using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AOT;
using UnityEngine;

public class iOSHander
{
    private iOSHander() { }
    private static readonly iOSHander singleInstance = new iOSHander();
    public static iOSHander Instance
    {
        get
        {
            return singleInstance;
        }
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void ResultHandler(string device, string IDFA);


    [MonoPInvokeCallback(typeof(ResultHandler))]
    static void resultHandler(string deviceStr, string IDFAStr)
    {
        Debug.Log("resultHandler : deviceStr = " + deviceStr + "IDFAStr = " + IDFAStr);


        Constant.Instance.device = deviceStr;

    }
#if UNITY_IOS
    [DllImport("__Internal")]
    static extern void BridageDeviceAndIDFA(IntPtr resultHandler);

    public void Handler()
    {
        ResultHandler handler = new ResultHandler(resultHandler);
        IntPtr fp = Marshal.GetFunctionPointerForDelegate(handler);
        BridageDeviceAndIDFA(fp);
    }
#endif






}
