FCM migration is optional, but recommended as Google deprecated GCM and is planning on dropping GCM client APIs in April of 2019. For more info, please read the GCM F.A.Q.
Urban Airship supports the FCM client library starting in SDK 9.1.0. It is available in a new package
urbanairship-fcm
. The FCM package is not compatible with the deprecated package urbanairship-sdk
and urbanairship-gcm
.
Migration Steps:
- Add Firebase to your app.
- Import your GCM project as a Firebase project.
- Update your build.gradle to use the new
urbanairship-fcm
and removeurbanairship-sdk
:
dependencies {
...
// Urban Airship SDK - FCM
implementation 'com.urbanairship.android:urbanairship-fcm:9.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
// Urban Airship SDK - ADM (Optional - if you support ADM)
implementation 'com.urbanairship.android:urbanairship-adm:9.1.0'
}
- If your application uses its own
FirebaseMessagingService
,FirebaseInstanceIDService
, or another provider that uses FCM, you will need to forward token refresh and message received calls to the Urban Airship SDK:
// FirebaseInstanceIdService:
public void onTokenRefresh() {
// Notify Urban Airship that the token is refreshed.
AirshipFirebaseInstanceIdService.processTokenRefresh(getContext());
}
// FirebaseMessagingService:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
AirshipFirebaseMessagingService.processMessageSync(getContext(), remoteMessage);
}