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); } }
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"); }
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); } }); }
public static string GetTestDeviceId() { var info = AdvertisingIdClient.GetAdvertisingIdInfo(UIRuntime.CurrentActivity); return(info.Id); }