感谢论坛版主 马浩川 的分享。
模块介绍:
阿里移动推送(Alibaba Cloud Mobile Push)是基于大数据的移动智能推送服务,帮助App快速集成移动推送的功能,在实现高效、精确、实时的移动推送的同时,极大地降低了开发成本。让开发者最有效地与用户保持连接,从而提高用户活跃度、提高应用的留存率。
EMAS操作图示:
创建 , 在这里获取配置项的值
配置ios推送证书:
开发环境下需要填写单个设备id
消息通知: 需要打开消息监听addMessageListener
记录:
Hello APP
var acmPush;
apiready = function() {
acmPush = api.require('acmPush');
};
function getDeviceId() {
acmPush.getDeviceId({}, function(ret, err) {
console.log(JSON.stringify(ret));
});
}
function addMessageListener() {
acmPush.addMessageListener({
listenerName: 'name',
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function onAppStart() {
acmPush.onAppStart({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function turnOnPushChannel() {
acmPush.turnOnPushChannel({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function turnOffPushChannel() {
acmPush.turnOffPushChannel({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function checkPushChannelStatus() {
acmPush.checkPushChannelStatus({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function bindTag() {
acmPush.bindTag({
target: 1,
tags: ["Google", "Runoob", "Taobao"],
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function listTags() {
acmPush.listTags({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function addAlias() {
acmPush.addAlias({
alias: '别名1',
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function setNotificationSound() {
acmPush.setNotificationSound({
soundPath: 'widget://res/sound.mp3',
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function setNotificationLargeIcon() {
acmPush.setNotificationLargeIcon({
iconPath: 'widget://res/QQ.png',
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function setDoNotDisturb() {
acmPush.setDoNotDisturb({
startHour: 0,
startMinute: 02,
endHour: 1,
endMinute: 02
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function closeDoNotDisturbMode() {
acmPush.closeDoNotDisturbMode({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function clearNotifications() {
acmPush.clearNotifications({}, function(ret, err) {
alert(JSON.stringify(ret));
});
}
function syncBadgeNum() {
acmPush.syncBadgeNum({
num: 1,
}, function(ret, err) {
alert(JSON.stringify(ret));
});
}