注册
qianyinli
qianyinli
安装
cordova plugin add cordova-plugin-device-master
cordova plugin add jpush-phonegap-plugin-master --variable API_KEY=303474015e8e6fccab723e11
app.js
$ionicPlatform.ready(function($rootScope){
//极光推送
//启动极光推送服务
window.plugins.jPushPlugin.init();
//调试模式
window.plugins.jPushPlugin.setDebugMode(true);
});
controller.js
//极光推送
var onReceiveMessage = function(event) {
try{
var message;
if(device.platform == "Android") {
message = event.message;
} else {
message = event.content;
}
$scope.testRes=message;
} catch(exception) {
console.log("JPushPlugin:onReceiveMessage-->" + exception);
}
}
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false); // 这个要写在下面。