xcode - 在推送通知授权期间检测用户操作

时间:2015-01-30 12:10:15

标签: ios push-notification

使用推送通知开发应用程序,我需要知道用户在推送通知授权期间何时点击两个按钮之一(不允许,允许)。

有没有代表这样做?

1 个答案:

答案 0 :(得分:2)

回拨将在致电-[UIApplication registerUserNotificationSettings:]时进行。用户授予应用程序的设置将作为第二个参数传入。

如果您想查看用户是否拒绝该选项,您可以检查!notification.types是否如此:

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    // Make sure we check for user permission for location
    UIUserNotificationSettings *notificationTypes = [[UIApplication sharedApplication] currentUserNotificationSettings];
    if (!notificationTypes.types) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You need to enable notifications for this functionality to work." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
}