Problem with iOS 10 Notifications

nickelnextnickelnext ✭✭CHMember ✭✭
edited October 2016 in Xamarin.iOS


I had, for the past year, the same code for registering my app to the APNs and then registering to Azure Notification Hub

I just realized that, after iOS10 got released, the notification system on the iPhone device has been screwed up.

Lemme explain better:

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
            Hub = new SBNotificationHub(AppSettings.ListenConnectionString, AppSettings.NotificationHubName);

            Hub.UnregisterAllAsync(deviceToken, (error) =>
                if (error != null)
                    Console.WriteLine("Error calling Unregister: {0}", error);

                NSSet tags = new NSSet(Mvx.Resolve<INotificationService>().Tags.ToArray()); // create tags if you want
                Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) =>
                    if (errorCallback != null)
                        Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());


Now, this code gets called twice on iPhone with iOS 10, while the same iPhone with 9.x gets called just once.

By being called twice, each iPhone with 10+ iOS gets registered on my hub twice.
This has been tested on 1 iPhone 6 iOS10 and 1 iPhone 5s iOS10, they got the same behaviour, while an iPhone 6 with iOS 9.x behaves correctly (gets registered just once)

The new documentation about Notifications in iOS10 it's not very explicative, both on Xamarin and Apple sides.

Edit: for the sake of clarity, i add my code for registration

public void RegisterNativeNotification()
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                       UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                       new NSSet());
                UIApplication.SharedApplication.UnregisterForRemoteNotifications(); //serve??
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.UnregisterForRemoteNotifications(); //serve?

This code gets called thru Mvx.Resolve after logging in.
End edit

Does anybody else have this problem?


Sign In or Register to comment.