Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

QQ Group

JPush React Native Plugin

有关于 JPush SDK 的疑问,请务必到我们的社区提问

NOTE:

自动配置(以下命令均在你的 React Native Project 目录下运行,自动配置失败后需要手动配置)

npm install jpush-react-native --save
npm install jcore-react-native --save ## jpush-react-native 1.4.2 版本以后需要同时安装 jcore-react-native
npm run configureJPush <yourAppKey> <yourModuleName>
//module name 指的是你 Android 项目中的模块名字(对 iOS 没有影响,不填写的话默认值为 app,会影响到查找 AndroidManifest 问题,
//如果没找到 AndroidManifest,则需要手动修改,参考下面的 AndroidManifest 配置相关说明)
举个例子:
npm run configureJPush d4ee2375846bc30fa51334f5 app

在 iOS 工程中设置 TARGETS-> BUILD Phases -> LinkBinary with Libraries 找到 UserNotifications.framework 把 status 设为 optional

在 iOS 工程中如果找不到头文件可能要在 TARGETS-> BUILD SETTINGS -> Search Paths -> Header Search Paths 添加如下如路径

$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule/RCTJPushModule

在 xcode8 之后需要点开推送选项: TARGETS -> Capabilities -> Push Notification 设为 on 状态

手动配置(自动配置后,部分操作需要手动修改)

通用

npm install jpush-react-native --save
npm install jcore-react-native --save
react-native link

iOS

在 iOS 工程中设置 TARGETS-> BUILD Phases -> LinkBinary with Libraries 找到 UserNotifications.framework 把 status 设为 optional

在 iOS 工程中如果找不到头文件可能要在 TARGETS-> BUILD SETTINGS -> Search Paths -> Header Search Paths 添加如下如路径

$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule/RCTJPushModule

在 xcode8 之后需要点开推送选项: TARGETS -> Capabilities -> Push Notification 设为 on 状态

Android

  • 修改 app 下的 build.gradle 配置:

your react native project/android/app/build.gradle

android {
 defaultConfig {
 applicationId "yourApplicationId"
 ...
 manifestPlaceholders = [
 JPUSH_APPKEY: "yourAppKey", //在此替换你的APPKey
 APP_CHANNEL: "developer-default" //应用渠道号
 ]
 }
}
...
dependencies {
 compile fileTree(dir: "libs", include: ["*.jar"])
  compile project(':jpush-react-native') // 添加 jpush 依赖
  compile project(':jcore-react-native') // 添加 jcore 依赖
  compile "com.facebook.react:react-native:+" // From node_modules
}

将此处的 yourApplicationId 替换为你的项目的包名;yourAppKey 替换成你在官网上申请的应用的 AppKey,检查一下 dependencies 中有没有添加 jpush-react-native 及 jcore-react-native 这两个依赖。

  • 检查 android 项目下的 settings.gradle 配置有没有包含一下内容:

settings.gradle

include ':app', ':jpush-react-native', ':jcore-react-native'
project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')
  • 检查一下 app 下的 AndroidManifest 配置,有没有增加 <meta-data> 部分。

your react native project/android/app/AndroidManifest.xml

 <application
 ...
 <!-- Required . Enable it you can get statistics data with channel -->
 <meta-data android:name="JPUSH_CHANNEL" android:value="${APP_CHANNEL}"/>
 <meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}"/>
 </application>
  • 现在重新 sync 一下项目,应该能看到 jpush-react-native 以及 jcore-react-native 作为 android Library 项目导进来了。

  • 加入 JPushPackage

Usage

API


贡献者列表

About

JPush's officially supported React Native plugin (Android & iOS). 极光推送官方支持的 React Native 插件(Android & iOS)。

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /