简体   繁体   English

设备锁定时的iOS推送通知操作

[英]iOS push notification action when device is locked

I'm handling push notifications in my app. 我正在我的应用程序中处理推送通知。 In the push notification alert, I've "Cancel" and "Join" buttons. 在推送通知警报中,我具有“取消”和“加入”按钮。 When the app is in background and not locked, the alert shows well with cancel and join buttons. 当应用程序处于后台且未锁定时,通过取消和加入按钮可以很好地显示警报。 When join is clicked, app will send a request to web server that user joined. 单击加入后,应用程序将向用户加入的Web服务器发送请求。 This is working fine. 一切正常。

But when the phone is locked, I'm seeing notification without any buttons. 但是当手机锁定时,我看到没有任何按钮的通知。 When user unlocks the device, which action will be sent to the app: cancel or join? 当用户解锁设备时,将向应用程序发送以下操作:取消还是加入?

How should I handle the situation where "join" is sent but the user wants to cancel? 我应该如何处理发送“ join”但用户要取消的情况?

You cannot specify more than one action for a push notification. 您不能为一个推送通知指定多个动作。 In other words, if the user taps the Cancel button, the OS will not even launch your app. 换句话说,如果用户点击“取消”按钮,则操作系统甚至不会启动您的应用程序。 Similarly, when the user unlocks the device by swiping over the notification, they implicitly execute the push notification's action button. 同样,当用户通过在通知上滑动来解锁设备时,他们会隐式执行推送通知的操作按钮。

In short: your app is never launched unless the user invokes the notification's action. 简而言之:除非用户调用通知的操作,否则您的应用程序永远不会启动。

The question is whether interpreting that single action as "Join" is a good idea. 问题是,将单个动作解释为“加入”是否是一个好主意。 (I think it isn't. Your app should ask for confirmation.) (我认为不是。您的应用应要求确认。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM