When you are stuck with the FCM-based push notification implementation, See the following items:
Does your development environment satisfy the requirement?
To leverage the FCM feature, you need to satisfy several requirements such as using a device running Android 2.3 or later. See the Firebase official documentation for more details.
Is your server location set other than China?
You cannot use FCM if your server location is set to China.
Are you using the correct access keys?
The sender and receiver must be the same Kii application, meaning that they have to use the same AppID.
Is the FCM API key issued correctly?
Ensure that you generate a server key following the procedures in our tutorial. Also, ensure that the server key is registered to Kii Cloud as the GCM key on the developer portal.
The web API key, which can be obtained in the Settings page of the Firebase console, looks similar to the server key. However, if you specify it as the GCM key on the developer portal, Kii Cloud throws the error: Unable to validate GCM key.
Did you set the API key on the Kii Cloud developer portal?
You need to set the server key you've got on the Firebase console.
Does your application contain the Google Play services project?
You need to integrate the Google Play services in your mobile app project so as to include it as a library.
Check that you do not have any error shown on the console or in the log, though the library should be included automatically if you follow the steps described in the tutorial.
Did you make the necessary changes in the AndroidManifest.xml file?
Update the AndroidManifest.xml file by following the steps described in the tutorial. Also make sure that your updates on the AndroidManifest.xml are correct (e.g. the package name is updated to match with your mobile app).
Did you set the development/production correctly?
You need to select the correct environment. Make sure that you selected the correct environment in the following steps:
- When you initialize the Kii Cloud push notification feature (some APIs will apply the production environment as default).
- When sending a push message (e.g. sending from the developer portal or sending via API).
Does your mobile app project have a subclass of the FirebaseMessagingService?
Make sure that a subclass of the FirebaseMessagingService has been added to your project and
android:namein <service> tag in AndroidManifest.xml has it.
Did you install your device while a user is logged in?
You need to install a device by executing the
KiiUser.pushInstallation().install()method while a KiiUser is logged in.
If you have not done this, add a device installation logic like one described in the sample code. If you use the sample code without any changes, check the username and password of the test user.
Is the initialization process running ok?
Check if the initialization process is running correctly (e.g. with a debugger) by looking for any errors thrown.
Then check to see if the device installation succeeds. You should be able to find the string that looks like the device token.
Has the handler been called?
When the device receives an FCM push message, you will see nothing unless you have implemented a logic to display push messages. Check the handler's behavior by setting breakpoints with the debugger.
Are you using the correct bucket/topic scope?
Make sure that the scope you've subscribed to and the scope that triggered the push messages match.
- If you are using the Push to App messages, double check if the bucket scope matches.
- If you are using the Push to User messages, double check if the topic scope matches.
For example, the following Android Push to App sample does not work properly because the subscription is made in the application scope while the updating is made in the user scope.
- Subscribed topic:
- Updated topic:
Did you check the developer log?
You might find some push-related information in the developer log.
When an error occurs on a Kii Cloud API, the failure reason is sometimes recorded in the developer log. By inspecting the developer log, you might find some hints to resolve the issue.
Here is an example of the message recorded in the developer log when the FCM payload exceeds 4096 bytes.
2015-01-21T14:51:16.159+09:00 [ERROR] push.send description:Failed to send Push Message sender: origin:EXPLICIT messageID: type: succeeded-endpoints: failed-endpoints: exception:There are validation errors: payload - The size of the payload exceeds the maximum allowed for GCM messages: 4096 bytes.
Did you set the collapse_key?
If you've sent multiple FCM push messages but received only one push message, you might have set the collapse_key enabled. See the description by Google for more information on the collapse_key.
Does the issue occur only on Android 8.0 or later?
Your app might not be setting a notification channel if a push notification does not show up on the status bar only on Android 8.0 or later. See Showing a message on the status bar for the details.
Note that although a message will not appear on the status bar without a notification channel, the push notification itself is delivered to the app.