GCM Troubleshooting

When you are stuck with the GCM-based push notification implementation, See the following items:

  1. Does your development environment satisfy the requirement?

    To leverage the GCM feature, you need either an Android device running Android 2.3 or higher with the Google Play Store application installed or an emulator running Android 2.3 with Google APIs. See the Google official documentation for more details.

  2. 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.

  3. Is the GCM API key issued correctly?

    Ensure that you generate a GCM API key following the procedures in our tutorial. Also, ensure that the API key is registered to Kii Cloud on the developer portal.

    You can also generate a server key in the Google Developers Console, but you might end up with the server key that is not usable on Kii Cloud. For example, the server key generated by pressing the Android Key button is for a device, so you cannot use it on Kii Cloud. The key with the server IP address being specified may not be usable on Kii Cloud.

  4. Did you enable the Google Cloud Messaging for Android on the Google API Console?

    If you create a server key before you turn the Google Cloud Messaging for Android ON, you will get an error "Unable to validate GCM key" when you try to register it on the Kii Cloud developer portal. In this case, enable the Google Cloud Messaging for Android, recreate a GCM API key and register it on the Kii Cloud.

  5. Did you set the API key on the Kii Cloud developer portal?

    You need to set the API key you've got on the Google API console.

  6. 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. To do so, install the Google Play services with the Android SDK Manager and link it to your application project.

    Also, double check that you do not have any error shown on the console or in the log to confirm that the library is properly integrated with your project.

  7. Did you make the necessary changes in the AndroidManifest.xml file?

    Update the AndroidManifest.xml file by following the steps described in our 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).

  8. 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).
  9. Does your mobile app project have a subclass of the GcmListenerService?

    Make sure that a subclass of the GcmListnerService has been added to your project and android:name in <service> tag in AndroidManifest.xml has it.

  10. 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.

  11. 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.

  12. Has the handler been called?

    When the device receives a GCM 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.

  13. 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: Kii.bucket("myBucket");
    • Updated topic: user.bucket("myBucket");
  14. 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 GCM 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.
  15. Did you set the collapse_key?

    If you've sent multiple GCM 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.

  16. 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.