I have integrated push notifications for my app. To catch the notifications I used this delegate.
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
in my app delegate.
So when the app is running in background if notification came and when I click on it this delegate fire. If the app is not running even in the background, If clicked on ntification then it fires
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Sofar it worked well. Then I wanted to catch notification in the background. So I found
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
this works for it.
So I just change my previous didReceive
method into this new didReceive
method. Now my problem is when app launch with push notification (if app doesnt run in background or forground and when click on the notification when comes) my app crashes. Even I cant debug and catch this situation.
What is the difference between these 2 delegates. Does my 2nd delegate fire when app launch with a notification? Please help me.