ios 8 安装应用时不弹出通知权限
Posted
技术标签:
【中文标题】ios 8 安装应用时不弹出通知权限【英文标题】:ios 8 doesn't pop the permission for notification when installing the app 【发布时间】:2015-07-04 03:56:16 【问题描述】:在较低版本的 ios 上一切正常,我的推送通知代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) categories:nil];
[application registerUserNotificationSettings:settings];
else
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
application.applicationIconBadgeNumber = 0;
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
//register to receive notifications
[application registerForRemoteNotifications];
//for sielent notifications
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
#endif
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
NSLog(@"My token is: %@", deviceToken);
1) 首次运行时,即使我使用 [[UIApplication sharedApplication] registerForRemoteNotifications] 重新调用请求权限的推送通知弹出窗口,也不会调用它;弹出窗口未显示。
【问题讨论】:
您是否在创建 APNS 证书后创建并分配了新的配置文件? 【参考方案1】:确保为您的App ID 配置了推送通知。 如果没有,设备将忽略任何与推送相关的方法。
【讨论】:
以上是关于ios 8 安装应用时不弹出通知权限的主要内容,如果未能解决你的问题,请参考以下文章
iOS 8 和 Cordova:应用程序在首次启动时立即请求推送通知权限