I am trying to update local sqlite database when notification received and app is closed/killed by user. Everything works fine when app is background or active mode.
Reference : REFERENCE STACK LINK 1
Here is code i am trying:
-(void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
NSLog(@"App Background :%@",userInfo);
    if(application.applicationState == UIApplicationStateInactive) {
    NSLog(@"Inactive");
    //Show the view with the content of the push
    [self BackgrounCall:userInfo];
    completionHandler(UIBackgroundFetchResultNewData);
    } else if (application.applicationState == UIApplicationStateBackground) {
    NSLog(@"Background");
    //Refresh the local model
    [self BackgrounCall:userInfo];
    completionHandler(UIBackgroundFetchResultNewData);
   } else {
    NSLog(@"Active");
    //Show an in-app banner
    [self BackgrounCall:userInfo];
    completionHandler(UIBackgroundFetchResultNewData);
       }  
   }
Question : Why it is not working in application INACTIVE state. Is there a solution to this issue ?
- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
// Override point for customization after application launch.
[[Database shareDatabase] createEditableCopyOfDatabaseIfNeeded];
if(launchOptions != nil)
{  
    // opened from a push notification when the app is closed
    NSDictionary* userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    if (userInfo != nil)
    {
        NSLog(@"userInfo->%@", [userInfo objectForKey:@"aps"]);
        [self application:application didReceiveRemoteNotification:launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];
    }
}
else
{   
}
 }
 
    