jpush-react-native

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

MIT License

Downloads
830
Stars
1.3K
Committers
37

JPush-React-Native

ChangeLog

  1. RN-JPush2.7.5TypeScript
  2. RN-JCore1.6.0RN-JCore1.7.0AndroidManifest.xml -2.1 Android

1.

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

    npm install jcore-react-native --save
    

2.

2.1 Android

  • build.gradle

    android {
          defaultConfig {
              applicationId "yourApplicationId"           //
              ...
              manifestPlaceholders = [
                      JPUSH_APPKEY: "yourAppKey",         //APPKey
                      JPUSH_CHANNEL: "yourChannel"        //channel
              ]
          }
      }
    
    dependencies {
          ...
          implementation project(':jpush-react-native')  //  jpush 
          implementation project(':jcore-react-native')  //  jcore 
      }
    
  • setting.gradle

    include ':jpush-react-native'
    project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
    include ':jcore-react-native'
    project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')
    
  • AndroidManifest.xml

    <meta-data
    	android:name="JPUSH_CHANNEL"
    	android:value="${JPUSH_CHANNEL}" />
    <meta-data
    	android:name="JPUSH_APPKEY"
    	android:value="${JPUSH_APPKEY}" />    
    

2.2 iOS

ios.xcworkspace

2.2.1 pod

pod install
  • pod

    pod deintegrate
    

2.2.2

  • Libraries

    Add Files to "your project name"
    node_modules/jcore-react-native/ios/RCTJCoreModule.xcodeproj
    node_modules/jpush-react-native/ios/RCTJPushModule.xcodeproj
    
  • Capabilities

    Push Notification --- ON
    
  • Build Settings

    All --- Search Paths --- Header Search Paths --- +
    $(SRCROOT)/../node_modules/jcore-react-native/ios/RCTJCoreModule/
    $(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule/
    
  • Build Phases

    libz.tbd
    libresolv.tbd
    UserNotifications.framework
    libRCTJCoreModule.a
    libRCTJPushModule.a
    

3.

3.1 Android

MainApplication.java

3.2 iOS

AppDelegate.m

3.3 js

App.js

4. API

index.js

5.

  • example
  • JPush.setLoggerEnable(true}debug