用户拒绝推送授权时的 ios 静默推送通知 [英] ios silent push notification when user denies Push Authorization

查看:205
本文介绍了用户拒绝推送授权时的 ios 静默推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始一个带有 IOS 静默推送通知的项目,以允许应用程序在后台更新.到目前为止我还不清楚的一个基本点是,如果用户完全拒绝推送消息会发生什么?这是否会拒绝应用接收静默推送通知,还是只会导致设备无法在视觉/听觉上向用户显示消息?

I am just starting a project with silent push notifications for IOS, to allow the app to update in the background. One basic point that is unclear to me so far is what happens if the user rejects push messaging entirely? Does that reject silent push notifications from being received by the app, or only cause the device not to display the messages to the user visually/audibly?

我意识到 Apple 的规则是应用程序不仅应该在允许推送的情况下工作,而且我很好奇如何最好地处理这种情况.

I realize apple has rules that an app should not only work if push is allowed, but I'm curious of how to best handle this situation.

推荐答案

正如评论中所述,静默通知不受用户权限的影响.您唯一需要注意的是通知格式:

As stated out in the comments, silent notifications aren't affected by the user permissions. The only thing you have to take care of is the notifications format:

发送静默通知需要对通知的有效负载进行特殊配置.如果您的负载配置不正确,通知可能会显示给用户,而不是在后台发送到您的应用程序.在您的负载中,确保满足以下条件:

The sending of a silent notification requires a special configuration of the notification’s payload. If your payload is not configured properly, the notification might be displayed to the user instead of being delivered to your app in the background. In your payload, make sure the following conditions are true:

  • payload 的 aps 字典必须包含值为 1content-available 键.
  • 有效载荷的aps 字典必须包含alertsoundbadge键.
  • The payload’s aps dictionary must include the content-available key with a value of 1.
  • The payload’s aps dictionary must not contain the alert, sound, or badge keys.

来源苹果

对于 iOS 8 之前的版本,这是我的旧答案(仍然适用于可见通知,这不是这里的主题):如果用户拒绝远程通知,这扇门就会关闭.从技术上讲,您可以考虑自己的后台服务,但这需要在后台持续运行,例如通过持续使用 GPS(坏主意).

This was my old answer true for pre-iOS 8 versions (and still is for visible notifications, which aren't topic here): If the user denies remote notifications, this door is closed. Technically you could think of your own background service, but this needs to run constantly in the background, e.g. via continuous GPS usage (bad idea).

更好的选择是说服用户在合适的时间接受并询问.这篇文章应该给你一个大致的思路:http://techcrunch.com/2014/04/04/the-right-way-to-ask-users-for-ios-permissions/

A better option is to convince the user to accept and ask at the right moment in time. This article should give you a rough direction what to think about: http://techcrunch.com/2014/04/04/the-right-way-to-ask-users-for-ios-permissions/

这篇关于用户拒绝推送授权时的 ios 静默推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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