Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
ionic2-jpush
Advanced tools
为ionic2调用极光插件提供符合angular2及TS的调用方式
说在前面:如果想使用 ionic-native 的调用方式,可以参考https://github.com/zjcboy/ionic2-jpush-demo
先安装官方的cordova插件 https://github.com/jpush/jpush-phonegap-plugin.git
$ cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey
在安装本库
$ npm install ionic2-jpush --save
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
...
import { IonJPushModule } from 'ionic2-jpush'
@NgModule({
declarations: [
MyApp,
...
],
imports: [
IonJPushModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
...
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
import 'rxjs';
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
...
import { JPushService } from 'ionic2-jpush'
@Component({
templateUrl: 'plugins-test.html'
})
export class PluginsTestPage {
constructor(
private platform: Platform,
private jPushPlugin: JPushService
) {
platform.ready().then( () =>{
this.jPushPlugin.openNotification()
.subscribe( res => {
console.log('收到推送');
console.log(res)
});
this.jPushPlugin.receiveNotification()
.subscribe( res => {
console.log('收到推送');
console.log(res)
});
this.jPushPlugin.receiveMessage()
.subscribe( res => {
console.log('收到推送');
console.log(res)
});
})
}
/**
* 注册极光
*/
init() {
this.jPushPlugin.init()
.then(res => alert(res))
.catch(err => alert(err))
}
/**
* 获取ID
*/
getRegistrationID() {
this.jPushPlugin.getRegistrationID()
.then(res => alert(res))
.catch(err => alert(err))
}
/**
* 设置 setBadge
* 仅限IOS
* @param number
*/
setBadge(number) {
if (this.platform.is('ios')) {
this.jPushPlugin.setBadge(number)
.then(res => alert(res))
.catch(err => alert(err))
}
}
}
名称 | 参数 | 返回类型 | 描述 |
---|---|---|---|
init | 无 | Promise | 注册极光 |
getRegistrationID | 无 | Promise | 获取ID |
stopPush | 无 | Promise | 停用推送 |
resumePush | 无 | Promise | 恢复推送 |
isPushStopped | 无 | Promise | 推送是否被停用 |
setTagsWithAlias | tags:Array,alias:string | Promise | 设置tags和alias |
setTags | tags:Array | Promise | 设置tags |
setAlias | alias:string | Promise | 设置alias |
setBadge | value:number | Promise | 设置badge 仅 ios |
setApplicationIconBadgeNumber | value:number | Promise | 设置badge 仅 ios |
reSetBadge | 无 | Promise | 移除badge 仅 ios |
getApplicationIconBadgeNumber | 无 | Promise | 获取badge 仅 ios |
clearNotificationById | id:number | Promise | 清除指定ID通知 仅 android |
clearAllNotification | id:number | Promise | 清除所有通知 仅 android |
openNotification | 无 | Observable | 点击通知事件 |
receiveNotification | 无 | Observable | 收到通知事件 |
receiveMessage | 无 | Observable | 收到自定义消息事件 |
backgroundNotification | 无 | Observable | 后台收到通知事件 |
FAQs
ionic2 jPush
The npm package ionic2-jpush receives a total of 5 weekly downloads. As such, ionic2-jpush popularity was classified as not popular.
We found that ionic2-jpush demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.