0

I have made one sample demo for Push Notification with FCM. I am able to received Notification in Back Ground Mode as well as Foreground mode. But my question is:- When my application is in Background Mode Notification received but does not called any single Method so I can do action.

I agreed that when I have clicked on that method it will call one method but not in background.

Method is i have used

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

}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center  willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{

}

Please Help Me guys I got stuck.I need it Thanks in Advance. I have read so many links but not able to solved my Problem.

Note:- Please keep in mind I have used Google clouding messaging:- FCM

I have used in Objective c

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
Hardik1344
  • 2,917
  • 2
  • 15
  • 31

1 Answers1

1

As per our discussion in comments under your question. Here are a few more things to be done to achieve your requirement. I m posting these points as you were not familiar with content-available thing.

Open your Xcode project and

1: In the Project Navigator, select your project.

2: In the editor, select your iOS app target.

3: Select the Capabilities tab.

4: Enable Push notification under capabilities.

enter image description here

5: Enable the Background Modes capability.

6: Enable the Remote notifications background mode.

enter image description here

Now if your notification payload contains content-available : 1 then your app would be awakened in background.

The system delivers notifications by calling the application:didReceiveRemoteNotification:fetchCompletionHandler: method of your app delegate. Use that method to initiate your desired operations.

M Zubair Shamshad
  • 2,741
  • 3
  • 23
  • 45
  • Whatever things You have mentioned above I have already implemented ,Just waiting for back end person for setting "content-available : 1" in his Pay Load Code.Thank You – Hardik1344 Aug 22 '17 at 13:10