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 🙏

© 2025 – Pkg Stats / Ryan Hefner

capacitor-plugin-jpushn

v6.0.7

Published

JPush New Version

Downloads

516

Readme

capacitor-plugin-jpushn

JPush New Version

大版本跟@capacitor
ref: capacitor-plugin-jpush

v6.x support Capacitor 6

Install

npm install capacitor-plugin-jpushn
npx cap sync

Usage

in capacitor.config.ts:

/// <reference types="capacitor-plugin-jpush" />

import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
  plugins: {
    JPush: {
      // your application appKey on JPush
      appKey: '',
      channel: '',
    },
  },
};

export default config;

in capacitor.config.json:

{
  "plugins": {
    "JPush": {
      "appKey": "",
      "channel": ""
    }
  }
}

IOS

On iOS you must enable the Push Notifications capability. See Setting Capabilities for instructions on how to enable the capability.

After enabling the Push Notifications capability, add the following to your app's AppDelegate.swift:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
  NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
}

// add the following code to applicationDidBecomeActive function
NotificationCenter.default.post(name: Notification.Name(rawValue: "didBecomeActiveNotification"), object: nil)

then use Xcode to open your native project, and set JPUSHService.h file's Target MemberShip to CapacitorPluginJPush which value is Public:

https://user-images.githubusercontent.com/29945352/235104201-a39bdb6e-314d-423a-beb7-2869f3b27679.png

Android

Android 13 requires a permission check in order to send notifications. You are required to call checkPermissions() and requestPermissions() accordingly.

On Android 12 and older it won't show a prompt and will just return as granted.

please set both compileSdkVersion and targetSdkVersion to 33 in variables.gradle:

android studio

add the following to your app's build.gradle:

manifestPlaceholders = [
  JPUSH_PKGNAME: applicationId,
]

Currently does not support the manufacturer channel push

Example

import { Capacitor } from '@capacitor/core';
import { JPush } from 'capacitor-plugin-jpush';

const jpushSetup = async () => {
  if (Capacitor.isNativePlatform()) {
    // addListener events
    const receivedEvent = await JPush.addListener(
      'notificationReceived',
      data => {
        console.log(data);
      },
    );
    // if you don't need,you can remove
    receivedEvent.remove();

    JPush.addListener('notificationOpened', data => {
      console.log(data);
    });

    JPush.checkPermissions().then(({ notifications }) => {
      console.log(notifications);
      if (notifications === 'prompt' || notifications === 'denied') {
        // apply notification permission
        JPush.requestPermissions().then(res => {
          console.log(res.notifications);
        });
      }
    });
  }
};

const jpushMethods = async () => {
  // set alias
  await JPush.setAlias({
    alias: 'alias',
  });

  // getRegistrationID
  const { registrationId } = await JPush.getRegistrationID();
  console.log(registrationId);

  // ......
};

API

startJPush()

startJPush() => any

启动极光推送服务,即使没有获取到通知权限,也会进行推送服务初始化

Returns: any


setDebugMode(...)

setDebugMode(isDebug: boolean) => any

开启 debug 模式 log日志

| Param | Type | | ------------- | -------------------- | | isDebug | boolean |

Returns: any


setAlias(...)

setAlias(options: AliasOptions) => any

设置推送别名,可作为推送消息的目标对象

| Param | Type | | ------------- | ----------------------------------------------------- | | options | AliasOptions |

Returns: any


deleteAlias(...)

deleteAlias(options?: DeleteAlias | undefined) => any

删除推送别名

| Param | Type | | ------------- | --------------------------------------------------- | | options | DeleteAlias |

Returns: any


addTags(...)

addTags(options: SetTagsOptions) => any

设置推送标签

| Param | Type | | ------------- | --------------------------------------------------------- | | options | SetTagsOptions |

Returns: any


deleteTags(...)

deleteTags(options: SetTagsOptions) => any

删除推送标签

| Param | Type | | ------------- | --------------------------------------------------------- | | options | SetTagsOptions |

Returns: any


cleanTags()

cleanTags() => any

Returns: any


setBadgeNumber(...)

setBadgeNumber(options?: SetBadgeNumberOptions | undefined) => any

设置 APP 角标数字,设为 0 即清空角标

| Param | Type | | ------------- | ----------------------------------------------------------------------- | | options | SetBadgeNumberOptions |

Returns: any


removeListeners()

removeListeners() => any

Returns: any


getRegistrationID()

getRegistrationID() => any

获取设备的注册 ID,若服务重新注册,则返回的 ID 是不一样的

Returns: any


checkPermissions()

checkPermissions() => any

检查通知权限状态

Returns: any


requestPermissions()

requestPermissions() => any

申请通知权限

Returns: any


openNotificationSetting()

openNotificationSetting() => any

打开推送通知权限设置页面(目前仅安卓支持)

Returns: any


addListener('notificationReceived', ...)

addListener(eventName: 'notificationReceived', listenerFunc: (notificationData: ReceiveNotificationData) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

监听推送消息

| Param | Type | | ------------------ | ---------------------------------------------------------------------------------------------------------- | | eventName | 'notificationReceived' | | listenerFunc | (notificationData: ReceiveNotificationData) => void |

Returns: any


addListener('notificationOpened', ...)

addListener(eventName: 'notificationOpened', listenerFunc: (notificationData: ReceiveNotificationData) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

监听消息栏通知被点击

| Param | Type | | ------------------ | ---------------------------------------------------------------------------------------------------------- | | eventName | 'notificationOpened' | | listenerFunc | (notificationData: ReceiveNotificationData) => void |

Returns: any


Interfaces

AliasOptions

| Prop | Type | | -------------- | ------------------- | | alias | string | | sequence | number |

DeleteAlias

| Prop | Type | | -------------- | ------------------- | | sequence | number |

SetTagsOptions

| Prop | Type | | ---------- | --------------- | | tags | {} |

SetBadgeNumberOptions

| Prop | Type | | ----------- | ------------------- | | badge | number |

PermissionStatus

| Prop | Type | Description | | ---------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------- | | permission | PermissionState | prompt: 首次申请,询问。 prompt-with-rationale: 每次都询问。 granted: 已获取权限。 denied:权限已拒绝。 |

ReceiveNotificationData

| Prop | Type | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | title | string | | content | string | | subTitle | string | | rawData | { [x: string]: any; aps: { alert: { body: string; subTitle: string; title: string; }; badge: number; sound: string; }; } |

PluginListenerHandle

| Prop | Type | | ------------ | ------------------------- | | remove | () => any |

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'