iOS - 设置页面如何删除通知

iOS - settings page how to remove just notifications

我有一个 IOS 设置屏幕(在 ios 8.0 上),它是使用以下代码生成的:

[[UIApplication sharedApplication] registerUserNotificationSettings:
        [UIUserNotificationSettings settingsForTypes:
        (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert) 
        categories:nil]];



[[UIApplication sharedApplication] registerForRemoteNotifications];

结果看起来是这样的:

我的目标是仅删除通知区域,但我希望保留隐私和 'use cellular data'。

在模拟器上没有隐私和 'use Cellular Data' 出现。这整个问题是因为我在模拟器上吗?

如果您使用 "registerForRemoteNotifications",此设置将自动存在并且不能省略。如果您想使用通知,则不允许禁用用户通知设置。

这可能已过时,但根据 Technote 2265

Resetting the Push Notifications Permissions Alert on 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. 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.