iOS通知操作而无需打开应用 [英] iOS notifications actions without opening the app

查看:180
本文介绍了iOS通知操作而无需打开应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不启动应用程序的情况下拦截用户对推送通知的单击或用户对丰富推送通知操作按钮的单击?我已经实现了所有必要的设置,以注册推送通知,接收推送通知以及处理简单丰富的推送通知,并且用户单击了丰富推送通知中的某些操作按钮.但是,当用户单击某个操作按钮时,应用程序将启动,我可以在其中进行处理:

Is there a way to intercept user's click on push notification or user's click on rich push notification action button, WITHOUT LAUNCHING THE APP? I have implemented all necessary settings to register for push notifications, to receive push notifications and to handle simple and rich push notifications, and user's click on some action button inside rich push notification. But, when user clicks on some action button, app launches, and I can handle it inside:

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    let notification = JSONParser.parseRichPushNotification(notification: response.notification.request.content.userInfo)
    if let responseIdentifier = 
    {
         print(response.actionIdentifier)
    }
//......
}

例如,我想在不启动应用程序的情况下执行一些后台操作,或者如果推送通知数据中有链接,则要打开Web浏览器.在iOS中有可能吗?

I would like to perform, for example some background action without launching the app, or to open web browser if there is a link in push notification data. Is it that possible in iOS?

我发现了类似的问题:

  • Is there a way to open urls received in a push notification without opening the app in ios 10?
  • Handle Push Notification when the App is off, or without opening the App at all - iOS
  • Android notifications actions without opening the app

但是我认为我没有找到问题的答案.我还阅读了有关静默通知的信息,但是我不确定是否可以将其用于此目的,即当用户单击操作按钮而不自动启动应用程序时执行一些操作.

But I think that I didn't find the answer for my question. I have also read about silent notifications, but I am not sure if I can use them for this purpose, i.e. to perform some operation when user clicks on action button without automatic launching the app.

顺便说一句,我正在使用OneSignal推送通知

Btw, I'm usine OneSignal push notifications

有人知道如何执行此操作吗?预先感谢

Does anybody know how to perform this? Thanks in advance

推荐答案

您可以通过创建 查看全文

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