Android Push Notifications Initialization
Last updated
Last updated
FCM dependency:
Before you can start receiving push notifications, you need to obtain a FCM unique token string that identifies each FCM client app instance:
You can initialize the services with the obtained token. Please note that the FCM token can be changed through an application life cycle. Please make sure that the FCM token supplied to the messaging SDK is up to date. To notify the messaging SDK of the latest token, the following line of code can be called whenever necessary:
To retrieve push notifications, use a service that extends FirebaseMessagingService
. Refer to Firebase's messages handling documentation for detailed information.
Since Google Play services are banned in China, The messaging SDK provides Baidu push services as a substitute for FCM. The messaging SDK requires an api key and a secret key from Baidu:
Baidu dependency:
Note: Baidu push services require a number of additional permissions. You can find a list of permissions here.
Baidu API key is needed for Baidu push services initialization:
Note: The messaging SDK always considers FCM as a primary push provider and Baidu as a secondary push provider. If the messaging SDK detects Google Play services on the device, Baidu push services won't be initialized.