SDK API
MTCorePrivatesApi
- Mainly used for information configuration
- All methods need to be called in the main process. Please do not put it in the child process by judging the process before calling the method, otherwise, unexpected errors will occur
configHeartbeatInterval
- You need to call this method in the Application.onCreate() method
- Please call before init
/**
* Set heartbeat interval
*
* You need to call in the Application.onCreate() method
*
* @param context is not empty
* @param heartbeatInterval The time unit is milliseconds. It must be greater than 0. The default value is 4 minutes and 50 seconds.
*/
public static void configHeartbeatInterval(Context context, long heartbeatInterval)
The code example is as follows
- Demonstrate setting the heartbeat interval to 3 minutes
MTCorePrivatesApi.configHeartbeatInterval(this,3 * 60 * 1000);
configConnectRetryCount
- You need to call this method in the Application.onCreate() method
- Please call before init
/**
*Set the number of long connection retries
*
* You need to call in the Application.onCreate() method
*
* @param context is not empty
* @param connectRetryCount Number of retries. The default value is 3. At least 3 retries
*/
public static void configConnectRetryCount(Context context, int connectRetryCount)
The code example is as follows
Demonstrate setting reconnection times to 10
MTCorePrivatesApi.configConnectRetryCount(this,10);
configDebugMode
- It needs to be called in the Application.onCreate() method
- Please call before init
- Private cloud Engagelab log format, search for "ENGAGELAB-PRIVATES"
- Private cloud Engagelab will print logs in the main process and sub process respectively
/**
* Set whether to debug mode, which will print more detailed logs
*
* You need to call in the Application.onCreate() method
*
* @Param context is not empty
* @param enable Whether to debug mode, true is the debug mode, false is not
*/
public static void configDebugMode(Context context, boolean enable)
The code example is as follows
- The sdk works in two processes, the main process and the sub process. The sub process name is the process attribute name of the MTCommonService sub class service
- The log tag of the private cloud sdk is "ENGAGELAB-PRIVATES"
- The logs of udp/tcp/http related operations are in the child process
- Therefore, if the message cannot be pushed, please turn on the debugging mode first, and then go to the sub process to obtain the log with the tag of "ENGAGELAB-PRIVATES" for technical support analysis
// It is recommended to set it to true when the application is not online for easy integration
MTCorePrivatesApi.configDebugMode(context.getApplicationContext(), true);
// It is recommended that the application be set to false after going online
MTCorePrivatesApi.configDebugMode(context.getApplicationContext(), false);
configSM4
- It needs to be called in the Application. onCreate() method
- Please call before init
/**
* Configure to use national security encryption
*
* @param context is not empty
*/
public static void configSM4(Context context)
The sample code is as follows
// Enable national security encryption, and use the default encryption method if not called
MTCorePrivatesApi.configSM4(context.getApplicationContext());
getUserId
When the return value is null, you should check whether the environment is configured and whether initialization methoid is called If the configuration is correct, it may still be in the process of connection. You can obtain it when onConnectStatus returns true
/**
* Get the userId of the current device, the unique ID of the Engagelab private cloud, which can be the same as push
*
* @param context is not empty
* @return userId
*/
public static String getUserId(Context context)
The code example is as follows
String userId = MTCorePrivatesApi.getUserId(context);
getRegistrationId
- When the return value is null, you should check whether the environment is configured and whether initialization is called.
- If the configuration is correct, it may still be in the process of connection. You can obtain it when onConnectStatus returns true.
/**
* Get the registrationId of the current device, the unique ID of the Engagelab private cloud, which can be the same as push
*
* @param context is not empty
* @return registrationId
*/
public static String getRegistrationId(Context context)
The code example is as follows:
String registrationId = MTPushPrivatesApi.getRegistrationId(context);
MTPushPrivatesApi
- Mainly used for push function
- All methods need to be called in the main process. Please do not put it in the child process by judging the process before calling the method, otherwise, unexpected errors will occur
configOldPushVersion
- The background server has not upgraded the version tag: V3.5.4-newportal-20210823-gamma.57. The front end must call this method, or it will notify you that there is a problem when clicking notification jump.
- Call in the Application.onCreate() method
- Please call before init
/**
* Configure the push version as 3.9. X
*
* @param context is not empty
*/
public static void configOldPushVersion(Context context)
The code example is as follows:
public class ExampleApplication extends Application {
@Override
public void onCreate() {
// Turn on debug mode
MTCorePrivatesApi.configDebugMode(context.getApplicationContext(), true);
// Click to jump using the old notification
MTPushPrivatesApi.configOldPushVersion(context.getApplicationContext());
// initialization
MTPushPrivatesApi.init(context.getApplicationContext());
}
}
init
- It is recommended to call in the Application.onCreate() method
/**
* MTPush initialization
*
* It is recommended to call in the Application.onCreate() method
*
* @param context is not empty, please use the applicationContext object
*/
public static void init(Context context)
The code example is as follows:
public class ExampleApplication extends Application {
@Override
public void onCreate() {
// Turn on debug mode
MTCorePrivatesApi.configDebugMode(context.getApplicationContext(), true);
// initialization
MTPushPrivatesApi.init(context.getApplicationContext());
}
}
goToAppNotificationSettings
- After starting the sdk, you can decide whether to call this interface according to the onNotificationStatus callback result
/**
* Go to the notification switch setting page
*
* @param context not empty
*/
public static void goToAppNotificationSettings(Context context)
The code example is as follows:
// Go to the notification switch setting page, and the customer needs to manually turn on the notification switch
MTPushPrivatesApi.goToAppNotificationSettings(this);
// After inheriting MTCommonReceiver, copy the onNotificationStatus method to obtain the status of the notification switch. If enable is true, it indicates that it has been successfully enabled
@Override
public void onNotificationStatus(Context context, boolean enable) {
if(enable){
// The notification switch is set to ON
}
}
turnOnPush
- It is generally used to enable push notification switch after calling turnOffPush
- Repeated calls will only take effect once. If they are already enabled, they will not take effect again
- If there is no problem with the environment,onConnectStatus will call back the results
- Currently supported channels::Engagelab/Huawei/Xiaomi/Meizu/oppo/vivo
/**
* Enable Push, and the status of the persistent storage switch is true. The default is true
*
* @param context not empty
*/
public static void turnOnPush(Context context)
The code example is as follows:
// Push is enabled by default
MTPushPrivatesApi.turnOnPush(context);
// After inheriting MTCommonReceiver, copy the onConnectStatus method to obtain the connection status of the long connection. If enable is true, it indicates that it has been successfully enabled
@Override
public void onConnectStatus(Context context, boolean enable){
if(enable){
// Successfully enabled push
}
}
turnOffPush
- It is generally used to turn off push
- After closing push notification switch, calling init will not open push
- Repeated calls will only take effect once
- If there is no problem with the environment,onConnectStatus will call back the results
- Currently supported channels::Engagelab/Huawei/Xiaomi/Meizu/oppo/vivo
/**
* Turn off push, and the persistent storage switch status is false. The default is true
*
* @param context not empty
*/
public static void turnOffPush(Context context)
The code example is as follows:
// Turn off push. You need to call turnOnPush again to turn on push
MTPushPrivatesApi.turnOffPush(context);
// After inheriting MTCommonReceiver, copy the onConnectStatus method to obtain the long connection status. If enable is false, it indicates that it has been closed successfully
@Override
public void onConnectStatus(Context context, boolean enable){
if(!enable){
// Successfully closed push
}
}
setNotificationShowTime
- init first, or the call will fail
- Currently supported channels:Engagelab/Google channel when the application is in the foreground (displayed by Engagelab)
/**
* Set the display time of the notice. It is displayed at any time by default
*
* @param context not empty
* @param beginHour Allow notification of the start time of the display (24-hour format, ranging from 0 to 23)
* @param endHour It is allowed to notify the end time of display (24-hour format, ranging from 0 to 23). beginHour cannot be greater than or equal to endHour
* @param weekDays An array of days (7-day system, ranging from 1 to 7) that allows notifications to be displayed. An empty array means that notifications will not be displayed at any time
*/
public static void setNotificationShowTime(Context context, int beginHour, int endHour, int... weekDays)
The code example is as follows:
// Set the display time of the notice to be 9:00 a.m. to 9:00 p.m. on 1/3/5/7 every week
MTPushPrivatesApi.setNotificationShowTime(context, 9, 21, 1,3,5,7);
resetNotificationShowTime
- init first, or the call will fail
- Currently supported channels:Engagelab/Google channel when the application is in the foreground (displayed by Engagelab)
/**
* Reset the display time of the notice, and display at any time by default
*
* @param context not empty
*/
public static void resetNotificationShowTime(Context context)
The code example is as follows:
// Reset the display time of the notice, and display at any time by default
MTPushPrivatesApi.resetNotificationShowTime(context);
setNotificationSilenceTime
- init first, or the call will fail
- Currently supported channels:Engagelab/Google channel when the application is in the foreground (displayed by Engagelab)
/**
* Set the notification silence time. By default, no silence occurs at any time
*
* @param context not empty
* @param beginHour The start time of the allowed notification silence, in hours (24-hour format, ranging from 0 to 23)
* @param beginMinute The start time of the allowed notification silence, in minutes (60 minute format, ranging from 0 to 59)
* @param endHour The end time of the allowed notification silence, in hours (24-hour format, ranging from 0 to 23)
* @param endMinute The end time allowed for notification silence, in minutes (60 minute format, ranging from 0 to 59)
*/
public static void setNotificationSilenceTime(Context context, int beginHour, int beginMinute, int endHour, int endMinute)
The code example is as follows:
// Set the notification silence time from 9:30 p.m. to 9:30 a.m
MTPushPrivatesApi.setNotificationSilenceTime(context, 21, 30, 9, 30);
resetNotificationSilenceTime
- init first, or the call will fail
- Currently supported channels:Engagelab/Google channel when the application is in the foreground (displayed by Engagelab)
/**
* Reset the notification silence time. By default, no silence occurs at any time
*
* @param context not empty
*/
public static void resetNotificationSilenceTime(Context context)
The code example is as follows:
// Reset the notification silence time. By default, no silence occurs at any time
MTPushPrivatesApi.resetNotificationSilenceTime(context);
setNotificationLayout
- init first, or the call will fail
- Currently supported channels:Engagelab
/**
* Set the custom notification layout, and use the system notification layout by default
*
* @param context not empty
* @param builderId builder id
* @param notificationLayout Objects that customize the notification layout,not empty
*/
public static void setNotificationLayout(Context context, int builderId, NotificationLayout notificationLayout)
The code example is as follows:
// A constant is defined here, representing the build id
private static final int BUILDER_ID = 11;
// build notificationLayout
NotificationLayout notificationLayout = new NotificationLayout()
.setLayoutId(R.layout.custom_notification_layout) // layout_id
.setIconViewId(R.id.iv_notification_icon) // view_id
.setIconResourceId(R.drawable.mtpush_notification_icon) // source_id
.setTitleViewId(R.id.tv_notification_title) // view_id
.setContentViewId(R.id.tv_notification_content) // view_id
.setTimeViewId(R.id.tv_notification_time); // view_id
// Set the build id to BUILDER_ The custom layout of ID, and the builderId is specified as BUILDER when the notification is issued_ ID, you can change the notification layout
MTPushPrivatesApi.setNotificationLayout(this.getApplicationContext(), BUILDER_ID, notificationLayout);
resetNotificationLayout
- init first, or the call will fail
- Currently supported channels:Engagelab
/**
* Reset custom notification layout, default to system notification layout
*
* @param context not empty
* @param builderId ID of custom notification layout
*/
public static void resetNotificationLayout(Context context, int builderId)
The code example is as follows:
// A constant is defined here, representing the build id
private static final int BUILDER_ID = 11;
// Reset build id to BUILDER_ The custom layout of ID, and the builderId is specified as BUILDER when the notification is issued_ ID, the system default layout will be used
MTPushPrivatesApi.resetNotificationLayout(context,BUILDER_ID);
setNotificationCount
- init first, or the call will fail
- Currently supported channels:Engagelab/Google channel when the application is in the foreground (displayed by Engagelab))
/**
* Set the number of notifications in the notification bar. The default number is 5
*
* @param context not empty
* @param count Limit the number of notifications in the notification bar. If the number exceeds the limit, the oldest notification will be removed. It cannot be less than or equal to 0
*/
public static void setNotificationCount(Context context, int count)
The code example is as follows:
// Set the number of notifications in the notification bar to 50
MTPushPrivatesApi.setNotificationCount(context,50);
resetNotificationCount
- init first, or the call will fail
- Currently supported channels:Engagelab/Google channel when the application is in the foreground (displayed by Engagelab)
/**
* Reset the number of notifications in the notification bar. The default number is 5
*
* @param context not empty
*/
public static void resetNotificationCount(Context context)
The code example is as follows:
// Reset the number of notifications in the notification bar. The default number is 5
MTPushPrivatesApi.resetNotificationCount(context);
setNotificationBadge
- init first, or the call will fail
/**
* Set the number of application subscripts. The default is 0 (only effective for Huawei/Honour)
*
* @param context not empty
* @param badge Number of applied corner markers
*/
public static void setNotificationBadge(Context context, int badge)
The code example is as follows:
// Set the number of applied subscripts to 1
MTPushPrivatesApi.setNotificationBadge(context,1);
resetNotificationBadge
- init first, or the call will fail
/**
* Set the number of application subscripts. The default is 0 (only effective for Huawei/Honour)
*
* @param context not empty
*/
public static void resetNotificationBadge(Context context) {
The code example is as follows:
// Reset the number of applied subscripts. The default is 0
MTPushPrivatesApi.resetNotificationBadge(context);
showNotification
- init first, or the call will fail
/**
* Display notice
*
* @param context not empty
* @param notificationMessage Notification object built,not empty
*/
public static void showNotification(Context context, NotificationMessage notificationMessage)
The code example is as follows:
// Build a basic notification, where messageId and content are required, otherwise the notification cannot be displayed
NotificationMessage notificationMessage = new NotificationMessage()
.setMessageId("12345")
.setNotificationId(12345)
.setTitle("custom_notification_title")
.setContent("custom_notification_content");
// Display notice
MTPushPrivatesApi.showNotification(context,notificationMessage);
clearNotification
- init first, or the call will fail
/**
* Clear notification of the specified notifyId
*
* @param context not empty
* @param notifyId notice id
*/
public static void clearNotification(Context context, int notifyId)
The code example is as follows:
// Clear notification of the specified notifyId
MTPushPrivatesApi.clearNotification(context,12345);
reportNotificationArrived
- init first, or the call will fail
- The manufacturer package of Engagelab is not integrated, but you still need to use Engagelab to statistics the notification delivery rate. Please call this interface
/**
* Report the arrival of manufacturer channel notification
*
* Report via http/https
*
* @param context not empty
* @param messageId Engagelab message id,not empty
* @param platform platform,value(1:mi、2:huawei、3:meizu、4:oppo、5:vivo、8:google)
* @param platformMessageId platform id,can be empty
*/
public static void reportNotificationArrived(Context context, String messageId, byte platform, String platformMessageId)
The code example is as follows:
// Report the arrival of the manufacturer's notification, the messageId is "12345", the manufacturer is Xiaomi, and the manufacturer's messageId is "MI-6476RHT25"
MTPushPrivatesApi.reportNotificationArrived(context,“12345”,MTPushPrivatesApi.PLATFORM_XIAOMI,"MI-6476RHT25");
reportNotificationClicked
- init first, or the call will fail
- The manufacturer package of Engagelab is not integrated, but it needs to count the click rate of notification by Engagelab. Please call this interface
/**
* Submit the manufacturer channel notification and click
*
*Report via http/https
*
* @param context not empty
* @param messageId Engagelab message id,not empty
* @param platform platform,value(1:mi、2:huawei、3:meizu、4:oppo、5:vivo、8:google)
* @param platformMessageId platform message id,can be empty
*/
public static void reportNotificationClicked(Context context, String messageId, byte platform, String platformMessageId)
The code example is as follows:
// Click to report the manufacturer's notice. The messageId is "12345", the manufacturer is Xiaomi, and the manufacturer's messageId is "MI-6476RHT25"
MTPushPrivatesApi.reportNotificationClicked(context,“12345”,MTPushPrivatesApi.PLATFORM_XIAOMI,"MI-6476RHT25");
reportNotificationDeleted
- init first, or the call will fail
- The manufacturer package of Engagelab is not integrated, but Engagelab is required to calculate the deletion rate of notifications. Please call this interface
/**
* Report to manufacturer channel notification deletion
*
* Report via http/https
*
* @param context not empty
* @param messageId Engagelab message id,not empty
* @param platform platform,value(1:mi、2:huawei、3:meizu、4:oppo、5:vivo、8:google)
* @param platformMessageId platform message id,can be empty
*/
public static void reportNotificationDeleted(Context context, String messageId, byte platform, String platformMessageId)
The code example is as follows:
// Report the deletion of the vendor notification. The messageId is "12345", the vendor is mi, and the vendor messageId is "MI-6476RHT25"
MTPushPrivatesApi.reportNotificationDeleted(context,“12345”,MTPushPrivatesApi.PLATFORM_XIAOMI,"MI-6476RHT25");
reportNotificationOpened
- init first, or the call will fail.
- The manufacturer package of Engagelab is not integrated, but the opening rate of the notice needs to be calculated by Engagelab. Please call this interface.
- Some manufacturers (e.g. huawei/opo/vivo) do not notify arrival or click callback. After configuring the activity to notify click jump, you can obtain parameter reports in the jump activity. It is recommended that all manufacturers notify click jump activities to configure.
- Not required for MTPush4.0.0 or above.
/**
* Open the channel notification of the reported manufacturer
*
*Report via http/https
*
* @param context not empty
* @param messageId Engagelab message id,not empty
* @param platform platform,value(1:mi、2:huawei、3:meizu、4:oppo、5:vivo、8:google)
* @param platformMessageId platform message id,can be empty
*/
public static void reportNotificationOpened(Context context, String messageId, byte platform, String platformMessageId)
The code example is as follows:
Bundle bundle = intent.getExtras();
String platformMessage = "";
// huawei
if (intent.getData() != null) {
platformMessage = intent.getData().toString();
}
// Other Mobile manufacturers
if (TextUtils.isEmpty(platformMessage) && intent.getExtras() != null) {
if (MTGlobal.IS_FOR_JIGUANG) {
platformMessage = bundle.getString("JMessageExtra");
}else {
platformMessage = bundle.getString("MTMessageExtra");
}
}
if (TextUtils.isEmpty(platformMessage)) {
return;
}
JSONObject messageJson = new JSONObject(platformMessage);
tvMessage.setText(toLogString(messageJson));
// analysis
String messageId = messageJson.optString("msg_id");
byte platform = (byte) messageJson.optInt("rom_type");
String title = messageJson.optString("n_title");
String content = messageJson.optString("n_content");
// Click activity to open the report notification. We recommend that you add all vendor redirects. Only MTPush4.0.0 or later is required.
MTPushPrivatesApi.reportNotificationOpened(this, messageId, platform, "");
uploadPlatformToken
- init first, or the call will fail
- Due to tcp upload, this interface is called after the long connection succeeds, that is, [onConnectStatus] (#onconnectstatus) callback result is true
- The manufacturer package of Engagelab is not integrated, but the manufacturer message pushed by Engagelab is required
/**
* upload Manufacturer token
*
* upload via tcp
*
* @param context not empty
* @param platform mobile manufacturer,ranges from(1:mi、2:huawei、3:meizu、4:oppo、5:vivo、8:google)
* @param token token back from mobile manufacturer,not empty
* @param region Overseas versions of Xiaomi and oppo need to set the region, fill in such as "US" according to the region of use, etc., fill in null for non-overseas versions
*/
public static void uploadPlatformToken(Context context, byte platform, String token, String region)
The code example is as follows:
// Report the manufacturer token. The manufacturer is mi and the manufacturer token is “MI-6476s-afs-afs-afaR-HT25”
MTPushPrivatesApi.uploadPlatformToken(context,MTPushPrivatesApi.PLATFORM_XIAOMI,"MI-6476s-afs-afs-afaR-HT25","US");
code
code | int | Description |
---|---|---|
SUCCESS | 0 | Success |
TIMEOUT | 6002 | Configuration timeout. This usually occurs when the network is poor and initialization has not been completed. |
UNKNOWN_ERROR | 6009 | unknown error |
INVALID_JSON | 6010 | invalid json |
CONNECT_NOT_ENABLE | 6013 | CONNECT_NOT_ENABLE |
MTCommonReceiver
- Method callback
- All method callbacks in this class are in the main proces
onNotificationStatus
- The current notification switch status is called back after the sdk init
- Callback is triggered only when the notification switch changes
/**
* Application notification switch status callback
*
* @param context not empty
* @param enable Is the notification switch on? true means yes,false means no
*/
@Override
public void onNotificationStatus(Context context, boolean enable)
onConnectStatus
/**
* persistent connection success
*
* After initialization, the connection is initiated. If the connection succeeds or fails, a callback is returned.
*
* @param context not empty
* @param enable Is the persistent connection successful? true means yes,false means no
*/
public void onConnectStatus(Context context, boolean enable)
onNotificationArrived
- Engagelab/Xiaomi/Meizu support (google channel needs app running in front)
- See NotificationMessage for notificationMessage
/**
* Notification message delivery
*
* This method is called back when a pushed notification message is delivered
*
* @param context not empty
* @param notificationMessage Notification message
*/
public void onNotificationArrived(Context context, NotificationMessage notificationMessage)
onNotificationClicked
- Engagelab/Xiaomi/Meizu support (google channel needs app running in front).
- See NotificationMessage for notificationMessage.
/**
* Notification message click
*
* This method is called back when a pushed notification message is clicked
*
* @param context not empty
* @param notificationMessage Notification message
*/
public void onNotificationClicked(Context context, NotificationMessage notificationMessage)
onNotificationDeleted
- Only when the notification message of the Engagelab channel is deleted.
- See NotificationMessage for notificationMessage.
- The application cannot be called back when the application is not active.
/**
* Notification message deletion
*
* This method is called back when the pushed notification message is deleted
*
* @param context not empty
* @param notificationMessage Notification message
*/
public void onNotificationDeleted(Context context, NotificationMessage notificationMessage)
onCustomMessage
- Custom messages are not displayed in the notification bar.
- Only when the notification message of the Engagelab channel is deleted.
- See CustomMessage for customMessage.
/**
* Custom message delivery
*
* This method is called back when a custom message is sent
*
* @param context not empty
* @param customMessage Custom message
*/
public void onCustomMessage(Context context, CustomMessage customMessage)
onPlatformToken
- After the manufacturer channel is correctly integrated, this callback occurs after the persistent connection is successful.
- See PlatformTokenMessage for onPlatformToken
/**
* Manufacturer operation message
*
* @param context ApplicationContext Object
* @param platformTokenMessage manufacturer token message
*/
public void onPlatformToken(Context context, PlatformTokenMessage platformMessage)
NotificationMessage
- Notification message
Attribute | Type | Description |
---|---|---|
messageId | String | required,EngagelabmessageId,Used for message tracking and statistics. Not empty. If it is empty, no notification will be displayed |
overrideMessageId | String | EngagelaboverrideMessageId,for Message Tracking and statistics |
platform | byte | Manufacturer TypeMTPushPrivatesApi.PLATFORM_DEFAULT :0MTPushPrivatesApi.PLATFORM_XIAOMI :1MTPushPrivatesApi.PLATFORM_HUAWEI :2MTPushPrivatesApi.PLATFORM_MEIZU :3MTPushPrivatesApi.PLATFORM_OPPO :4MTPushPrivatesApi.PLATFORM_VIVO :5MTPushPrivatesApi.PLATFORM_GOOGLE :8 |
platformMessageId | String | Manufacturer messageId,for manufacturer message tracking and statistics |
notificationId | int | Notification id. Call clearNotification to cancel |
smallIcon | String | small icon,use drawable/mtpush_notification_icon.png by default |
largeIcon | String | large icon,Generally, it is on the right side of the notification |
title | String | The notification Title. If empty, the application name is used. |
content | String | Required,notification content,not empty. If empty, no notification is displayed. |
extras | Bundle | Additional fields, key/value format is String |
builderId | int | The id of the notification style. Call the setNotificationLayout to set the notification style. The system style is used by default |
style | int | The notification style.Default value: 0. |
bigText | String | Large Text. The style parameter is NOTIFICATION_STYLE_BIG_TEXT |
inbox | String[] | Inbox. The style is NOTIFICATION_STYLE_INBOX |
bigPicture | String | Large image. The style is NOTIFICATION_STYLE_BIG_PICTURE |
priority | int | The urgency of the Notification. The default value is 0. |
defaults | int | Notifications are used for ringtones, vibration, and LED lights. The default value is Notification.DEFAULT_ALL:-1 ringtone, Notification.DEFAULT_SOUND:1 vibration, Notification.DEFAULT_VIBRATE:2led, Notification.DEFAULT_LIGHTS:4 three scenes can be freely combined. For example, when it is 7, it indicates that the ring, vibration, and LED lights all have Android8.0. This attribute follows the channel. |
category | String | The Notification type, which is used to sort or filter the Notification bar. A wide range of Notification types are available, such as Notification.CATEGORY_ALARM and Notification#CATEGORY_CALL |
sound | String | The ringtone attached to the notification. The ringtone file Android8.0 must be stored in the res/raw directory in advance. The ringtone follows the channel. If the ringtone is not set in the channel used by the notification, this notification does not take effect on the custom ringtone. We recommend that you set the ringtone in the channel in advance. When the notification is sent later, the sound is consistent with the ringtone in the channelId. |
channelId | String | It is required from Android8.0. If you do not set the sdk in advance, the sdk will help you set it up (only the Engagelab channel and the google channel when the application is in front desk). |
intentUri | String | Click the redirection after the notification. Currently, only activity is supported. activity redirection is obtained by usingIntent.toURI() |
badge | int | The number of corner labels added to this notification belongs to the accumulation logic. The value must be greater than 0. Otherwise, it is invalid. We recommend that you enter 1. Only Huawei and Xiaomi take effect. After Xiaomi clicks the notification, the number of corner labels will be automatically reduced by 1. After Huawei clicks the notification, the number of corner labels will not be automatically reduced by 1. We recommend that you call setNotificationBadge to set |
CustomMessage
- Custom message
Attribute | Type | Description |
---|---|---|
messageId | String | Required, EngagelabmessageId, used for Message Tracking and statistics,not empty |
platform | byte | Manufacturer type. MTPushPrivatesApi.PLATFORM_DEFAULT :0 MTPushPrivatesApi.PLATFORM_XIAOMI :1 MTPushPrivatesApi.PLATFORM_HUAWEI :2 MTPushPrivatesApi.PLATFORM_MEIZU :3 MTPushPrivatesApi.PLATFORM_OPPO :4 MTPushPrivatesApi.PLATFORM_VIVO :5 MTPushPrivatesApi.PLATFORM_GOOGLE :8 |
platformMessageId | String | Manufacturer messageId,Used for vendor message tracking and statistics |
title | String | Message title |
content | String | Message content |
contentType | String | Message type |
extras | Bundle | Extra field,key/value format is String |
PlatformTokenMessage
- platform token
Attribute | Type | Description |
---|---|---|
platform | byte | Type MTPushPrivatesApi.PLATFORM_DEFAULT :0MTPushPrivatesApi.PLATFORM_XIAOMI :1 MTPushPrivatesApi.PLATFORM_HUAWEI :2 MTPushPrivatesApi.PLATFORM_MEIZU :3 MTPushPrivatesApi.PLATFORM_OPPO :4 MTPushPrivatesApi.PLATFORM_VIVO :5 MTPushPrivatesApi.PLATFORM_GOOGLE :8 |
token | String | returned token |