export default {
onLaunch: function () {
// #ifdef APP-PLUS
// 锁定屏幕方向
plus.screen.lockOrientation('portrait-primary'); //锁定
//获取版本信息
this.getVersion();
/* 5+ push 消息推送 ps:使用:H5+的方式监听,实现推送*/
plus.push.addEventListener("click", function(msg) {
uni.showModal({
showCancel:false,
title: msg.title,
content: msg.content,
});
}, false);
//监听在线消息事件
plus.push.addEventListener("receive", function(msg) {
uni.showModal({
showCancel:false,
content: msg.aps
});
}, false);
// #endif
},
methods:{
openPush:function(){ //开启个推
uni.getProvider({
service: 'push',
success: function (res) {
console.log(res.provider)
// 个推的名称为 igexin
if (~res.provider.indexOf('igexin')) {
uni.subscribePush({
provider: 'igexin',
success: function (res) {
console.log('success:' + JSON.stringify(res));
}
});
}
}
});
},
onPush:function(){
uni.onPush({
provider: 'igexin',
success: function () {
console.log('监听透传成功');
},
callback: function (data) {
console.log("接收到透传数据:" + JSON.stringify(data));
}
});
}
}
}