通话期间未调用远程通知回调 [英] Remote Notification callback not being called during phone call

查看:18
本文介绍了通话期间未调用远程通知回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用程序,其中在接收推送通知时编写了后台提取代码.我在 .plist 中启用了后台模式,推送通知有效负载中的 content-available 键设置为 1,注册推送通知并使用委托

I have created an app in which background fetch code is written on receiving push notification. I have enabled the background mode in .plist, content-available key is set to 1 in push notification payload, registered for push notification and using delegate

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler  

现在,当我的应用程序在后台时,我会接到一个电话.在通话过程中,我收到了关于我的应用的推送通知.
在通话期间收到推送通知时,未调用推送通知委托.

Now when my app is in background, I receive a call. During call, I receive a push notification for my app.
On receiving the push notification during a call, push notification delegate is not getting called.

推荐答案

所以这里在电话中处理推送通知/远程通知的方法是:当接到电话时,应用程序变为非活动状态,当电话呼叫断开时,应用程序变为活动状态,并调用 AppDelegate 中的方法applicationDidBecomeActive".因此,您可以在 applicationDidBecomeActive 中的 didReceiveRemoteNotification 方法中回调远程通知.

So to handle the push notification/Remote Notification during phone call here below the method is: When the phone call is received the app is become inactive and when the phone call is disconnected then the app become active and the Method "applicationDidBecomeActive" in the AppDelegate is called.Hence you can call back the Remote Notification in the didReceiveRemoteNotification method in the applicationDidBecomeActive.

即使您可以在应用终止时处理推送通知.例如在特定的 viewController 上移动, didFinishLaunchingWithOptions 包含字典,其中包含应用程序终止和收到推送通知时通知的有效负载.这可以作为 .`.

Even you can handle the push notification when the app is terminated. such as move on the specific viewController, didFinishLaunchingWithOptions contains the dictionary which contains the payload of the notification when app is terminated and Push notification is received . This can be done as . `.

if (launchOptions != nil)
{
    // opened from a push notification when the app is closed

 NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

if (userInfo != nil)
   {

    }
}
else
{
    // opened app without a push notification.
}`

希望这会奏效:)

这篇关于通话期间未调用远程通知回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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