registerUserNotificationSettings没有显示提示iOS 8 [英] registerUserNotificationSettings not showing prompt iOS 8

查看:110
本文介绍了registerUserNotificationSettings没有显示提示iOS 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在iOS 8.1或8.2中显示 registerUserNotificationSettings

I can't seem to get a prompt to show for registerUserNotificationSettings in iOS 8.1 or 8.2.

以下是我在做的事情didFinishLaunchingWithOptions

  if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
       #ifdef __IPHONE_8_0
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert
                                                                                             |UIUserNotificationTypeSound | UIUserNotificationTypeBadge) categories:nil];
        NSLog(@"Reg settings %@", settings);
        [application registerUserNotificationSettings:settings];
    #endif
    }

此处也收到正确的回电:

Also getting the correct call back here:

- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
    NSLog(@"Did register - %@", notificationSettings);
}

但是没有显示任何提示。更令人讨厌的是,当设备被锁定时会显示警报,但不会发出通知警报声。关于解决方案的任何想法?

Yet no prompt is ever displayed. What's even more annoying is that an alert will display when the device is locked, but won't give the notification alert sound. Any ideas on a work around?

推荐答案

iOS 11 +更新:



自iOS 11起重置iOS上的推送通知权限警报过程似乎不再需要了。只需取消/重新安装应用程序。

Update for iOS 11+:

Since iOS 11 Resetting the Push Notifications Permissions Alert on iOS procedure seems not to be necessary anymore. Just un-/reinstall the app.

使用您的代码,我会在第一次启动应用程序时收到提示,并且仅在第一次发射。但afaik,这是iOS中的预期行为。
至少它与照片库,麦克风访问等相同:

Using your code, I get the prompt on the first app launch, and only on the first launch. But afaik, that's the expected behavior in iOS. At least it's the same for photo library, microphone access etc:


  1. 首次使用弹出窗口(或至少是使用它的请求)

  2. Apple在设置中添加条目(例如隐私,或仅在通知设置下)



首次使用



First usage


  1. 向下滚动,选择您的应用

  2. 选择通知

  3. 启用/禁用它们,或调整其行为



重置iOS上的推送通知权限警报



Resetting the Push Notifications Permissions Alert on iOS


第一次a支持推送的应用程序注册表用于推送通知,
iOS会询问用户是否希望接收该应用程序的通知。
一旦用户响应此提醒,除非设备已恢复或已卸载应用程序且每天至少花费
,否则不再显示

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

如果您想模拟首次运行的应用程序,可以将
的应用程序卸载一天。您可以通过以下步骤实现后者而不需要
实际等待一天:

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by following these steps:


  1. 从设备中删除您的应用。

  2. 完全关闭设备并重新打开。

  3. 转到设置>常规>日期&时间并将日期提前一天
    或更多。

  4. 再次关闭设备并重新打开。

  1. Delete your app from the device.
  2. Turn the device off completely and turn it back on.
  3. Go to Settings > General > Date & Time and set the date ahead a day or more.
  4. Turn the device off completely again and turn it back on.


来源: https://developer.apple.com/library/ios/technotes/tn2265/_index.html

这篇关于registerUserNotificationSettings没有显示提示iOS 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆