New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ionic2-jpush

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ionic2-jpush

ionic2 jPush

  • 0.1.0-beta.2
  • beta
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

ionic2-JPush

Dependency Status NPM version Downloads MIT License

为ionic2调用极光插件提供符合angular2及TS的调用方式

说在前面:如果想使用 ionic-native 的调用方式,可以参考https://github.com/zjcboy/ionic2-jpush-demo

install

先安装官方的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 module

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 {}

Use

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

API

名称参数返回类型描述
initPromise注册极光
getRegistrationIDPromise获取ID
stopPushPromise停用推送
resumePushPromise恢复推送
isPushStoppedPromise推送是否被停用
setTagsWithAliastags:Array,alias:stringPromise设置tags和alias
setTagstags:ArrayPromise设置tags
setAliasalias:stringPromise设置alias
setBadgevalue:numberPromise设置badge 仅 ios
setApplicationIconBadgeNumbervalue:numberPromise设置badge 仅 ios
reSetBadgePromise移除badge 仅 ios
getApplicationIconBadgeNumberPromise获取badge 仅 ios
clearNotificationByIdid:numberPromise清除指定ID通知 仅 android
clearAllNotificationid:numberPromise清除所有通知 仅 android
openNotificationObservable点击通知事件
receiveNotificationObservable收到通知事件
receiveMessageObservable收到自定义消息事件
backgroundNotificationObservable后台收到通知事件

Keywords

FAQs

Package last updated on 31 Oct 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc