@Ionic-Native-Cordova-Plugin
Github: https://github.com/kongdewen1994/ionic2-jpush-cordova-plugin
支持 iOS, Android 的 Cordova 極光推送插件( ionic2/3 @ionic-native??封裝)飞蛹。
Install
-
通過(guò) Cordova Plugins 安裝敷待,要求 Cordova CLI 5.0+:
ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey
-
或直接通過(guò) url 安裝:
ionic cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable APP_KEY=your_jpush_appkey
Usage
API
Usage
The dist directory will contain a sub directory @ionic-native with all the packages compiled in there. Copy the package(s) you created/modified to your app's node_modules under the @ionic-native directory. (e.g. cp -r dist/@ionic-native/plugin-name ../my-app/node_modules/@ionic-native/).
???? 將 dist/@ionic-native 的 jpush文件夾復(fù)制到 ionic2項(xiàng)目的 node_modules/@ionic-native/ 下
Add Plugins to Your App's Module
After installing a plugin’s package, add it to your app’s NgModule.
...
import { JPushPlugin } from '@ionic-native/jpush';
...
@NgModule({
...
providers: [
...
JPushPlugin
...
]
...
})
export class AppModule { }
import { JPushPlugin } from '@ionic-native/jpush';
constructor(public jpush: JPushPlugin) {
this.init();
//延遲執(zhí)行,等極光完全初始化
setTimeout(()=>{
this.setAlias( "Alias" );
},300)
}
init(){
//初始化極光
this.jpush.init();
//收到通知時(shí)會(huì)觸發(fā)該事件赞哗。
document.addEventListener("jpush.receiveNotification", function (event) {
alert( JSON.stringify( event ) );
}, false);
}
//綁定別名
setAlias( Alias : string ){
jpush.setAlias( Alias ).then((res)=>{
alert( JSON.stringify(res) );
}).catch((err)=>{
alert( JSON.stringify(err) );
});
}
............
...
Support
- QQ 群:513752928