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

ltg-jpush

v0.0.8

Published

JPush for cordova plugin

Downloads

275

Readme

JPush PhoneGap / Cordova Plugin

在官方基础上,增加对Capacitor的支持。

Build Status release platforms weibo

极光官方支持的 cordova 推送插件。

注意:插件从 v3.4.0 开始支持 cordova-android 7.0.0,因 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。

如果需要在cordova-android 7.0.0之前版本集成最新插件,参照这篇文章

如果需要安装之前版本的插件,请先安装 v1.2.0 以下版本(建议安装 v1.1.12)的 cordova-plugin-jcore,再安装旧版本插件(比如 v3.3.2),否则运行会报错。

Cordova Android版本与原生版本对应表

Install

注意:

  • 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。
  • 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
  • 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:

    cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey
  • 或直接通过 url 安装:

    cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable APP_KEY=your_jpush_appkey
  • 或下载到本地安装:

    cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey

参数

  • APP_KEY: 必须设置,JPush 上注册的包名对应的 Appkey

    --variable APP_KEY=your_jpush_appkey
  • CHANNEL: 可以不设置,v3.6.0+ 版本开始支持(Android Only),方便开发者统计 APK 分发渠道,默认为 developer-default.

    --variable CHANNEL=your_channel
  • 同时动态配置 APP_KEY 和 CHANNEL 示例

    cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey --variable CHANNEL=your_channel

Ionic

如果使用了 Ionic,可以再安装 @jiguang-ionic/jpush 包,适配 ionic-native:

npm install --save @jiguang-ionic/[email protected]

# npm install --save @jiguang-ionic/[email protected] for ionic4+

然后在 app.module.ts 中增加:

// @jiguang-ionic/[email protected]+
import { JPush } from '@jiguang-ionic/jpush';

// @jiguang-ionic/[email protected]+
import { JPush } from '@jiguang-ionic/jpush/ngx';
...
  providers: [
    ...
    JPush,
    ...
  ]

具体可参考 ./ionic/example 中的文件。

Usage

API

Demo

插件项目中包含一个简单的 Demo。若想参考,可以在 /example 文件夹内找到并拷贝以下文件:

example/index.html -> www/index.html
example/css/* -> www/css
example/js/* -> www/js

关于 PhoneGap build 云服务

该项目基于 Cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。

FAQ

如果遇到了疑问,请优先参考 Demo 和 API 文档。若还无法解决,可到 Issues 提问。

Android

在 Eclipse 中 import 工程之后出现:Type CallbackContext cannot be resolved to a type

右键单击工程名 -> Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。

无法获取到 Registration Id

检查 AppKey 和应用包名是否对应、是否调用了 init 方法。

如何自定义通知声音?

Android 因为各 Rom 的高度定制化,不像 iOS 一样能有一个统一的管理,如果在 Android 中想自定义通知铃声,推荐通过 JPush 推送自定义 消息,之后在 jpush.receiveMessage 事件监听中通过 Cordova Local-Notification Plugin 触发通知,再配合 Cordova Background Plugin 插件保证应用的后台运行。

如何让通知内容像 iOS 一样自动换行展示?

#267

关闭 App 后收不到通知

Android 的推送通过长连接的方式实现,只有在保持连接的情况下才能收到通知。而有的第三方 ROM 会限制一般应用服务的自启动,也就是在退出应用后,应用的所有服务均被杀死,且无法自启动,所以就会收不到通知。

目前 JPush 是做了应用互相拉起机制的,也就是当用户打开其他集成了 JPush 的应用时,你的应用也能同时收到推送消息。

如果你的应用希望随时都能收到推送,官方推荐是通过文案的方式引导用户在设置中允许你的应用能够自启动,常见机型的设置方法可以参考这里

或者自己实现应用保活,网上有很多相关文章(不推荐)。

为什么 QQ、微信之类的应用退出后还能够收到通知?因为这些大厂应用,手机厂商默认都会加入自启动白名单中,也不会在应用退出后杀死它们的相关服务。 如果你多加留意,就会发现非大厂的应用如果你一段时间不用都是收不到推送的。

iOS

XCode 10 收不到推送怎么办?

打开 xcode -> file -> WorkSpace Settings… -> Build System 改成 Legacy Build System 然后卸载 App 重新运行。

打包时遇到 i386 打包失败怎么办?

cordova platform update ios

PushConfig.plist 文件中的字段都是什么意思?

  • Appkey:应用标识。
  • Channel:渠道标识。
  • IsProduction:是否生产环境。
  • IsIDFA:是否使用 IDFA 启动 SDK。

刚集成完插件收不到推送怎么办?

请首先按照正确方式再次配置证书、描述文件,具体可参考 iOS 证书设置指南

iOS 集成插件白屏、或无法启动插件、或打包报错无法找到需要引入的文件怎么办?

按照以下步骤逐个尝试:

  • 升级至最新版本 Xcode
  • 删除插件、再重装插件(先使用 cordova platform add ios,后使用 cordova plugin add

Support

Contribute

Please contribute! Look at the issues.

License

MIT © JiGuang