12

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.

Baris Akar
  • 4,895
  • 1
  • 26
  • 54
GAURAV VIG
  • 269
  • 2
  • 9
  • did you register for push notification – Bhavin Bhadani Aug 05 '15 at 07:37
  • @Bhavin I have registered for push notification. – GAURAV VIG Aug 06 '15 at 06:14
  • Yes, the delegate is not getting called – GAURAV VIG Aug 06 '15 at 06:22
  • Do you really receive the notification during phone call? How do you know? There is [another question here](http://stackoverflow.com/questions/26996401/ios-remote-silent-notification-is-not-working-during-phone-calls-network-fluct), with a similar problem. – Baris Akar Aug 06 '15 at 07:36
  • @BarisAkar Banner is being displayed when push notification arrives. – GAURAV VIG Aug 06 '15 at 09:08
  • It seems only reasonable that newer versions of the OS do not invoke your callback, since this very issue has plagued iOS 5 and 6, much to the annoyance of herds of users. Have you verified this behavior when your app is not running, and checked that `application:willFinishLaunchingWithOptions:` is also not invoked with `UIApplicationLaunchOptionsRemoteNotificationKey` when the call terminates? – SwiftArchitect Aug 20 '15 at 02:00
  • Push notifications are triggered by the systems not by the app, so during a call the system is able to access to all the resources but the app may be suspended until finishing the phone call – Pablo A. Aug 23 '15 at 15:36
  • @GAURAVVIG Try adding sound to your notification. Will it work then? – EugZol Aug 24 '15 at 21:48
  • So far i know, show "push alert" doesn't not call didReceiveRemoteNotification, you need click at push received and after this push will be registered at didReceiveRemoteNotification and you can do what ever you want. Otherwise you could control and do a lot of action when background/foreground and that isn't permit, unless fill action like play musics. – Felipe Florencio Aug 31 '15 at 14:39

2 Answers2

0

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 :)

MayankSengar
  • 284
  • 5
  • 19
-1

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.

Abhinav
  • 37,684
  • 43
  • 191
  • 309