6. Message Sync
Monitor target third-party software message notifications and sync messages to the device side
6.1. Push Message
After monitoring target third-party software message notifications, push messages to the device side
Sample Code
//WatchManager is a subclass of WatchOpImpl, must be configured in sdk 1.3
WatchManager watchManager = WatchManager.getInstance();
//Simulate receiving WeChat message
String appName = HealthConstant.PACKAGE_NAME_WECHAT;
NotificationMsg msg = new NotificationMsg()
.setAppName(appName)
.setFlag(NotificationHelper.getNotificationFlag(appName))
.setContent("Young man:[1] Hello, welcome to use the health assistant, enjoy sports, help health!")
.setTitle("Test message")
.setTime(time)
.setOp(NotificationMsg.OP_PUSH);
watchManager.pushMessageInfo(msg, new OnWatchOpCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Callback success
}
@Override
public void onFailed(BaseError error) {
//Callback failure
//error: Error message
}
});
Important
Need to obtain permission to monitor application notifications
Need to check if the application has notification function enabled
6.1.1. Information Description
Information Type Table
Type |
name |
Value |
|---|---|---|
0 |
Timestamp |
Timestamp(4Bytes, refer to sports record timestamp format Time Structure (4Bytes)) |
1 |
Package Name |
Maximum limit: 31 Bytes |
2 |
App Icon |
Flag(1 Byte):
0: Default icon
1: SMS icon
2: WeChat icon
3: QQ icon
4: DingTalk icon
|
3 |
Title |
Maximum limit: 36 Bytes |
4 |
Content |
Maximum limit: 133 ~ 439 Bytes, determined by firmware |
6.2. Remove Message
After monitoring system clear message notifications, notify the device to remove the message
Sample Code
//WatchManager is a subclass of WatchOpImpl, must be configured in sdk 1.3
WatchManager watchManager = WatchManager.getInstance();
//Simulate revoking WeChat message
String appName = HealthConstant.PACKAGE_NAME_WECHAT;
NotificationMsg msg = new NotificationMsg()
.setAppName(appName)
.setFlag(NotificationHelper.getNotificationFlag(appName))
.setTime(time)
.setOp(NotificationMsg.OP_REMOVE);
watchManager.removeMessageInfo(msg, new OnWatchOpCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Callback success
}
@Override
public void onFailed(BaseError error) {
//Callback failure
//error: Error message
}
});
Important
Need to obtain permission to monitor application notifications