在 iPhone 上收到通知时会触发哪种方法(不是在点击并打开通知后)? [英] Which method will be triggered when the notification received on iPhone(not after the notification is tapped and opened)?

查看:23
本文介绍了在 iPhone 上收到通知时会触发哪种方法(不是在点击并打开通知后)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在使用 didReceiveRemoteNotification 来获取从 Parse 推送的通知的有效负载,但是,它仅在通知被点击和打开时触发.

I’m now using didReceiveRemoteNotification to get the payload of the notification pushed from Parse, however, it is only triggered when the notification is tapped and opened.

我想要做的是启动警报以提醒用户通知已到达,所以我想 didReceiveRemoteNotification 不是我想要的.为此,我应该研究哪种方法?

What I’m trying to do is start an alarm to remind the user that a notification has arrived, so I guess didReceiveRemoteNotification is not what I’m looking for. Which method should I look into for this purpose?

谢谢!

推荐答案

来自 WWDC 2014 iOS 通知的新变化

本地和推送通知让后台或非活动应用程序通知用户发生了感兴趣的事件,或者应用程序为他们提供了新信息.

WWDC 2013 多任务处理的新变化告诉我们如何完成这项工作.

The WWDC 2013 Whats New With Multitasking tells us how to get this work.

• 在 info.plist

• 在从服务器发送时在有效负载中添加 `content-available: 1

• add `content-available: 1 in your Payload while sending from server

• 让 iOS 处理它以在后台模式下打开您的应用

• lets iOS handle it to open your app for background mode

对于 iOS 10 及更高版本,您必须从目标中打开 Background Modes ->在 Capabilities 下,勾选必填字段.

For iOS 10 and above you have to switch ON the Background Modes from your Target -> Under Capabilities and check mark the required fields.

现在您可以根据需要设置闹钟.您可以设置预定的本地通知,直到用户与应用交互

Now you can set your alarm as you want. you may set a scheduled local notification until user interact with app

这篇关于在 iPhone 上收到通知时会触发哪种方法(不是在点击并打开通知后)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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