Ejemplo n.º 1
0
        //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);
            }
        }
Ejemplo n.º 2
0
		public async void updatetoken(CustomerResponse cr)
		{
			try
			{
				if (CurrentUser.GetDeviceToken() != null)
				{
					ServiceWrapper svc = new ServiceWrapper();
					await svc.InsertUpdateToken(CurrentUser.GetDeviceToken(), cr.customer.CustomerID.ToString());
				}
			}
			catch (Exception ex)
			{
				LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
			}
		}