- for latest RN, use latest
- for jpush-react-native > 1.4.4, require install jcore-react-native
npm install jpush-react-native jcore-react-native --save
Configuration contains two steps, auto configuration part and manual cofiguration part.
- Run script command
npm run configureJPush <yourAppKey> <yourModuleName>
// module name corresponds your Android Module name in your project.
// No effect to iOS,default value is "app",this value is the key to find your AndroidManifest.xml,
// If not found AndroidManifest.xml,you need modify manually, please refer the manual part.
// For example:
npm run configureJPush d4ee2375846bc30fa51334f5 app
- Link project
react-native link
Input appKey for JPush and that's all.
If you want to know what auto configuration script does, see The codes iOS auto configuration script adds for detail, otherwise ignore this.
-
In iOS project, TARGETS-> BUILD Phases -> LinkBinary with Libraries find UserNotifications.framework, change status to optional.
-
Add codes to TARGETS-> BUILD SETTINGS -> Search Paths -> Header Search Paths, if auto configuration script can't find header file.
$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule/RCTJPushModule
- Xcode8 or later, you need turn Push Nofication on. TARGETS -> Capabilities -> Push Notification turn on this option.
- Modify your build.gradle in you Android module:
your react native project/android/app/build.gradle
android {
defaultConfig {
// add this if not exists.
applicationId "yourApplicationId" // change to your package name.
...
manifestPlaceholders = [
JPUSH_APPKEY: "yourAppKey", // change to your appKey value.
APP_CHANNEL: "developer-default" // default value.
]
}
}
...
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':jpush-react-native') // add jpush dependency
compile project(':jcore-react-native') // add jcore dependency
compile "com.facebook.react:react-native:+" // From node_modules
}
Change yourApplicationId to your actual package name;change yourAppKey to your AppKey apply from our website.