在 iOS 10 上处理用户通知 [英] Handling user notifications on iOS 10

查看:21
本文介绍了在 iOS 10 上处理用户通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法确定用户何时点击 iOS 10 上的用户推送通知.

I have troubles determining when the user taps on a user push notification on iOS 10.

到目前为止,我一直在使用 -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:]

So far, I have been using the -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] which is called when

  • Case 1:应用程序处于活动状态并收到推送
  • Case 2:当用户点击收到的通知后启动应用程序
  • Case 1: the application is active and the push is received
  • Case 2: when the user launched the app after taping a received notification

这个方法注释明确说

请注意,此行为与 application:didReceiveRemoteNotification: 形成对比,后者在这些情况下不会被调用,并且如果实现此方法也不会被调用.

Note that this behavior is in contrast to application:didReceiveRemoteNotification:, which is not called in those cases, and which will not be invoked if this method is implemented.

所有这些都按预期工作.

All this work as expected.

现在 iOS 10 弃用了这种委托方法并引入了 UserNotification 框架,我无法使用该框架,因为我仍然面向 iOS 8 和 9.

Now iOS 10 deprecated this delegate method and introduced the UserNotification framework which I cannot use because I'm still targeting iOS 8 and 9.

当我的应用在 iOS 10 上运行并在应用处于活动状态时收到推送(Case 1),-[AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] 被正确调用.

When my app is running on iOS 10 and a push is received while the app is active (Case 1), the -[AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] is called correctly.

同样在 iOS 10 上,当用户通过点击通知(Case 2)启动应用程序时,此方法不会被调用.

Again on iOS 10, when the user starts the app by tapping a notification (Case 2) this method is not called.

我意识到当我实现旧的 -[UIApplicationDelegate application:didReceiveRemoteNotification:] 时,它会在 Case 2

I realise that when I implement the older -[UIApplicationDelegate application:didReceiveRemoteNotification:] it is the one that gets called in the Case 2

在 iOS 8 和 9 上,在 Case 2 中,调用了 -[AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] 方法.

On iOS 8 and 9, in the Case 2 it is the -[AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] method is called.

这是否意味着我必须更新我的应用程序并实现仅适用于 iOS 10 的旧委托?

Does it mean that I have to update my application and implement the older delegate just for iOS 10?

所以问题是,在不使用 UserNotification 框架的情况下,在 iOS 10 上处理接收到的推送的用户交互的正确实现是什么.

So the question is, what is the proper implementation of handling the user interaction of a received push on iOS 10 without using the UserNotification framework.

干杯,扬

推荐答案

此问题已在 iOS 10.1 Beta 1 中修复!!

This has been fixed in iOS 10.1 Beta 1 !!

-[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] 在用户点击通知时被正确调用.

The -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] is correctly called when the user taps on a notification.

这篇关于在 iOS 10 上处理用户通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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