Can not register for APNS

BartoszCicheckiBartoszCichecki USMember
edited February 2014 in Xamarin.iOS

Hello Guys!

I have another question (probably lame one).

So I have a simple code that is supposed to register for APNS. I have all certificates and profiles set up on my Apple account. So in AppDelegate.cs in FinishedLaunching method I added:

<br /> UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge);<br />

and I also added two methods:

<br /> public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)<br /> {<br /> DeviceTokenHolder.deviceToken = deviceToken.ToString();<br /> DeviceTokenHolder.registered = true;<br /> new UIAlertView ("APNS", "Registered. Token: " + deviceToken.ToString(), null, "OK", null).Show();<br /> }</p> <p>public override void FailedToRegisterForRemoteNotifications (UIApplication application, NSError error)<br /> {<br /> new UIAlertView ("APNS", "Failed register", null, "OK", null).Show();<br /> }<br />

THe problem is that when I launch the app on my iPhone I never reach the RegisteredForRemoteNotifications method nor FailedToRegisterForRemoteNotifications (I set up breakpoints). When I launch the app on iPhone simulator FailedToRegisterForRemoteNotifications is of course invoked.

A same code that uses the same certificates, but written in Objective C in Xcode, works like a charm and I get token immediately.

I am using Xamarin trial license.


Sign In or Register to comment.