Skip to content

Commit 48f635b

Browse files
author
wicked-tc130
authored
Merge pull request #662 from jpush/dev
更新readme和example
2 parents 40c1f34 + a410a77 commit 48f635b

File tree

12 files changed

+151
-138
lines changed

12 files changed

+151
-138
lines changed

README.md

Lines changed: 81 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,103 @@ npm install jpush-react-native --save
88

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

11-
```
12-
npm install jcore-react-native --save
13-
```
11+
```
12+
npm install jcore-react-native --save
13+
```
1414

1515
## 2. 配置
1616

1717
### 2.1 Android
1818

1919
* build.gradle
2020

21-
```
22-
android {
23-
defaultConfig {
24-
applicationId "yourApplicationId" //在此替换你的应用包名
25-
...
26-
manifestPlaceholders = [
27-
JPUSH_APPKEY: "yourAppKey", //在此替换你的APPKey
28-
JPUSH_CHANNEL: "yourChannel" //在此替换你的channel
29-
]
30-
}
31-
}
32-
```
21+
```
22+
android {
23+
defaultConfig {
24+
applicationId "yourApplicationId" //在此替换你的应用包名
25+
...
26+
manifestPlaceholders = [
27+
JPUSH_APPKEY: "yourAppKey", //在此替换你的APPKey
28+
JPUSH_CHANNEL: "yourChannel" //在此替换你的channel
29+
]
30+
}
31+
}
32+
```
3333

34-
```
35-
dependencies {
36-
...
37-
implementation project(':jpush-react-native') // 添加 jpush 依赖
38-
implementation project(':jcore-react-native') // 添加 jcore 依赖
39-
}
40-
```
34+
```
35+
dependencies {
36+
...
37+
implementation project(':jpush-react-native') // 添加 jpush 依赖
38+
implementation project(':jcore-react-native') // 添加 jcore 依赖
39+
}
40+
```
4141

4242
* AndridManifest.xml
4343

44-
```
45-
<meta-data
46-
android:name="JPUSH_CHANNEL"
44+
```
45+
<meta-data
46+
android:name="JPUSH_CHANNEL"
4747
android:value="${JPUSH_CHANNEL}" />
48-
<meta-data
48+
<meta-data
4949
android:name="JPUSH_APPKEY"
5050
android:value="${JPUSH_APPKEY}" />
51-
```
51+
```
5252

5353
* setting.gradle
5454

55-
```
56-
include ':jpush-react-native'
57-
project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
58-
include ':jcore-react-native'
59-
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')
60-
```
55+
```
56+
include ':jpush-react-native'
57+
project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
58+
include ':jcore-react-native'
59+
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')
60+
```
6161

6262
###2.2 iOS
63+
64+
* Libraries
65+
66+
```
67+
Add Files to "your project name"
68+
node_modules/jcore-react-native/ios/RCTJCoreModule/
69+
node_modules/jpush-react-native/ios/RCTJPushModule/
70+
```
71+
72+
* Capabilities
73+
74+
```
75+
Push Notification --- ON
76+
```
77+
78+
* Build Settings
79+
80+
```
81+
All --- Search Paths --- Header Search Paths --- +
82+
$(SRCROOT)/../node_modules/jcore-react-native/ios/RCTJCoreModule/
83+
$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule/
84+
```
85+
86+
* Build Phases
87+
88+
```
89+
libz.tbd
90+
libresolv.tbd
91+
UserNotifications.framework
92+
93+
```
94+
95+
## 3. 引用
96+
97+
### 3.1 Android
98+
99+
参考:[MainApplication.java](https://github.com/jpush/jpush-react-native/tree/master/example/android/app/src/main/java/com/example/MainApplication)
100+
101+
### 3.2 iOS
102+
103+
参考:[AppDelegate.m](https://github.com/jpush/jpush-react-native/tree/master/example/ios/PushDemo/AppDelegate.m)
104+
105+
## 4. API
106+
107+
详见:[index.js](https://github.com/jpush/jpush-react-native/blob/master/index.js)
108+
109+
110+

example/android/app/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,11 @@ def enableSeparateBuildPerCPUArchitecture = false
9494
def enableProguardInReleaseBuilds = false
9595

9696
android {
97-
compileSdkVersion 25
98-
97+
compileSdkVersion 28
9998
defaultConfig {
10099
applicationId "com.jmessage.sdk" //替换包名:
101100
minSdkVersion 16
102-
targetSdkVersion 23
101+
targetSdkVersion 28
103102
versionCode 1
104103
versionName "1.0"
105104
ndk {
@@ -144,7 +143,6 @@ dependencies {
144143
implementation fileTree(include: ['*.jar'], dir: 'libs')
145144
implementation project(':jcore-react-native')
146145
implementation project(':jpush-react-native')
147-
implementation 'com.android.support:appcompat-v7:25.3.1'
148146
implementation 'com.facebook.react:react-native:+'
149147
}
150148

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:tools="http://schemas.android.com/tools"
3-
package="com.pushdemo">
3+
package="com.example">
44

55
<application
66
android:name=".MainApplication"

example/android/app/src/main/java/com/pushdemo/MainActivity.java renamed to example/android/app/src/main/java/com/example/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.pushdemo;
1+
package com.example;
22

33
import android.os.Bundle;
44

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

1717
@Override
1818
protected String getMainComponentName() {
19-
return "ReactNative-JPush";
19+
return "JPush-RN";
2020
}
2121

2222
}

example/android/app/src/main/java/com/pushdemo/MainApplication.java renamed to example/android/app/src/main/java/com/example/MainApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.pushdemo;
1+
package com.example;
22

33
import android.app.Application;
44

@@ -31,6 +31,7 @@ protected String getJSMainModuleName() {
3131
protected List<ReactPackage> getPackages() {
3232
return Arrays.<ReactPackage>asList(
3333
new MainReactPackage(),
34+
//需要add JPush
3435
new JPushPackage()
3536
);
3637
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
<string name="app_name">ReactNative-JPush</string>
2+
<string name="app_name">JPush-RN</string>
33
</resources>

example/android/build.gradle

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
31
buildscript {
42
repositories {
53
google()
64
jcenter()
75
}
86
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.3.2'
10-
11-
// NOTE: Do not place your application dependencies here; they belong
12-
// in the individual module build.gradle files
7+
classpath 'com.android.tools.build:gradle:3.3.0'
138
}
149
}
1510

@@ -19,7 +14,6 @@ allprojects {
1914
mavenLocal()
2015
jcenter()
2116
maven {
22-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
2317
url "$rootDir/../node_modules/react-native/android"
2418
}
2519
}

example/app.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"name": "ReactNative-JPush",
3-
"displayName": "ReactNative-JPush"
2+
"name": "JPush-RN",
3+
"displayName": "JPush-RN"
44
}

0 commit comments

Comments
 (0)