The FCM channel is a system-level push channel provided by Google. On mobile phones with the Google service framework, as the background processes are managed loosely, push notifications can be received if application processes are not force stopped. This channel is not supported for clusters in the Chinese mainland.
FCM PUSH supports the following two methods of key configuration. You just need to choose one of them, but the new proposal method using the server private key is recommended.
google-services.json
file.build.gradle
file:classpath 'com.google.gms:google-services:4.2.0'
Note:If
FCM Register error! java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.qq.xg4all. Make sure to call FirebaseApp.initializeApp(Context) first.
appears for a version earlier than 4.2.0, addYOUR_GOOGLE_APP_ID
in thestring.xml
file in theres/values
folder.
Add dependencies in the app-level build.gradle
file:
implementation 'com.tencent.tpns:fcm:[VERSION]-release' // For FCM PUSH, [VERSION] is the version number of the current SDK and can be obtained from "SDK for Android".
implementation 'com.google.firebase:firebase-messaging:17.6.0'
// In the app-level gradle file, add the following to the last line of the code and put google-services.json under the root directory of your app model
apply plugin: 'com.google.gms.google-services'
Note:
- For FCM PUSH, [VERSION] is the version number of the current SDK and can be obtained from the SDK for Android.
- Configure
google-play-services
for Google (v17.0.0+ or later recommended; an earlier version may cause FCM registration failure).
Add the following code before calling the Tencent Push Notification Service registration code XGPushManager.registerPush
:
XGPushConfig.enableOtherPush(this, true);
The log of successful FCM registration is as follows:
V/TPush: [XGPushConfig] isUsedOtherPush:true
I/TPush: [OtherPush] checkDevice pushClassNamecom.tencent.android.tpush.otherpush.fcm.impl.OtherPushImpl
I/TPush: [XGPushManager] other push token is : dSJA5n4fSZ27YeDf2rFg1A:APA91bGiqSPCMZTuyup**********f1fBIahZKYkth2OoDpixDPQmEZkQ11fX06mw_1kEaW5-jFmT4YwlER4qfX66h_BIoUxOyj_tKqZSUg7oHigIKaOrDWmMQfMAqGoT8qSfg other push type: fcm
-keep class com.google.firebase.** {*;}
Note:Obfuscation rules must be stored in the
proguard-rules.pro
file at the application project level.
Go to Settings > Application Management on the phone, select a specific application, and click Stop, Force Stop, or a similar button to stop the application. For most Chinese phones, closing the application process on the multitasking page can also be considered as force stopping the application process (this is not the case for phones outside the Chinese mainland).
Was this page helpful?