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

react-native-jpush

v1.0.9

Published

极光推送模块

Downloads

12

Readme

react-native-jpush

React Native的极光推送插件, react-native版本需要0.17.0及以上

如何安装

首先安装npm包

npm install react-native-jpush --save

link

rnpm link react-native-jpush

Note:

  • rnpm requires node version 4.1 or higher
  • Android SDK Build-tools 23.0.2 or higher

iOS工程配置

a.在工程target的Build Phases->Link Binary with Libraries中加入libz.tbd、CoreTelephony.framework、Security.framework

b.在你的工程中创建一个新的Property List文件,并将其命名为PushConfig.plist,文件所含字段如下:

CHANNEL
	指明应用程序包的下载渠道,为方便分渠道统计,具体值由你自行定义,如:App Store。
APP_KEY
	与JPush上申请的 AppKey 一致。
APS_FOR_PRODUCTION
	0 (默认值)表示采用的是开发证书,1 表示采用生产证书发布应用。
	注:此字段的值要与Build Settings的Code Signing配置的证书环境一致。

c.在AppDelegate.m中加入

#import "RCTJPush.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  
  [RCTJPush application:application didFinishLaunchingWithOptions:launchOptions];
  
  ...
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [RCTJPush application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
{
  [RCTJPush application:application didReceiveRemoteNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  [RCTJPush application:application didReceiveRemoteNotification:notification];
  completionHandler(UIBackgroundFetchResultNewData);
}

Android配置

android/app/build.gradle里,defaultConfig栏目下添加如下代码:

manifestPlaceholders = [
    JPush_APPID: "JPush的APPID",	//在此修改JPush的APPID
    APP_CHANNEL: "应用渠道号"		//应用渠道号
]

如何使用

引入包

import JPush , {JpushEventReceiveMessage, JpushEventOpenMessage} from 'react-native-jpush'

在你的根Component中加入下面代码

componentDidMount() {
    JPush.requestPermissions()
    this.pushlisteners = [
        JPush.addEventListener(JpushEventReceiveMessage, this.onReceiveMessage.bind(this)),
        JPush.addEventListener(JpushEventOpenMessage, this.onOpenMessage.bind(this)),
    ]
}
componentWillUnmount() {
    this.pushlisteners.forEach(listener=> {
        JPush.removeEventListener(listener);
    });
}
onReceiveMessage(message) {
}
onOpenMessage(message) {
}