I came across a similar scenario, I wrote this code for debugging if my application wakes up in a quiet notification or not.
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *str = [defaults objectForKey:@"key"]; if (str == nil) { str = @"didReceiveRemoteNotification"; }else{ str = [NSString stringWithFormat:@"%@, didReceiveRemoteNotification",str]; } [defaults setObject:str forKey:@"key"]; [defaults synchronize]; }
This code works as if the application woke up, than you will receive a callback in this method, and the method name will be written in NSUserDefaults . Therefore, when you debug your application manually, you can see the str value of the string variable, if there was a line didReceiveRemoteNotification , than you know that your application woke up.
Note. This only works in the background for me. I get the value when I did not force my application to close (terminate manually), but when I close my application from the application switcher, I will not get any value.
I hope this works.
user5690918
source share