npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ionic2-jpush

v0.1.1

Published

ionic2 jPush

Downloads

82

Readme

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

| 名称 | 参数 | 返回类型 | 描述 | | ------------- | ------- | ------- | ----------- | | setDebugMode | boolean | Promise | 设置 debug 模式 | | init | 无 | Promise | 注册极光 | | getRegistrationID | 无 | Promise | 获取ID | | stopPush | 无 | Promise | 停用推送 | | resumePush | 无 | Promise | 恢复推送 | | isPushStopped | 无 | Promise | 推送是否被停用 | | 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

| 名称 | 参数 | 返回类型 | 描述 | | ------------- | ------- | ------- | ----------- | | setBadge | value:number| Promise | 设置 badge 至 JPush 服务器| | reSetBadge | 无| Promise | 移除 JPush 服务器 badge | | getApplicationIconBadgeNumber | 无| Promise | 获取本地 badge | | setApplicationIconBadgeNumber | value:number| Promise | 设置本地 badge | | clearAllLocalNotifications | 无| Promise | 清除所有本地推送对象 |

Android API

| 名称 | 参数 | 返回类型 | 描述 | | ------------- | ------- | ------- | ----------- | | clearNotificationById | id:number| Promise | 清除指定ID通知 | | clearAllNotification | 无 | Promise | 清除所有通知 | | setPushTime | days: number , startHour: number, endHour: number | Promise | 设置允许推送时间 | | setSilenceTime | days: number , startHour: number, endHour: number | Promise | 设置通知静默时间 |

可订阅事件

| 名称 | 参数 | 返回类型 | 描述 | | ------------- | ------- | ------- | ----------- | | openNotification | 无| Observable | 点击通知事件 | | receiveNotification | 无| Observable | 收到通知事件 | | receiveMessage | 无| Observable | 收到自定义消息事件 | | backgroundNotification | 无| Observable | 后台收到通知事件 |