Firebase Cloud Messaging iOS (compatibility with G

2019-06-11 16:02发布

问题:

I'm implementing an application on iOS which main purpose is to handle push notifications received from the server. Server is using GCM for messages delivery.

  1. If I decided to use the FCM framework on iOS (not even decided, just haven't found GCM framework for Swift 3, nor on Cocoapods), how much compatible will it be with the existing GCM - is it necessary to migrate it to FCM?

  2. Is it possible to receive data messages (not notifications - the work as the should) while application is terminated. While application is in the background or foreground, the delegate method is being invoked and data are handled as they should, but when it is terminated - nothing is invoked, only if user touches the notification popup, but I need to fill data from data message to the database even when app is closed.

  3. How to determine the topic to which the message was sent? The reason I need this is that I have to make different actions based on to what topic/s the received message was sent to. I know that on Android, there is a key in received JSON - from, but what about iOS?

Thank you.

回答1:

  1. All the GCM features are compatibile with FCM (same token, topics etc).
    New FCM features might not be available in GCM.

  2. On iOS is not possible to receive data-messages if the application is terminated (as in it's not listed in the app switcher menu). This is a limitation imposed by iOS.

  3. for now I suggest to add (replicate) the information about which topic you are targeting in the the data payload of the message



回答2:

Is it necessary to migrate it to FCM?

YES, and here is the guide that can help you to migrate a GCM Client App for iOS to Firebase Cloud Messaging

Is it possible to receive data messages?

Try to check this page to know how the FCM message work. You can learn here all the possibilities that you can do with your message in FCM.

How to determine the topic to which the message was sent?

Now, for this question, this Topic Messaging on iOS guide can help you to answer your question.

Hope this information helps you.