Пример #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");

            Console.WriteLine("Device Token: " + newDeviceToken);
        }
Пример #2
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");

			Console.WriteLine("Device Token: " + newDeviceToken);
		}
Пример #3
0
        public void TestUpdate()
        {
            var queryRecord = new SecRecord(SecKind.GenericPassword)
            {
                Account    = TestAccountName,
                Accessible = SecAccessible.WhenUnlocked
            };

            SecStatusCode queryStatusCode;
            SecRecord     queryResult;

            queryResult = SecKeyChain.QueryAsRecord(queryRecord, out queryStatusCode);
            if (queryStatusCode == SecStatusCode.ItemNotFound)
            {
                var newRecord = new SecRecord(SecKind.GenericPassword)
                {
                    Account    = TestAccountName,
                    Accessible = SecAccessible.WhenUnlocked,
                    Generic    = TestSecret
                };
                var newRecordStatusCode = SecKeyChain.Add(newRecord);
                Assert.True(newRecordStatusCode == SecStatusCode.Success);
            }

            queryResult = SecKeyChain.QueryAsRecord(queryRecord, out queryStatusCode);
            Assert.True(queryStatusCode == SecStatusCode.Success);
            Assert.True(TestSecret.Equals(queryResult.Generic));

            // try updating
            SecRecord newSecret = new SecRecord()
            {
                Generic = TestNewSecret
            };
            var updateStatusCode = SecKeyChain.Update(queryRecord, newSecret);

            Assert.True(updateStatusCode == SecStatusCode.Success,
                        string.Format("Got {0} instead", updateStatusCode));

            queryResult = SecKeyChain.QueryAsRecord(queryRecord, out queryStatusCode);
            Assert.True(queryStatusCode == SecStatusCode.Success);
            Assert.True(TestNewSecret.Equals(queryResult.Generic));
        }
Пример #4
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));
        }