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));
}
});
}
}
}