Offline Push (Google FCM)

Last updated: 2020-03-13 11:53:49

    To use FCM offline push, you need to install Google Play Services on your mobile phone and use it outside Mainland China.

    Process Description

    The process of implementing offline message push is as follows:

    1. A developer registers an account on the vendor’s platform. After passing developer certification, the developer can apply for the push service.
    2. Create the push service, bind it with app information, and obtain information such as the push certificate, password, and key.
    3. Log in to IM Console and specify the push certificate and relevant information. The IM server generates a unique certificate ID for each certificate.
    4. Integrate the push SDK provided by the vendor with the developer’s project and configure it based on the vendor’s requirements.
    5. After integrating the IM SDK with the project, report the certificate ID, device information, and other required information to the IM server.
    6. When the client app is killed by the system or user without logging out from IM, the IM server notifies the user of this through message push.


    Step 1: Configuring Firebase and the FCM SDK

    The website used in this step is the official website of Firebase, which is accessible only outside Mainland China.

    1. Refer to Delivering Firebase Cloud Messages to set Firebase and integrate the FCM SDK. After starting the app, obtain the device registration token.
    2. Refer to FCM Test Instructions to test notification messages and ensure that FCM has been integrated successfully.
    3. Log in to the Firebase console and click your app card to go to the app configuration page.
    4. Click to the right of "Project Overview", and choose Project Settings > Cloud Message Delivery.
    5. Record Old Server Key and Sender ID.

    Step 2: Host certificate information to IM

    1. Log in to Tencent Cloud IM Console and click the target app card to go to the basic configuration page of the app.

    2. Click Add Certificate in the Android Platform Push Settings area.

      If you already have a certificate and only want to modify its information, you can click Edit in the corresponding certificate area to modify and update the certificate.

    3. Set the following parameters based on the information obtained in Step 1:

      • Push Platform: select Google.
      • Application Package Name: enter the name of the client app package.
      • Sender ID: enter the Sender ID of the Google push service app.
      • Old Server Key: enter the Old Server Key of the Google push service app.
    4. Click OK to save the settings. The certificate information will take effect in 10 minutes.

    5. Record the ID of the certificate after the push certificate information is generated.

    Step 3: Report the push information to the IM server

    After users successfully log in, use the setOfflinePushToken method of TIMManager to report certificate ID that is generated and hosted by the IM console and token that is generated by the client after FCM integration, to the IM server.

    After the token and certificate ID are correctly reported, the IM service can bind users with the corresponding device information, enabling the use of FCM to push notifications.

    Sample code in the demo is as follows:

    Define the certificate ID constant:

    /****** Start of FCM offline push parameters ******/
    // Use your certificate ID in the FCM push certificate information in the IM console
    public static final long GOOGLE_FCM_PUSH_BUZID = 6768;
    /****** End of FCM offline push parameters ******/

    Report the push certificate ID and token:

     * Reporting the push certificate ID and device information in
    public class ThirdPushTokenMgr {
        private static final String TAG = "ThirdPushTokenMgr";
        private String mThirdPushToken;
        private boolean mIsTokenSet = false;
        public static ThirdPushTokenMgr getInstance () {
            return ThirdPushTokenHolder.instance;
        private static class ThirdPushTokenHolder {
            private static final ThirdPushTokenMgr instance = new ThirdPushTokenMgr();
        public String getThirdPushToken() {
            return mThirdPushToken;
        public void setThirdPushToken(String mThirdPushToken) {
            this.mThirdPushToken = mThirdPushToken;  // The token value is specified here.
        public void setPushTokenToTIM(){
                QLog.i(TAG, "setPushTokenToTIM mIsTokenSet true, ignore");
            String token = ThirdPushTokenMgr.getInstance().getThirdPushToken();
                QLog.i(TAG, "setPushTokenToTIM third token is empty");
                mIsTokenSet = false;
            TIMOfflinePushToken param = new TIMOfflinePushToken(Constants.GOOGLE_FCM_PUSH_BUZID, token);
            TIMManager.getInstance().setOfflinePushToken(param, new TIMCallBack() {
                public void onError(int code, String desc) {
                    Log.d(TAG, "setOfflinePushToken err code = " + code);
                public void onSuccess() {
                    Log.d(TAG, "setOfflinePushToken success");
                    mIsTokenSet = true;

    Step 4: Offline push

    After the certificate ID and token are successfully reported, the IM server sends messages through FCM push notifications to the user before the logout of the IM user on the device and after the app is killed.

    • FCM push does not guarantee 100% success in reaching target users.
    • FCM push may be delayed. Usually, this pertains to the timing of app killing. In some cases, it pertains to the FCM push service.
    • If the IM user has logged out or has been forced logout by the IM server (for example, due to login on another terminal), the device cannot receive push messages.


    Can I customize the push notification sound?

    No, FCM push currently does not support custom notification sounds.

    How can I learn the cause of a failure to receive push messages?

    1. No push service is guaranteed 100% successful in reaching target users and zero FCM exceptions. Therefore, if one or two push messages fail to reach users during a fast and continuous push process, it is usually due to the restrictions of FCM’s push frequency control.
    2. Based on the push process, check whether the FCM push certificate information is correctly configured in IM Console.
    3. Check that your FCM project has been correctly configured and has obtained a token.
    4. Check that you have reported push information to the IM server correctly.
    5. Manually kill the app on your device, send several messages, and check that you can receive notifications within one minute.
    6. If you still cannot receive push messages after performing the preceding steps, you can submit a ticket with the relevant time, SDKAppID, certificate ID, and push receiving UserID.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback