Skip to content

Commit

Permalink
Merge pull request #662 from jpush/dev
Browse files Browse the repository at this point in the history
更新readme和example
  • Loading branch information
wicked-tc130 authored Sep 10, 2019
2 parents 40c1f34 + a410a77 commit 48f635b
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 138 deletions.
114 changes: 81 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,103 @@ npm install jpush-react-native --save

* 注意:如果项目里没有jcore-react-native,需要安装

```
npm install jcore-react-native --save
```
```
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
]
}
}
```
```
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 依赖
}
```
```
dependencies {
...
implementation project(':jpush-react-native') // 添加 jpush 依赖
implementation project(':jcore-react-native') // 添加 jcore 依赖
}
```

* AndridManifest.xml

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

* 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')
```
```
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')
```

###2.2 iOS

* Libraries

```
Add Files to "your project name"
node_modules/jcore-react-native/ios/RCTJCoreModule/
node_modules/jpush-react-native/ios/RCTJPushModule/
```

* 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
```

## 3. 引用

### 3.1 Android

参考:[MainApplication.java](https://github.com/jpush/jpush-react-native/tree/master/example/android/app/src/main/java/com/example/MainApplication)

### 3.2 iOS

参考:[AppDelegate.m](https://github.com/jpush/jpush-react-native/tree/master/example/ios/PushDemo/AppDelegate.m)

## 4. API

详见:[index.js](https://github.com/jpush/jpush-react-native/blob/master/index.js)



6 changes: 2 additions & 4 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 25

compileSdkVersion 28
defaultConfig {
applicationId "com.jmessage.sdk" //替换包名:
minSdkVersion 16
targetSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk {
Expand Down Expand Up @@ -144,7 +143,6 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':jcore-react-native')
implementation project(':jpush-react-native')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.facebook.react:react-native:+'
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.pushdemo">
package="com.example">

<application
android:name=".MainApplication"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pushdemo;
package com.example;

import android.os.Bundle;

Expand All @@ -16,7 +16,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
protected String getMainComponentName() {
return "ReactNative-JPush";
return "JPush-RN";
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pushdemo;
package com.example;

import android.app.Application;

Expand Down Expand Up @@ -31,6 +31,7 @@ protected String getJSMainModuleName() {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
//需要add JPush
new JPushPackage()
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">ReactNative-JPush</string>
<string name="app_name">JPush-RN</string>
</resources>
8 changes: 1 addition & 7 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.3.0'
}
}

Expand All @@ -19,7 +14,6 @@ allprojects {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ReactNative-JPush",
"displayName": "ReactNative-JPush"
"name": "JPush-RN",
"displayName": "JPush-RN"
}
Loading

0 comments on commit 48f635b

Please sign in to comment.