当iOS应用程序位于前台时忽略推送通知 [英] Ignore push notifications when iOS app is in the foreground

查看:345
本文介绍了当iOS应用程序位于前台时忽略推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当大的iOS项目。当应用程序在前台接收到通知时,该通知以类似于AlertView的形式显示。我想摆脱它。我不知道这是我很久以前编程的东西,还是项目中的一个框架(Parse,Onesignal,FBSDK)正在这样做。我的问题是,如何确定警报视图的来源,因此可以删除该代码。我没有在任何地方实现 willPresentNotification 方法(我已经搜索了整个项目)。我确实有一个 didReceiveRemoteNotification 方法,即使只在点击通知时才调用该方法,我还是尝试将其注释掉。我也搜索了整个项目的UIAlertView和UIAlertController,但没有用。

I have a fairly large iOS project. When the app receives a notifications while in the foreground, the notification is displayed in something that looks like an AlertView. I want to get rid of it. I have no idea if this is something I programmed myself a long time ago, or if one of the frameworks in the project (Parse, Onesignal, FBSDK) is doing this. My question is, how can I find out where that alert view is coming from, so I can remove that code. I have not implemented the willPresentNotification method anywhere (I have searched through the entire project). I do have a didReceiveRemoteNotification method, and even though that should only be called when a notification is tapped, I have tried commenting it out. I have also searched through the entire project for UIAlertView and UIAlertController, to no avail.

推荐答案

OneSignal SDK 自动使用新的 UserNotifications框架在设备上检测到。

OneSignal SDK automatically uses the new UserNotifications Framework, when iOS10 is detected on device.

在这种情况下,AppDelegate方法 didReceiveRemoteNotification 方法未调用,而是 UNUserNotificationCenterDelegate 被调用,由SDK捕获以记录点击/观看次数。

In this case, the AppDelegate method didReceiveRemoteNotification method not get called, instead methods in UNUserNotificationCenterDelegate get invoked, which is captured by SDK to record clicks/views.

OneSignal使用回调来处理收到的通知。

OneSignal use callback to handle received Notification.


  • OSHandleNotificationReceivedBlock:在应用程序仅在焦点对准时会收到通知

  • OSHandleNotificationReceivedBlock: Called when the app receives a notification while in focus only

OSHandleNotificationActionBlock:在用户打开或点击通知上的操作时调用。

OSHandleNotificationActionBlock: Called when the user opens or taps an action on a notification.

OSNotificationOpenedResult:用户收到的通知返回的信息。

OSNotificationOpenedResult: The information returned from a notification the user received.

您可以直接实现 UNUserNotificationCenterDelegate 方法来处理应用程序中与通知相关的交互。

You can directly implement UNUserNotificationCenterDelegate methods to handling notification-related interactions in your app.

这篇关于当iOS应用程序位于前台时忽略推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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