This documentation is for WSO2 IoT Server 3.2.0. View the documentation for the latest release.
Page Comparison - Configuring Android with Firebase Cloud Messaging (v.6 vs v.7) - IoT Server 3.2.0 - WSO2 Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Go to the Firebase API Console.
  2. Click CREATE NEW PROJECT.
  3. Provide a preferred name for the project (example: WSO2-FCM), select the country/region, and click CREATE PROJECT.


    The new project is created in few seconds, and you are navigated to the overview page of the project.

  4. Click Add Firebase to your Android App on the overview page of the project.

  5. Anchor
    fifth
    fifth

    Provide the package name of the WSO2 Android agent, that is org.wso2.iot.agent and click REGISTER APP.


  6. Click Download google-service.json to download the configurations.

  7. Replace the <ANDROID_AGENT_SOURCE_CODE>/client/client/google-services.json file with the google-services.json file you just downloaded.
  8. Click CONTINUE > FINISH to finish the process and create the application. 
    You are navigated to the overview of the created application.
  9. Anchor
    FCM_Token
    FCM_Token
    Scroll up the page and go to the CLOUD MESSAGING tab. Note down the Firebase Cloud messaging token. You need to provide this token as the server key when configuring the Android platform.

  10. Open <ANDROID_AGENT_SOURCE_CODE> via Android Studio, clean the project, and build the project.

    Info

    The WSO2 Android agent can't be built via the usual Android developer SDK, as it requires access to developer restricted APIs. Therefore, you need to replace the existing android.jar file that is in the <SDK_LOCATION>/platforms/android-<COMPILE_SDK_VERSION> directory with the explicitly built android.jar file that has access to the restricted APIs. 

    For more information on how to build the project, see creating a new APK file.

  11. Rename the created .apk file to android-agent.apk.
  12. Copy the renamed file and replace the existing android-agent.apk file that is in the <IoT_HOME>/core/repository/deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/public/assets directory.
  13. Open the <IoT_HOME>/core/repository/deployment/server/devicetypes/android.xml file and uncomment the configuration given below to enable communication via FCM.
    Code Block
    <PushNotificationProviderConfig type="FCM" isScheduled="false">
    </PushNotificationProviderConfig>
    Info

    The isScheduled element used to enable the scheduler task that sends push notifications. The task sends the push notifications in batches. So this reduces the sudden request burst when many devices try to access the server after receiving the push notification.

  14. Restart the WSO2 IoT Server in order to apply the changes.