启动页 推送
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// 简单的使用示例
|
||||
'use strict';
|
||||
const uniPush = uniCloud.getPushManager({
|
||||
appId: "__UNI__89F511F"
|
||||
})
|
||||
exports.main = async (event) => {
|
||||
let obj = JSON.parse(event.body)
|
||||
const res = await uniPush.sendMessage({
|
||||
"push_clientid": obj.cids, // 设备id,支持多个以数组的形式指定多个设备,如["cid-1","cid-2"],数组长度不大于1000
|
||||
"title": obj.title, // 标题
|
||||
"content": obj.content, // 内容
|
||||
"settings": obj.settings, // 消息有效期
|
||||
"payload": obj.payload, // 数据
|
||||
"category": obj.category, // HarmonyOS NEXT系统(纯血鸿蒙、非安卓鸿蒙)的消息分类,要给鸿蒙设备推送时才必传
|
||||
"force_notification": true, //填写true,客户端就会对在线消息自动创建“通知栏消息”,不填写则需要客户端自己处理。
|
||||
"request_id": obj.request_id ,//请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
|
||||
"options":obj.options //消息分类,没申请可以不传这个参数
|
||||
})
|
||||
return res;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "commentPush",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// 简单的使用示例
|
||||
'use strict';
|
||||
const uniPush = uniCloud.getPushManager({appId:"__UNI__89F511F"}) //注意这里需要传入你的应用appId
|
||||
exports.main = async (event, context) => {
|
||||
return await uniPush.sendMessage({
|
||||
"push_clientid": "a297ac02dc531b7d43ff539f3163efcb", //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid
|
||||
"force_notification":true, //填写true,客户端就会对在线消息自动创建“通知栏消息”。
|
||||
"title": "通知栏显示的标题",
|
||||
"content": "通知栏显示的内容",
|
||||
"settings": {
|
||||
//消息有效期设置,单位毫秒,-1表示不设离线。默认是 2 小时,取值范围:-1 ~ 3 * 24 * 3600 * 1000(3天)之间
|
||||
"ttl":86400000
|
||||
},
|
||||
"payload": {
|
||||
"text":"体验一下uni-push2.0"
|
||||
},
|
||||
"category": {
|
||||
//HarmonyOS NEXT系统(纯血鸿蒙、非安卓鸿蒙)的消息分类,要给鸿蒙设备推送时才必传
|
||||
"harmony":"MARKETING"
|
||||
},
|
||||
"options":{
|
||||
"HW": {
|
||||
// 值为int 类型。1 表示华为测试消息,华为每个应用每日可发送该测试消息500条。此 target_user_type 参数请勿发布至线上。
|
||||
"/message/android/target_user_type":1
|
||||
} ,
|
||||
"HO": {
|
||||
//值为int 类型。1 表示测试推送,不填默认为0。荣耀每个应用每日可发送该测试消息1000条。此测试参数请勿发布至线上。
|
||||
"/android/targetUserType": 1
|
||||
} ,
|
||||
"VV": {
|
||||
//值为int 类型。0 表示正式推送;1 表示测试推送,不填默认为0。此 pushMode 参数请勿发布至线上。
|
||||
"/pushMode":1
|
||||
} ,
|
||||
"XM": {
|
||||
//新小米消息分类下,私信公信id都必须要传,否则请求小米厂商接口会被拦截
|
||||
"/extra.channel_id": "填写小米平台申请的渠道id"
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "testPush2",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-push": {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user