Forum Xamarin.iOS

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:

UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge);

and I also added two methods:

public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
DeviceTokenHolder.deviceToken = deviceToken.ToString();
DeviceTokenHolder.registered = true;
new UIAlertView ("APNS", "Registered. Token: " + deviceToken.ToString(), null, "OK", null).Show();

public override void FailedToRegisterForRemoteNotifications (UIApplication application, NSError error)
new UIAlertView ("APNS", "Failed register", null, "OK", null).Show();

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.