安装应用程序时,ios 8不会弹出通知权限

时间:2015-07-04 03:56:16

标签: ios8 push-notification

在较低版本的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]重新调用它,也不会调用请求权限的推送通知弹出窗口;弹出窗口没有显示。

1 个答案:

答案 0 :(得分:0)

确保为App ID配置推送通知 如果没有,设备将忽略任何推送相关的方法。 enter image description here