Пример #1
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            var oldDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey("PushDeviceToken");

            //There's probably a better way to do this
            var strFormat      = new NSString("%@");
            var dt             = new NSString(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(new MonoTouch.ObjCRuntime.Class("NSString").Handle, new MonoTouch.ObjCRuntime.Selector("stringWithFormat:").Handle, strFormat.Handle, deviceToken.Handle));
            var newDeviceToken = dt.ToString().Replace("<", "").Replace(">", "").Replace(" ", "");

            if (string.IsNullOrEmpty(oldDeviceToken) || !deviceToken.Equals(newDeviceToken))
            {
                //TODO: Put your own logic here to notify your server that the device token has changed/been created!
            }

            //Save device token now
            NSUserDefaults.StandardUserDefaults.SetString(newDeviceToken, "PushDeviceToken");

            //var wc = new WebClient();
            //registrationId="199";

            //userLogin u = controllerUserLogin.getuserLogin();

            /*
             * string myParameters = "iddev="+newDeviceToken+"&uname=iphone5Hipolyto&iduser=1024";
             * wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
             *
             * var result = wc.UploadString("http://www.letsolutions.com.mx/pushTestSpotlight/submit.aspx", "POST",myParameters);
             */
            // ParseLib.ParsePush..StoreDeviceToken (deviceToken);

            Console.WriteLine("Device Token: " + newDeviceToken);

            ParsePush.StoreDeviceToken(deviceToken);
            ParsePush.SubscribeToChannelAsync("events");


            // vtmService.registerDevice(newDeviceToken,int.Parse(u.userId));
        }
Пример #2
0
 public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
 {
     ParsePush.StoreDeviceToken(deviceToken);
     ParsePush.SubscribeToChannelAsync("");
 }