Remote Notification callback not being called during phone call

拟墨画扇 提交于 2019-12-23 07:37:01

问题


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.


回答1:


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.

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.
}`

hope this will work :)




回答2:


I guess during phone call cellular chip is being used for voice transmission. Data transmission is extra work for the chip to do which could affect battery life dramatically. This is a more a conscious decision by Apple to make it more of a silent notification during phone calls.



来源:https://stackoverflow.com/questions/31826116/remote-notification-callback-not-being-called-during-phone-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!