ทดสอบการแจ้งเตือนข้อความ
ส่งข้อความแจ้งเตือนในเบื้องหลัง
การแจกจ่ายคอลเลกชัน: ดาวน์โหลด PostMan บนคอมพิวเตอร์ จากนั้นนำเข้าลิงก์ในมุมซ้ายบนของซอฟต์แวร์: https://www.getpostman.com/collections/618d2460851f697dc22c
รูปแบบการแจ้งเตือนมีดังนี้:
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
}
}
}
}'
โค้ดนี้โชว์เป็นหน้าต่างลอย
คำอธิบายพารามิเตอร์
คุณสมบัติ | ช่องทางที่รองรับ | ประเภท | ความหมาย |
---|---|---|---|
title | all | String | เลือกได้, หัวข้อ |
alert | all | String | จำเป็น, เนื้อหา |
builder_id | เฉพาะ Engagelab | int | เลือกได้, ID รูปแบบที่กำหนดเอง, โดยค่าเริ่มต้นจะใช้รูปแบบระบบ |
category | เฉพาะ Engagelab | String | |
large_icon | เฉพาะ Engagelab | String | เลือกได้, ไอคอนขนาดใหญ่, โดยปกติจะอยู่ทางด้านขวาของการแจ้งเตือน |
extras | all | JsonObject | เลือกได้, ฟิลด์เพิ่มเติม, รูปแบบ key/value เป็น String |
priority | เฉพาะ Engagelab | int | เลือกได้, ระดับความสำคัญของการแจ้งเตือน, ค่าเริ่มต้น: 0 |
alert_type | เฉพาะ Engagelab | int | เลือกได้, การแจ้งเตือนสำหรับเสียง, การสั่น และไฟ LED, ค่าเริ่มต้นคือ Notification.DEFAULT_ALL:-1 เสียง, Notification.DEFAULT_SOUND:1 การสั่น, Notification.DEFAULT_VIBRATE:2 ไฟ LED, Notification.DEFAULT_LIGHTS:4 สามารถรวมกันได้อย่างอิสระ เช่น เมื่อค่าคือ 7 หมายถึงมีเสียง, การสั่น และไฟ LED |
sound | Engagelab/google/xiaomi | String | |
channel_id | Engagelab/google/huawei/xiaomi /oppo | String | เลือกได้, ตั้งแต่ Android8.0 เป็นต้นไปจำเป็นต้องกรอก หาก sdk ไม่ได้ตั้งค่าล่วงหน้า, จะช่วยคุณตั้งค่า (ใช้เฉพาะเมื่อแอปอยู่ในเบื้องหน้าในช่องทาง Engagelab และ google) |
badge_add_num | Engagelab/huawei/xiaomi | int | เลือกได้, เพิ่มจำนวนมุมแอป, ตรรกะการสะสม |
badge_class | Engagelab/huawei/xiaomi | String | เลือกได้, MainActivity ของแอปที่แสดงมุม |
style | เฉพาะ Engagelab | int | เลือกได้, การแจ้งเตือนสำหรับเสียง, การสั่น และไฟ LED, สามารถรวมกันได้อย่างอิสระ Android 8.0, คุณสมบัตินี้เป็นไปตาม channel เช่น หากค่าคือ 7 หมายถึงมีเสียง, การสั่น และไฟ LED ค่าเริ่มต้นคือ Notification.DEFAULT_ALL:-1 |
big_text | เฉพาะ Engagelab | String | เลือกได้, ข้อความขนาดใหญ่, รูปแบบคือ NOTIFICATION_STYLE_BIG_TEXT |
inbox | เฉพาะ Engagelab | JsonObject | เลือกได้, กล่องจดหมาย, รูปแบบคือ NOTIFICATION_STYLE_INBOX |
big_pic_path | เฉพาะ Engagelab | String | เลือกได้, รูปภาพขนาดใหญ่, รูปแบบคือ NOTIFICATION_STYLE_BIG_PICTURE |
Intent:url | all | String | เลือกได้, มีผลตั้งแต่ MTPush4.0.0, คลิกการแจ้งเตือน (Engagelab + ผู้ผลิตทั้งหมด) เพื่อไปยังลิงก์ ปัจจุบันรองรับเฉพาะ activity Intent.toURI() แปลง |
ตัวอย่างโค้ดการกำหนดค่า activity บน Android client:
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;
/**
* ใช้สำหรับการสาธิต - คลิกการแจ้งเตือนเพื่อไปยัง activity
*
* ตรวจสอบให้แน่ใจว่าไม่ได้เรียกใช้ {@link MTPushPrivatesApi#configOldPushVersion(Context)} มิฉะนั้นคลิก "ไปยัง" การแจ้งเตือนจะไม่ไปยังหน้านี้
* <p>
* ไม่จำเป็นต้องเรียกใช้ {@link MTPushPrivatesApi#reportNotificationOpened(Context, String, byte, String)} SDK ได้จัดการภายในแล้ว
*/
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;
/**
* ใช้สำหรับการสาธิต - คลิกการแจ้งเตือนเพื่อไปยัง activity
*
* ตรวจสอบให้แน่ใจว่าไม่ได้เรียกใช้ {@link MTPushPrivatesApi#configOldPushVersion(Context)} มิฉะนั้นคลิก "ไปยัง" การแจ้งเตือนจะไม่ไปยังหน้านี้
* <p>
* ไม่จำเป็นต้องเรียกใช้ {@link MTPushPrivatesApi#reportNotificationOpened(Context, String, byte, String)} SDK ได้จัดการภายในแล้ว
*/
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();
}
}
}
โค้ดนี้โชว์เป็นหน้าต่างลอย
<!-- การแจ้งเตือนคลิกเพื่อไปยังการสาธิตและเวอร์ชันถัดไป -->
<activity
android:name="com.engagelab.app.component.UserActivity400"
android:exported="false"
android:launchMode="singleTask" />
<!--การตรวจสอบรายการขาวในท้องถิ่น: ตั้งแต่ MTPush4.2.3 เป็นต้นไป, การกำหนดค่า ENGAGELAB_ PRIVATES_ TRANSFER SDK จะทำการตรวจสอบในท้องถิ่น; หากไม่ได้กำหนดค่าจะไม่ทำการตรวจสอบในท้องถิ่น หากเปิดใช้งานการตรวจสอบในท้องถิ่น, ต้องกำหนดค่ากิจกรรมเป้าหมาย; หากมีกิจกรรมเป้าหมายหลายรายการ, ใช้ / แยก-->
<meta-data
android:name="ENGAGELAB_PRIVATES_TRANSFER"
android:value="com.engagelab.app.component.UserActivity400" />
<!-- การแจ้งเตือนคลิกเพื่อไปยังการสาธิตและเวอร์ชันถัดไป -->
<activity
android:name="com.engagelab.app.component.UserActivity400"
android:exported="false"
android:launchMode="singleTask" />
<!--การตรวจสอบรายการขาวในท้องถิ่น: ตั้งแต่ MTPush4.2.3 เป็นต้นไป, การกำหนดค่า ENGAGELAB_ PRIVATES_ TRANSFER SDK จะทำการตรวจสอบในท้องถิ่น; หากไม่ได้กำหนดค่าจะไม่ทำการตรวจสอบในท้องถิ่น หากเปิดใช้งานการตรวจสอบในท้องถิ่น, ต้องกำหนดค่ากิจกรรมเป้าหมาย; หากมีกิจกรรมเป้าหมายหลายรายการ, ใช้ / แยก-->
<meta-data
android:name="ENGAGELAB_PRIVATES_TRANSFER"
android:value="com.engagelab.app.component.UserActivity400" />
โค้ดนี้โชว์เป็นหน้าต่างลอย