Send silent notification to my iOS app in backgrou

2019-07-20 12:16发布

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 ?

1条回答
疯言疯语
2楼-- · 2019-07-20 12:51

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 .

查看更多
登录 后发表回答