Search code examples
iosobjective-cfirebasefirebase-cloud-messagingfirebase-console

Send silent notification to my iOS app in background, through FCM message console


I want to send silent notifications to my iOS app, for which i have implemented FCM into it. while app is in background, i need to perform some operation when app gets the notification from the FCM .

for that ,execution process will enter into the method called

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


but problem is that, it does not enter into this method until user taps on the notification .

As per (FCM documents) , if we want to wake up our app in background then we have to pass content_available parameter with key value true . but when i am sending this information through your FCM Compose message console in custom data, our app is not waking up nor getting activated in background, until user taps on the notifications. I guess the notifications which all i am receiving are normal notifications, not silent one . so FCM implementation and sending notification is working perfectly it seems.

i have followed all the FCM documents given and referred almost all possible connected stackoverflow solutions . even i have followed apple documents for sending remote notifications . and lastly i am sending "content_available" : true through FCM message console. but it is not becoming silent notification and i am receiving notification as normal notification which user has to tap on, to enter into the method didReceiveRemoteNotification.

i have referred many links like these here, here, & here

is it even possible through FCM to receive notifications in backgrounds (like silent notifications) or not ? or any other way to implement it ?


Solution

  • i have got the solution for this . just follow this link and its answer .

    and enter the json body like this in postman

    {
        "to":"eEBrg.... .... .... .... (FCM Token)",
        "priority": "normal",
        "content_available": true,
        "notification":{
     (do not send body here if you want to send the silent notification)
          "requesttype":"ring" // optional
        }   
    }
    

    ... and your app will wake up in background and will enter into the method didReceiveRemoteNotification .