unregisterForRemoteNotifications 仍然显示“允许通知";如设置 [英] unregisterForRemoteNotifications still shows "Allow Notifications" as on in Settings

查看:105
本文介绍了unregisterForRemoteNotifications 仍然显示“允许通知";如设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个设置页面,允许用户打开和关闭推送通知.这是我的问题.如果用户在初始系统提示时允许推送通知,则稍后改变主意并将 UISwitch 设置为否,我的关闭开关操作为:[[UIApplication sharedApplication] unregisterForRemoteNotifications];

I'm creating a settings page which allows the user to turn push notifications on and off. Here's my question. If the user Allows Push Notifications at the initial system prompt then later changes their mind and turns the UISwitch to No, I have my off switch action to be: [[UIApplication sharedApplication] unregisterForRemoteNotifications];

但是如果您转到手机上的设置应用程序,允许通知"仍设置为开".我知道取消注册会使令牌无效,因此他们不会再收到任何通知.但我认为如果设置应用程序仍然说他们允许通知,他们会感到困惑.我是否仍然需要将用户从应用程序重定向到设置应用程序以关闭远程通知?或者我可以添加一些代码来将设置"应用程序中的允许通知"更改为关闭".

But if you go to the settings app on the phone Allow Notifications is still set to On. I know unregistering them invalidated the token so they won't get any more notifications. But I think they will be confused if the settings app still says they are Allowing Notifications. Do I still need to redirect the user out of the app to settings app to turn OFF remote notifications? Or is there some code I can add that will change Allow Notifications to Off in the Settings app.

推荐答案

您无法从您的应用程序更改设置应用程序.您必须从设置应用程序中手动禁用它.如另一个答案中所述,您可以提示消息永久禁用(请通过设置应用程序执行此操作).

you can't change setting app from your app. You have to manually disable it from setting app. as mentioned in another answer you can prompt message to permanently disable (please do it through the settings app).

第二件事,如果你想让你的服务器知道不要向这个设备发送通知,那么你可以这样做,

Second thing if you want to make your server know that don't send notification to this device then You can do something like this,

如果您想在应用程序内部执行,则使用一个标识符并根据推送通知启用和禁用按钮将其发送到服务器.因此,您的服务器端编码使用此标识符并据此工作.就像标识符是说它已启用,而不是您的服务器将发送通知,否则不会.

if you want to do Inside the app then use one identifier and send it to server according push notification enable and disable button. So, your server side coding use this identifier and work according to that. Like identifier is say it's enable than your server will send notification otherwise not.

您可以使用以下代码检查用户设置 enabledisable Push Notifications.

You can check that user set enable or disable Push Notifications using following code.

启用或禁用 iPhone 推送通知

Enable or Disable Iphone Push Notifications

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) 
 // Yes it is..

希望这会有所帮助:)

这篇关于unregisterForRemoteNotifications 仍然显示“允许通知";如设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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