在应用程序内启用或禁用 iPhone 推送通知 [英] Enable or Disable Iphone Push Notifications inside the app

查看:21
本文介绍了在应用程序内启用或禁用 iPhone 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以接收推送通知的 iphone 应用程序.目前,我可以通过转到 iphone 设置/通知来禁用我的应用的推送通知.

I have a iphone app which is enable to receive push notifications. Currently i can disable push notifications for my app by going to the iphone settings/Notifications.

但我想在我的应用中添加一个开关或按钮来启用或禁用推送通知.

But i want to add a switch or button inside my app to enable or disable push notifications.

它可以做到,因为我在foursqure iphone应用程序中看到它做到了.他们在设置呼叫通知设置中有一个部分,用户可以为应用启用或禁用不同类型的通知.

It can be done because i saw it in foursqure iphone app did it. They got a section in settings call notification settings and user can enable or disable different kind of notification for the app.

我在网上四处寻找合适的解决方案,但仍然没有找到方法.任何人都可以提供任何想法如何做到这一点?

I look all over the net to find a proper solution for this but still not found a way. Can any one please give any idea how to do that ?

提前致谢:)

推荐答案

首先是你不能启用和禁用 推送通知在应用程序内部.如果您发现某些应用程序执行了此操作,则必须有变通的解决方案.

First thing is that you can not enable and disable push notification in inside the app. If you have found some apps which did it than there must be workaround solution.

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

Like 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..

希望能帮到你..

这篇关于在应用程序内启用或禁用 iPhone 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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