Configuring Android with Firebase Cloud Messaging
Prerequisites
 Clone theÂ
cdmf-agent-android
 GIT repository. This will be referred to asÂ<ANDROID_AGENT_SOURCE_CODE>
.git clone https://github.com/wso2/cdmf-agent-android/tree/release-2.0.0
Make sure that the Android agent release version matches the IoT Server release version. Click here for more information.
- Download and install Android Studio. For more information, see installing Android Studio.
Follow the instructions given below to configure WSO2 IoT Server Firebase Cloud Messaging (FCM):
- Go to the Firebase API Console.
- Click CREATE NEW PROJECT.
Provide a preferred name for the project (example: WSO2-FCM), select the country/region, and click CREATE PROJECT.
The new project will be created in few seconds, and you will be navigated to the overview page of the project.Click Add Firebase to your Android App on the overview page of the project.
-
Provide the package name of the WSO2 Android agent, that isÂ
org.wso2.emm.agent
and click ADD APP.
The generated
google-service.json
file will download. - Click CONTINUE >Â FINISH to finish the process and create the application.Â
You will then be navigated to the overview of the created application.
- Click the menu icon of the project you created and click Manage.
- Go to the CLOUD MESSAGING tab and note down the Firebase Cloud messaging token. You need to provide this token as the server key when configuring the Android platform.
Replace the
<ANDROID_AGENT_SOURCE_CODE>/client/client/google-services.json
file with thegoogle-services.json
file that downloaded in the fifth step.OpenÂ
<ANDROID_AGENT_SOURCE_CODE>
 via Android Studio and build the project.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.- Rename the createdÂ
.apk
 file toÂandroid-agent.apk
. - Copy the renamed file and replace it instead of the existingÂ
android-agent.apk
 file that is in the<IoT_HOME>/core/repository/deployment/server/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset
 directory. - Open theÂ
<IoT_HOME>/core/repository/deployment/server/devicetypes/android.xml
 file and copy the configuration given below to enable communication via FCM.<PushNotificationProvider type="FCM"> </PushNotificationProvider>