Last Updated on : 2024-01-10 09:09:16
Tuya supports push notifications through third-party channels, such as Google Firebase Cloud Messaging (FCM), Umeng, Xiaomi, Huawei, and MEIZU. To integrate this feature into your app development, you must request app key information from each third-party platform and initialize the SDK as instructed in the documents. This topic describes how to integrate with U-Push to enable push notifications through Umeng.
If your push notifications are targeted to mainland China and developed based on U-Push, follow Umeng’s documents to integrate U-Push into your project.
Request key information required by push notifications through Umeng. For more information, see Apply for Push Key from Umeng.
Log in to the Tuya IoT Development Platform and go to the SDK Development page. On the Certificates tab, copy and paste the requested key information to the Push (Umeng) section.
The configurations must meet the following requirements:
After your project is integrated with Umeng, use the Umeng SDK to set the user ID. Push notifications are sent to users by user IDs.
mPushAgent.setAlias(aliasId, ALIAS_TYPE, new UTrack.ICallBack() {
@Override
public void onMessage(boolean isSuccess, String message) {
}
});
Parameters
Parameter | Description |
---|---|
aliasId | It can be the unique ID that is automatically assigned by your app to each user. |
ALIAS_TYPE | Set it to TUYA_SMART . |
Register aliasId
to the Tuya IoT Cloud.
Parameters
Parameter | Description |
---|---|
aliasId | The user alias. After the user alias obtained in the previous step is registered to the cloud, Tuya Smart Life App SDK will send push notifications to the user’s app. |
pushProvider | The type of push notification. Set the value to umeng . |
Example
TuyaHomeSdk.getPushInstance().registerDevice(String aliasId, String pushProvider, new IResultCallback() {
@Override
public void onError(String code, String error) {
}
@Override
public void onSuccess() {
}
});
If a third-party channel is used, the activity
of the dialog box must be named SpecialPushActivity
. For example, to enable push notifications through Umeng, SpecialPushActivity
inherits from UmengNotifyClickActivity
, and the complete package name path is com.activity.SpecialPushActivity
.
For more information on how to integrate with custom push notifications through Umeng, see Umeng’s documents. Example:
UmengMessageHandler messageHandler = new UmengMessageHandler(){
@Override
public void dealWithCustomMessage(final Context context, final UMessage msg) {
new Handler(getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(context, msg.custom, Toast.LENGTH_LONG).show();
}
});
}
};
mPushAgent.setMessageHandler(messageHandler);
msg.custom
is the received push notification. The content of msg.custom
is delivered over the protocol in the following format:custom=tuya://message?a=view&ct="title"&cc="content"&p=>{}&link=tuyaSmart%3A%2F%2Fbrowser%3Furl%3Dhttp%253A%252F%252Fwww.baidu.com;
Uri uri = Uri.parse(message);
.API description
You can call the following Umeng method to remove a registration token. This applies when you want to unbind your app from users in specific scenarios, such as logout.
mPushAgent.deleteAlias(aliasId, "TUYA_SMART", new UTrack.ICallBack() {
@Override
public void onMessage(boolean isSuccess, String message) {
}
});
Parameters
Parameter | Description |
---|---|
aliasId | The unique ID that is automatically assigned by your app to each user. |
ALIAS_TYPE | Set it to TUYA_SMART . |
After you integrate with the capabilities of push notifications, you can configure push notifications on the Tuya IoT Development Platform.
Log in to the Tuya IoT Development Platform and go to the Marketing push page. Then, users can receive your in-app message regarding new arrivals, trending information, and more. This can help to build user engagement.
To create a device push notification, log in to the Tuya IoT Development Platform, and in the left-side navigation pane, choose Product > Notifications. For more information, see Configure Push Notification.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback