使用 Urban Airship 服务的应用程序的推送通知策略 (iPhone)

发布于 2024-08-26 06:02:56 字数 637 浏览 5 评论 0原文

我正在构建一个应用程序,它使用精细的 Urban Airship api 向用户发送推送通知。

该应用程序会跟踪用户添加到应用程序的事件日期。 这意味着我没有适当的服务器来处理推送,应用程序本身只是 当用户添加事件日期和时间时,使用 Urban AS 安排推送通知。

如果用户决定在事件发生之前删除该事件,我会使用 Urban AS 取消安排该事件。一切都很好。但是,我不想向已禁用通知的用户发送通知,因为这些通知不是免费的:)

我知道 Apple 的推送通知 API 可确保用户在设置中关闭通知时不会收到任何通知。他们将简单地忽略 Urban AS 发送的预定通知,这浪费了带宽和金钱。

如何判断用户是否已禁用我的应用程序的通知?

此外,除了测试用户是否已关闭通知,然后告诉 Urban AS 取消所有通知之外,我没有其他选择。用户重新打开它们,我将不得不遍历所有事件并重新安排它们:/每次应用程序运行时。

有人能想出一种方法让我不必用各种条件代码填充我的 appDelegate 来测试这些场景吗?例如,自上次运行应用程序以来,用户已关闭推送,用户已将它们打开自从上次以来。我还担心用户会理解这种行为吗?

我想我只是要求一些关于此推送/城市飞艇设置的最佳实践:) 谢谢。

I am building an app that uses the fine Urban Airship api to send the user push notifications.

The app keeps track of event dates that are added to the app by the user.
This means I have no server in place for dealing with push, the app itself simply
schedules a push notification with Urban AS when the user add the event date and time.

If the user decides to delete the event before it occurs I un-schedule it with Urban AS. All is good. I, however, would like to not send notifications to a user that has disabled notifications as these notifications are no free:)

I know the Push Notification API from Apple makes sure the user will not receive any notification if they turned them off in settings. They will simply ignore the scheduled notifications Urban AS sends, which is a waste of bandwidth and money.

How can I tell if the user has disabled the notification for my app?

Also, I see no other option than to test if the user has turned off notification and then tell Urban AS to cancel all notifications and if the user turns them back on, I will have to go through all events and re-scheduled them :/ each time the app runs.

Can anyone think of a way for me not to have to fill up my appDelegate with all kinds of conditional code for testing these scenarios? e.g. user has turned off push since last running the app, user has turned them on since last time. I am also concerned if the user will understand this behavior?

Guess I am just asking for a bit of best practice with this push / Urban Airship setup:)
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪了杯 2024-09-02 06:02:56

据我所知, [[UIApplication sharedApplication]enabledRemoteNotificationTypes] 将返回用户当前为您的应用程序启用的通知类型。

否则,你是对的。您必须在每次应用程序启动时调用此方法,并且在用户重新启用通知的情况下,重新安排您之前删除的所有事件。

至于用各种条件填充应用程序委托的问题,您可能需要编写一个单独的 PushNotificationsController(不是 UIViewController,只是 NSObject 子类)来处理所有与推送相关的内容。

As I see it, [[UIApplication sharedApplication] enabledRemoteNotificationTypes] will return the notification types the user has currently enabled for your app.

Otherwise, you are correct. You have to call this method on every app launch and, in the case that the user has reenabled notifications, reschedule all events that you had formerly deleted.

As to the question of filling up your app delegate with all kinds of conditionals, you might want to write a separate PushNotificationsController (not a UIViewController, just a NSObject subclass) that will handle all push-related stuff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文