Quick test notification message
Enviar mensaje de notificación en segundo plano
Colección de distribución: descargar Postman en el ordenador y, a continuación, importar el enlace en la esquina superior izquierda del software: https://www.getpostman.com/collections/618d2460851f697dc22c
El formato de la notificación es el siguiente:
curl --location --request POST 'http://pricloud-master-api.glqas.mtpushoa.com/v3/push' \
--header 'Authorization: Basic MWM0Yjc0OWExN2Y2YWNhMzM5NjBhNTYwOjQ5ZjlkODI2MDExMmI0YmVlMDVhMzQzOA==' \
--header 'Content-Type: application/json' \
--data-raw
'{
"platform": "android",
"audience": {
"registration_id": [
"1104a89792bbb659ec5"
]
},
"notification": {
"android": {
"title": "notification title",
"alert": "notification content",
"builder_id": 0,
"category": "alarm",
"small_icon": "mtpush_notification_icon",
"large_icon": "mtpush_notification_icon",
"extras": {
"notification key": "notification value"
},
"priority": 1,
"alert_type": 7,
"sound": "coin",
"channel_id": "money",
"badge_add_num": 1,
"badge_class": "com.engagelab.app.activity.MainActivity",
"style": 2,
"big_text": "Farewell to Cambridge is a popular poem of modern poet Xu Zhimo and a representative work of the New Moon School. The whole poem takes the emotional ups and downs when leaving Cambridge as a clue to express the deep feelings for leaving Cambridge. The language is light and soft, and the form is exquisite and mellow. The poet uses the method of combining the virtual and the real to describe the flowing pictures, which constitute a beautiful artistic conception everywhere. The poet's love for Cambridge, his nostalgia for the past life, and his helpless sorrow for parting in front of him are expressed in detail in a sincere, rich and meaningful way, which is the last song in Xu Zhimo's poems.",
"inbox": {
"inbox1": "this is inbox one",
"inbox2": "this is inbox two",
"inbox3": "this is inbox three"
},
"big_pic_path": "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=96071541,1913562332&fm=26&gp=0.jpg",
"intent": {
"url": "intent:#Intent;component=com.engagelab.oaapp/com.engagelab.app.component.UserActivity400;end"
}
}
},
"options": {
"third_party_channel": {
"vivo": {
"classification": 1,
"pushMode": 1
}
}
}
}'
curl --location --request POST 'http://pricloud-master-api.glqas.mtpushoa.com/v3/push' \
--header 'Authorization: Basic MWM0Yjc0OWExN2Y2YWNhMzM5NjBhNTYwOjQ5ZjlkODI2MDExMmI0YmVlMDVhMzQzOA==' \
--header 'Content-Type: application/json' \
--data-raw
'{
"platform": "android",
"audience": {
"registration_id": [
"1104a89792bbb659ec5"
]
},
"notification": {
"android": {
"title": "notification title",
"alert": "notification content",
"builder_id": 0,
"category": "alarm",
"small_icon": "mtpush_notification_icon",
"large_icon": "mtpush_notification_icon",
"extras": {
"notification key": "notification value"
},
"priority": 1,
"alert_type": 7,
"sound": "coin",
"channel_id": "money",
"badge_add_num": 1,
"badge_class": "com.engagelab.app.activity.MainActivity",
"style": 2,
"big_text": "Farewell to Cambridge is a popular poem of modern poet Xu Zhimo and a representative work of the New Moon School. The whole poem takes the emotional ups and downs when leaving Cambridge as a clue to express the deep feelings for leaving Cambridge. The language is light and soft, and the form is exquisite and mellow. The poet uses the method of combining the virtual and the real to describe the flowing pictures, which constitute a beautiful artistic conception everywhere. The poet's love for Cambridge, his nostalgia for the past life, and his helpless sorrow for parting in front of him are expressed in detail in a sincere, rich and meaningful way, which is the last song in Xu Zhimo's poems.",
"inbox": {
"inbox1": "this is inbox one",
"inbox2": "this is inbox two",
"inbox3": "this is inbox three"
},
"big_pic_path": "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=96071541,1913562332&fm=26&gp=0.jpg",
"intent": {
"url": "intent:#Intent;component=com.engagelab.oaapp/com.engagelab.app.component.UserActivity400;end"
}
}
},
"options": {
"third_party_channel": {
"vivo": {
"classification": 1,
"pushMode": 1
}
}
}
}'
Este bloque de código se muestra en una ventana flotante
Descripción de parámetros
| Propiedades | Canales compatibles | Tipo | Significado |
|---|---|---|---|
| title | todos | String | opcional, título |
| alert | todos | String | obligatorio, contenido |
| builder_id | solo Engagelab | int | opcional. ID del estilo personalizado. De forma predeterminada se utiliza el estilo del sistema. |
| category | solo Engagelab | String | |
| large_icon | solo Engagelab | String | opcional. Icono grande. Por lo general, se muestra en el lado derecho de la notificación. |
| extras | todos | JsonObject | opcional. Campos adicionales. El formato clave/valor es String. |
| priority | solo Engagelab | int | opcional. Urgencia de la notificación. Valor predeterminado: 0. |
| alert_type | solo Engagelab | int | opcional. Las notificaciones se utilizan para tonos, vibración y luces LED. El valor predeterminado es Notification.DEFAULT_ALL:-1. Tono, Notification.DEFAULT_SOUND:1 Vibración, Notification.DEFAULT_VIBRATE:2 Luces LED, Notification.DEFAULT_LIGHTS:4. Estas tres opciones se pueden combinar libremente. Por ejemplo, si es 7, significa que hay tonos, vibración y luces LED. |
| sound | Engagelab/google/xiaomi | String | |
| channel_id | Engagelab/google/huawei/xiaomi /oppo | String | opcional. Es obligatorio a partir de Android 8.0. Si el SDK no se configura previamente, se configurará automáticamente (solo canales Engagelab y canales Google cuando la aplicación está en primer plano). |
| badge_add_num | Engagelab/huawei/xiaomi | int | opcional. Incrementa el número de insignias (badge) en el icono de la aplicación y aplica lógica de acumulación. |
| badge_class | Engagelab/huawei/xiaomi | String | opcional. La MainActivity de la aplicación se utiliza para la visualización del badge. |
| style | solo Engagelab | int | opcional. Las notificaciones se utilizan para tonos, vibración y luces LED. Estas tres opciones se pueden combinar libremente. En Android 8.0, este atributo sigue al canal. Por ejemplo, si es 7, indica que hay tonos, vibración y luces LED. El valor predeterminado es Notification.DEFAULT_ALL:-1. |
| big_text | solo Engagelab | String | opcional. Texto largo. El estilo es NOTIFICATION_STYLE_BIG_TEXT. |
| inbox | solo Engagelab | JsonObject | opcional. Bandeja de entrada. El estilo es NOTIFICATION_STYLE_INBOX. |
| big_pic_path | solo Engagelab | String | opcional. Imagen grande. El estilo es NOTIFICATION_STYLE_BIG_PICTURE. |
| Intent:url | todos | String | opcional. Disponible a partir de MTPush 4.0.0. Al hacer clic en la notificación (Engagelab + todos los proveedores) se realiza la redirección. Actualmente, solo se admite activity. Convertido mediante Intent.toURI() |
Código de ejemplo para configurar Activity en el cliente Android:
package com.engagelab.app.component;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.engagelab.app.R;
import com.engagelab.app.log.ExampleLogger;
import com.engagelab.privates.push.api.MTPushPrivatesApi;
import com.engagelab.privates.push.api.NotificationMessage;
import com.engagelab.privates.push.constants.MTPushConstants;
/**
* Used to demonstrate - click the notification to jump to the activity
*
* Make sure there is no call{@link MTPushPrivatesApi#configOldPushVersion(Context)},Otherwise, click "Jump" and the notice will not jump to this page
* <p>
* no need to call {@link MTPushPrivatesApi#reportNotificationOpened(Context, String, byte, String)},The sdk has been processed internally
*/
public class UserActivity400 extends Activity {
private static final String TAG = "UserActivity400";
private TextView tvMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intent);
tvMessage = findViewById(R.id.tv_message);
onIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
onIntent(intent);
}
private void onIntent(Intent intent) {
try {
Toast.makeText(this, TAG, Toast.LENGTH_SHORT).show();
if (intent == null) {
return;
}
Bundle bundle = intent.getExtras();
NotificationMessage notificationMessage = bundle.getParcelable("message");
if (notificationMessage == null) {
return;
}
ExampleLogger.d(TAG, "notificationMessage:" + notificationMessage.toString());
tvMessage.setText(notificationMessage.toString());
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
package com.engagelab.app.component;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.engagelab.app.R;
import com.engagelab.app.log.ExampleLogger;
import com.engagelab.privates.push.api.MTPushPrivatesApi;
import com.engagelab.privates.push.api.NotificationMessage;
import com.engagelab.privates.push.constants.MTPushConstants;
/**
* Used to demonstrate - click the notification to jump to the activity
*
* Make sure there is no call{@link MTPushPrivatesApi#configOldPushVersion(Context)},Otherwise, click "Jump" and the notice will not jump to this page
* <p>
* no need to call {@link MTPushPrivatesApi#reportNotificationOpened(Context, String, byte, String)},The sdk has been processed internally
*/
public class UserActivity400 extends Activity {
private static final String TAG = "UserActivity400";
private TextView tvMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intent);
tvMessage = findViewById(R.id.tv_message);
onIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
onIntent(intent);
}
private void onIntent(Intent intent) {
try {
Toast.makeText(this, TAG, Toast.LENGTH_SHORT).show();
if (intent == null) {
return;
}
Bundle bundle = intent.getExtras();
NotificationMessage notificationMessage = bundle.getParcelable("message");
if (notificationMessage == null) {
return;
}
ExampleLogger.d(TAG, "notificationMessage:" + notificationMessage.toString());
tvMessage.setText(notificationMessage.toString());
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
Este bloque de código se muestra en una ventana flotante
<!-- Click to jump to the notification for demonstrating and later versions -->
<activity
android:name="com.engagelab.app.component.UserActivity400"
android:exported="false"
android:launchMode="singleTask" />
<!--Local transit verification of white list: Start from MTPush4.2.3 and configure ENGAGELAB_ PRIVATES_ After TRANSFER, the SDK will perform local verification; No local authentication is performed without configuration. If local verification is enabled, configure the target activity to jump here; If there are multiple target activities, use/to separate them.-->
<meta-data
android:name="ENGAGELAB_PRIVATES_TRANSFER"
android:value="com.engagelab.app.component.UserActivity400" />
<!-- Click to jump to the notification for demonstrating and later versions -->
<activity
android:name="com.engagelab.app.component.UserActivity400"
android:exported="false"
android:launchMode="singleTask" />
<!--Local transit verification of white list: Start from MTPush4.2.3 and configure ENGAGELAB_ PRIVATES_ After TRANSFER, the SDK will perform local verification; No local authentication is performed without configuration. If local verification is enabled, configure the target activity to jump here; If there are multiple target activities, use/to separate them.-->
<meta-data
android:name="ENGAGELAB_PRIVATES_TRANSFER"
android:value="com.engagelab.app.component.UserActivity400" />
Este bloque de código se muestra en una ventana flotante
