public override void RegisterForRemoteNotifications (string senderId, RemoteNotificationType[] types)
{
SystemLogger.Log(SystemLogger.Module.PLATFORM,"Registering senderId ["+ senderId +"] for receiving push notifications");
UIApplication.SharedApplication.InvokeOnMainThread (delegate {
UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.None;
try {
if(types != null) {
SystemLogger.Log(SystemLogger.Module.PLATFORM,"Remote Notifications types enabled #num : " + types.Length);
foreach(RemoteNotificationType notificationType in types) {
notificationTypes = notificationTypes | rnTypes[notificationType] ;
}
}
SystemLogger.Log(SystemLogger.Module.PLATFORM,"Remote Notifications types enabled: " + notificationTypes);
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
UIUserNotificationType uiUserNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(uiUserNotificationTypes, new NSSet (new string[] {}));
UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);
}else{
//This tells our app to go ahead and ask the user for permission to use Push Notifications
// You have to specify which types you want to ask permission for
// Most apps just ask for them all and if they don't use one type, who cares
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
}
} catch(Exception e) {
SystemLogger.Log(SystemLogger.Module.PLATFORM,"Exception ocurred: " + e.Message);
}
});
}