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.1
  • latest
  • 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))
     }
     
    /**
    * 设置标签
    */
    setTags() {
    this.jPushPlugin.setTags({
      sequence: Date.now(),
      tags: ['tag1', 'tag2']
    })
    .then((res:any) => {
      console.log(res.tags.toString())
    })
    .catch(err => {
      alert(err);
      console.log(err)
    })
    }
    
  }

API

名称参数返回类型描述
setDebugModebooleanPromise设置 debug 模式
initPromise注册极光
getRegistrationIDPromise获取ID
stopPushPromise停用推送
resumePushPromise恢复推送
isPushStoppedPromise推送是否被停用
setTags{ sequence: number; tags: string[] }Promise设置 tags
addTags{ sequence: number; tags: string[] }Promise添加 tags
deleteTags{ sequence: number; tags: string[] }Promise删除 tags
cleanTags{ sequence: number }Promise清除tags
getAllTags{ sequence: number }Promise获取所有本机设置的 tags
setAlias{ sequence: number; alias: string }Promise设置 alias
deleteAlias{ sequence: number }Promise删除 alias
getAlias{ sequence: number }Promise获取本机设置的 alias

IOS API

名称参数返回类型描述
setBadgevalue:numberPromise设置 badge 至 JPush 服务器
reSetBadgePromise移除 JPush 服务器 badge
getApplicationIconBadgeNumberPromise获取本地 badge
setApplicationIconBadgeNumbervalue:numberPromise设置本地 badge
clearAllLocalNotificationsPromise清除所有本地推送对象

Android API

名称参数返回类型描述
clearNotificationByIdid:numberPromise清除指定ID通知
clearAllNotificationPromise清除所有通知
setPushTimedays: number , startHour: number, endHour: numberPromise设置允许推送时间
setSilenceTimedays: number , startHour: number, endHour: numberPromise设置通知静默时间

可订阅事件

名称参数返回类型描述
openNotificationObservable点击通知事件
receiveNotificationObservable收到通知事件
receiveMessageObservable收到自定义消息事件
backgroundNotificationObservable后台收到通知事件

Keywords

FAQs

Package last updated on 14 Nov 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