1、1.注册极光推送,创建应用,获取 appkey2.使用 cordova 命令安装插件cordova plugin add jpush-phonegap-plugin -variable API_KEY=填写你创建应用后获取到的 key3.service 封装方法/ 极光推送.factory(JpushService, $window,$ionicPlatform,function($window, $ionicPlatform)return /初始化init: function(notificationCallback)if ($window.plugins /$window.plugins.
2、jPushPlugin.setDebugMode(true);/$window.plugins.jPushPlugin.openNotificationInAndroidCallback = notificationCallback;/$window.plugins.jPushPlugin.receiveNotificationIniOSCallback = notificationCallback;,/设置设备注册的 RegistrationIDgetRegistrationID: function(onGetRegistradionID)if($window.plugins ,/打开onO
3、pen: function(callback) if ($window.plugins ,/接收onReceive: function(callback) if ($window.plugins ,/获取状态isPushStopped : function(fun)if($window.plugins ,/重启极光推送resumePush: function(onCallback)if($window.plugins ,/设置标签和别名setTagsWithAlias: function(tags,alias)if($window.plugins document.addEventListen
4、er(“jpush.setTagsWithAlias“, onTagsWithAlias, false);var onTagsWithAlias = function(event) try var result = “result code:“ + event.resultCode + “ “;result += “tags:“ + event.tags + “ “;result += “alias:“ + event.alias + “ “; catch (exception) ,/设置标签setTags: function(tags)if($window.plugins ,/设置别名set
5、Alias: function(alias)if($window.plugins ,/ 清空应用 badge 值clearBadge: function() if ($ionicPlatform.is(ios) if($window.plugins )4.测试 app.js 添加红色部分.run($ionicPlatform,JpushService,function($ionicPlatform, JpushService) $ionicPlatform.ready(function() if (window.cordova cordova.plugins.Keyboard.disableScroll(true);if (window.StatusBar) StatusBar.styleDefault();/ 启动极光推送JpushService.init();JpushService.onOpen();JpushService.onReceive();/ 获取设备的 registerIdJpushService.getRegistrationID(function(id)/ 传送 registrationId 到用户服务器alert(“registerId:“ + id);););)5.极光应用平台推送消息6.手机接收到的通知