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

南楼画角 提交于 2019-12-11 02:29:22

问题


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:


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 .



来源:https://stackoverflow.com/questions/47770256/send-silent-notification-to-my-ios-app-in-background-through-fcm-message-consol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!