FCM is backward compatible with GCM. The steps to configure FCM on AWS are identical to the GCM setup procedure and (at least for now). FCM transparently works with GCM and SNS with respect to server-side configuration.
However, if you send useful files to the data Android device, they will not be processed unless you run the client service , which extends the FirebaseMessagingService . The default JSON message generator in the AWS console sends data messages that will be ignored by your application if the above service is not implemented. To get around this for initial testing, you can provide a custom notification payload that will be received by your device (until your application is in the foreground).
There are instructions GCM-FCM migration instructions provided by Google, however the changes you need to make are mainly on the application side.
The steps you must follow to test GCM / FCM in your application using SNS:
- Create the Platform application in SNS by selecting Google Cloud Messaging (GCM) as the Push Notification Platform and providing the server API key in the API field.
- Select the platform application and click the Create platform endpoint button.
- Provide the InstanceID generated by your application. You must extend the
FirebaseInstanceIDService and override the onTokenRefresh method to see this in your Android application. After you have done this , uninstall and reinstall the application, and your token should be printed on the Debug console in Android Studio at the first boot. - Click the Add Endpoint button.
- Click the ARN link for your platform application.
- Select the newly created endpoint for your device and click the Publish to endpoint button.
- Select JSON Message Format and click the JSON Message Generator button.
- Enter a test message and click Create JSON
- Now comes the "piece received."
The message generated by SNS will look like:
{ "GCM": "{ \"data\": { \"message\": \"test message\" } }" }
As mentioned earlier, the data payload will be ignored if no service to receive them has been implemented. We would like to test without writing too much code, so instead we should send a notification payload. To do this, simply modify the JSON message to read:
{ "GCM": "{ \"notification\": { \"text\": \"test message\" } }" }
Once you do this, make sure your application is not running on the device and click the Post message button. You should now see a notification that appears on your device.
You can, of course, do all this programmatically through the Amazon SNS API, however all the examples seem to use the data payload, so you need to keep that in mind and generate the payload that matches your use case.
Nathan Dunn Jul 28 '16 at 2:58 2016-07-28 02:58
source share