陌上人如玉
公子世无双

unipush 云函数 消息推送配置

// index.obj.js

const uniPush = uniCloud.getPushManager({
    appId: "__UNI__D940142"
});
module.exports = {
    async Alarm(params) {
        if (!params.title || !params.content) {
            return {
                errCode: 'INVALID_TODO',
                errMsg: 'TODO标题或内容不可为空'
            }
        }
        await uniPush.sendMessage({
                "push_clientid": params.cid, 
                "title": params.title,
                "content": params.content,
                "payload": params.payload,
                "force_notification":true, 
                "options": {
                    "HW": {
                        "/message/android/notification/importance":"NORMAL",
                        "/message/android/category":"WORK",
                        "/message/android/target_user_type":1 
                    },
                    "HO": {
                        "/android/notification/badge/badgeClass": "/pages/login/login",
                        "/android/ttl": "86400s",
                        "/android/notification/importance": "NORMAL",
                         "/android/targetUserType": 1  
                    },
                    "XM": {
                        "/extra.channel_id": "122248",
                        "/time_to_live": 86400000
                    },
                    "OP": {
                        "/channel_id": "Default",
                        "/off_line": true,
                        "/off_line_ttl": 86400
                    },
                    "VV": {
                        "/category": "TODO",
                        "/classification": 1,
                        "/timeToLive": 86400
                    }
                }
            });
        return {
            errCode: 0,
            errMsg: '创建成功'
        }
    }
}
赞(0) 打赏
未经允许不得转载:陌上寒 » unipush 云函数 消息推送配置

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

微信扫一扫

支付宝扫一扫