1.1.1. Integrate FCM Push

Foreign users need to integrate Google’s FCM push service. According to official document, Firebase is added to your Android project, then the client is configured by reference with Android Client Configuration Firebase

1.1.2. Configure FCM information to the Tuya Iot platform

Please refer to the document Register process of FCM. Configure the Sender ID, Server Key, and google-services.json files to the "App Workbench" of the iot platform - "APP SDK" corresponding to the configuration of the application "Push (Google)"

1.1.3. The registered token is registered to Tuya Cloud.

The onTokenRefresh method of inheriting the FirebaseInstanceIdService class monitors the generation of the registration token, and the token is registered to the graffiti cloud.

/**
* @param aliasId   user alias, the token generated by fcm
* @param pushProvider   registered push category   fcm is filled in"fcm”
*/
TuyaHomeSdk.getPushInstance().registerDevice(String aliasId, String pushProvider, new IResultCallback() {
    @Override
    public void onError(String code, String error) {
    }
    @Override
    public void onSuccess() {
    }
});

1.1.4. Receive and process messages

Receive processing messages in the onMessageReceived method in a class that extend FirebaseMessagingService

public class MyFcmListenerService extends FirebaseMessagingService {

    public static final String TAG = "MyFcmListenerService";

    public static HashMap<String, Long> pushTimeMap = new HashMap<>();

    @Override
    public void onMessageReceived(RemoteMessage message) {
        Log.d(TAG, "FCM message received" + message.getData().toString());

    }
}

Description

  • The content in message.getData() is the received push information.

1.2. User unbind

Description

When the user needs to unburden the application and user relationship, such as logging out, user can invoke the method of removing registered token by FCM.

FirebaseInstanceId.getInstance().deleteInstanceId();

1.2.1. Send Push

Add operation Push

Doodle Developer Platform - User Operations - Message Center - Add News

Add alarm Push

Graffiti Developer Platform - Corresponding Products - Extended Features - Alarm Settings - New Alarm Rules (App Push Mode)

1.2.2. Precautions

  • With FCM, you need to have Google services installed on your phone and you can connect to Google.

results matching ""

    No results matching ""