예제 #1
0
        public static void GetOaid(Context context, OaidCallback callback)
        {
            if (null == context || null == callback)
            {
                Log.Error(TAG, "invalid input param");
                return;
            }
            try
            {
                //Get advertising id information. Do not call this method in the main thread.
                AdvertisingIdClient.Info info = AdvertisingIdClient.GetAdvertisingIdInfo(context);
                Log.Info(TAG, "AdvertisingIdClient.GetAdvertisingIdInfo function called successfully.");

                if (null != info)
                {
                    Log.Info(TAG, "AdvertisingIdClient.Info.Id: " + info.Id);
                    Log.Info(TAG, "AdvertisingIdClient.Info.IsLimitAdTrackingEnabled: " + info.IsLimitAdTrackingEnabled);
                    callback.OnSuccess(info.Id, info.IsLimitAdTrackingEnabled);
                }
                else
                {
                    callback.OnFail("OAID is null");
                }
            }
            catch (IOException ex)
            {
                Log.Error(TAG, "AdvertisingIdInfo IOException");
                callback.OnFail("AdvertisingIdInfo IOException:" + ex.Message);
            }
        }
예제 #2
0
            protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
            {
                try
                {
                    AdvertisingIdClient.VerifyAdId(context, adId, true);
                }
                catch (AdIdVerifyException ex)
                {
                    Log.Info("SetVerifyIdTask", ex.Message);
                    return(null);
                }

                return("success");
            }
예제 #3
0
 public void GetAdvertisingId(Action <string> callback)
 {
     string   advertisingId = string.Empty;
     Activity activity      = Xamarin.Forms.Forms.Context as Activity;
     Task     task          = Task.Factory.StartNew(() =>
     {
         try
         {
             AdvertisingIdClient.Info adinfo = AdvertisingIdClient.GetAdvertisingIdInfo(activity);
             callback(adinfo.Id);
         }
         catch (Exception)
         {
             callback(string.Empty);
         }
     });
 }
예제 #4
0
        public static string GetTestDeviceId()
        {
            var info = AdvertisingIdClient.GetAdvertisingIdInfo(UIRuntime.CurrentActivity);

            return(info.Id);
        }