9

I have implemented silent push notification. Its not working if I killed app manually. After getting silent push notification, I have called one function which will send data to server.

Here is my code for Silent Push notification

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


NSLog(@"didReceiveRemoteNotification fetchCompletionHandler...........");
[MyviewController SendDataFunction];

handler(UIBackgroundFetchResultNewData);
}

Please guide me.

Update: -There is no way to launch app via silent notification or via background fetch if user has killed app manually in app switcher. To get notification user must start the app again. And still if anybody needs to activate app then PushKit + VOIP should be enabled for that app like whatsapp, refer the following link https://zeropush.com/guide/guide-to-pushkit-and-voip

nikBhosale
  • 531
  • 1
  • 5
  • 27

1 Answers1

0

didReceiveRemoteNotification is only called app when running and app in background state, it not called app not running state, that time you get notifications like this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 ...............
 ...............
 UILocalNotification *localNotif =[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
 if (localNotif) {

     NSLog(@"load notifiation *******");
    // Perform your actions
}

    return YES;
}
NANNAV
  • 4,875
  • 4
  • 32
  • 50
  • in [iOS7](https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:) silently handling push notification was added. Which says `If your app is suspended or not running, the system wakes up or launches your app and puts it into the background running state before calling the method.` – Janak Nirmal Jan 20 '14 at 06:53
  • Thanks for reply. I will try with this and let you know if its working or not. – nikBhosale Jan 20 '14 at 07:18
  • @NANNAV.. I tried this but still its not working for me. – nikBhosale Jan 20 '14 at 09:28
  • is there any different method to call web service if app is not running? – nikBhosale Jan 20 '14 at 10:22
  • are you get localNotif value when open the app. you not call any WS app is not running – NANNAV Jan 20 '14 at 10:26
  • 10
    @JanakNirmal if you continue reading, it says: `However, the system does not automatically launch your app if the user has force-quit it` – ninjaneer Oct 19 '14 at 20:13