//Registering for remote notifications public override async void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { try { CurrentUser.app = application; CurrentUser.dt = deviceToken; var DeviceToken = deviceToken.Description; if (!string.IsNullOrWhiteSpace(DeviceToken)) { DeviceToken = DeviceToken.Trim('<').Trim('>'); CurrentUser.PutDeviceToken(DeviceToken); } ServiceWrapper svc = new ServiceWrapper(); await svc.InsertUpdateToken(DeviceToken, CurrentUser.RetreiveUserId().ToString()); LoggingClass.LogInfo("Device Token " + DeviceToken, screen); //CurrentUser.PutDeviceToken(DeviceToken); //UIAlertView alert1 = new UIAlertView() //{ //Title = DeviceToken, //}; //alert1.AddButton("OK"); //alert1.Show(); var oldDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey("PushDeviceToken"); // Has the token changed? if (string.IsNullOrEmpty(oldDeviceToken) || !oldDeviceToken.Equals(DeviceToken)) { await svc.InsertUpdateToken(DeviceToken, CurrentUser.RetreiveUserId().ToString()); //UIAlertView alert = new UIAlertView() //{ // Title = DeviceToken, //}; //alert.AddButton("OK"); //alert.Show(); } // Save new device token NSUserDefaults.StandardUserDefaults.SetString(DeviceToken, "PushDeviceToken"); } catch (Exception ex) { LoggingClass.LogError(ex.Message + " User not allowed to send notifications.", screen, ex.StackTrace); } }