Pass from UIUserNotificationTypeNone to UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound

匿名 (未验证) 提交于 2019-12-03 01:05:01

问题:

Do you know a way to pass from UIUserNotificationTypeNone to UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound (iOS8)?

To pass to UIUserNotificationTypeNone works well but not when the user try to switch again to enable ...

This is my code:

 // Register for Push Notifications, if running iOS 8                     if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])                     {                         UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);                         UIUserNotificationSettings * settingsAvailable = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];                         [application registerUserNotificationSettings:settingsAvailable];                         [application registerForRemoteNotifications];                     }                      else                     {                         // Register for Push Notifications before iOS 8                         [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];                     } 

After switch to enable the method of delegate "didRegisterUserNotificationSettings"

// Register to receive notifications [application registerForRemoteNotifications];  NSLog(@"The app is registered for the types: %@", notificationSettings); 

returns:

The app is registered for the types: <UIUserNotificationSettings: 0x15e9e790; types: (none);> 

Thanks in advance

回答1:

That's because the notification setting has been turned off in the system setting.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!