0
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type
{

    [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    viewcontroller2 *historyVC = [storyboard instantiateViewControllerWithIdentifier: @"second"];


    self.window.rootViewController = historyVC;
    [self.window makeKeyAndVisible];


}

My app not opening from background to foreground but as per apple doc they said app will be come foreground.

Victor Casé
  • 745
  • 8
  • 15
saurabh
  • 31
  • 9

2 Answers2

0

The following method - pushRegistry:didUpdatePushCredentials:forType: is invoked when push notification is received. until and unless user launches the app, we cant open the app. when u open app. make preferences to show your respective view controller.

Avijit Nagare
  • 8,482
  • 7
  • 39
  • 68
sanjayzed
  • 57
  • 9
  • please see above code i do excectally as for open controller but not coming app from background to foreground after receiving push (ios 8 voip push) – saurabh Feb 12 '16 at 08:48
  • yes got it it's can open app from background,but can't open view controller – saurabh Apr 21 '17 at 11:24
0

Using push kit, newer your app will get open automatically. that would not come to foreground from background or terminated state.

Your app will only gets active in background mode for some 30 seconds and you would be able to do rest of work whichever is needed. ( For example setting some values in Database etc )

Hasya
  • 9,792
  • 4
  • 31
  • 46
  • ok but how whatsapp use pushkit for voip call because the opened app for forground how it's possible, without user intraction on notification?. – saurabh Oct 03 '16 at 13:07
  • Pushkit will just provide you data, now schedule local notification that will come in notification center, app will invoke in background upto your sound file play time ( max 30 seconds ). now you tap on notification or its event, then only app will come to foreground, this is how whatapp, skype other do. – Hasya Oct 03 '16 at 13:11