Forum Xamarin.iOS

Error accessing deviceToken when registering for push notifications (iOS 7.0.6)

jbrightjbright USMember ✭✭

I am following the sample code pretty much verbatim. (It seems the hardest part of Push Notifications is the whole cert/provisioning thing). In my FinishedLaunching method I've included:

UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;

And then I have a breakpoint set in here:

public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
        // This is the Id that we need to keep track of.

And I get the exception

System.Exception: Could not initialize an instance of the type 'MonoTouch.Foundation.NSString': the native 'initWithData:encoding:' method returned nil.
It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.

Which means I basically can't do anything with the deviceToken. Seems to be a bug with Xamarin but I wanted to see if there is something obvious I'm missing. Thanks.



Sign In or Register to comment.