Skip to content

Commit 78f4146

Browse files
author
wicked-tc130
authored
Merge pull request #651 from jpush/dev
同步Android-JPush3.3.4&&iOS-JPush3.2.2
2 parents 7ec953d + 2e222d0 commit 78f4146

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2151
-6514
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,5 @@ package-lock.json
204204
yarn.lock
205205
*.qshell
206206
*.DS_Store
207+
208+
*.gitattributes

README.md

Lines changed: 34 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,62 @@
1-
[![tag](https://img.shields.io/badge/tag-1.6.7-blue.svg)](https://github.com/jpush/jpush-react-native/releases)
2-
[![QQ Group](https://img.shields.io/badge/QQ%20Group-553406342-red.svg)]()
1+
# JPush-React-Native
32

4-
# JPush React Native Plugin
5-
6-
[English Document](README_en.md)
7-
8-
## 安装
3+
## 1. 安装
94

105
```
11-
npm install jpush-react-native jcore-react-native --save
6+
npm install jpush-react-native --save
127
```
138

14-
## 配置
15-
16-
#### 1. iOS 手动操作部分 (3 个步骤)
17-
18-
- 在 iOS 工程中设置 TARGETS-> BUILD Phases -> LinkBinary with Libraries 找到 UserNotifications.framework 把 status 设为 optional
19-
- 在 iOS 工程中如果找不到头文件可能要在 TARGETS-> BUILD SETTINGS -> Search Paths -> Header Search Paths 添加如下路径
9+
* 注意:如果项目里没有jcore-react-native,需要安装
2010

2111
```
22-
$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule
12+
npm install jcore-react-native --save
2313
```
2414

25-
- 在 xcode8 之后需要点开推送选项: TARGETS -> Capabilities -> Push Notification 设为 on 状态
15+
## 2. 配置
2616

27-
#### 2. Android 手动操作部分 (3 个步骤)
17+
### 2.1 Android
2818

29-
- 修改 app 下的 build.gradle 配置:
19+
* build.gradle
3020

31-
> your react native project/android/app/build.gradle
32-
33-
```java
34-
android {
21+
```
22+
android {
3523
defaultConfig {
36-
applicationId "yourApplicationId"
24+
applicationId "yourApplicationId" //在此替换你的应用包名
3725
...
3826
manifestPlaceholders = [
3927
JPUSH_APPKEY: "yourAppKey", //在此替换你的APPKey
40-
JPUSH_CHANNEL: "developer-default" //在此替换你的channel
28+
JPUSH_CHANNEL: "yourChannel" //在此替换你的channel
4129
]
4230
}
4331
}
44-
...
45-
dependencies {
46-
implementation fileTree(dir: "libs", include: ["*.jar"])
32+
```
33+
34+
```
35+
dependencies {
36+
...
4737
implementation project(':jpush-react-native') // 添加 jpush 依赖
4838
implementation project(':jcore-react-native') // 添加 jcore 依赖
49-
implementation "com.facebook.react:react-native:+" // From node_modules
5039
}
51-
```
52-
同时在AndridManifest.xml中添加如下代码
53-
```
54-
<meta-data
55-
android:name="JPUSH_CHANNEL"
56-
android:value="${JPUSH_CHANNEL}" />
57-
<meta-data
58-
android:name="JPUSH_APPKEY"
59-
android:value="${JPUSH_APPKEY}" />
60-
```
40+
```
41+
42+
* AndridManifest.xml
43+
44+
```
45+
<meta-data
46+
android:name="JPUSH_CHANNEL"
47+
android:value="${JPUSH_CHANNEL}" />
48+
<meta-data
49+
android:name="JPUSH_APPKEY"
50+
android:value="${JPUSH_APPKEY}" />
51+
```
6152

62-
- 修改setting.gradle配置:
53+
* setting.gradle
6354

64-
```java
65-
include ':jpush-react-native'
55+
```
56+
include ':jpush-react-native'
6657
project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
6758
include ':jcore-react-native'
6859
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')
69-
```
70-
71-
**操作完成后点击AndroidStudio的构建**
72-
73-
- 在Application中添加JPush
74-
75-
```java
76-
public class MainApplication extends Application implements ReactApplication {
77-
78-
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
79-
@Override
80-
public boolean getUseDeveloperSupport() {
81-
return BuildConfig.DEBUG;
82-
}
83-
84-
@Override
85-
protected List<ReactPackage> getPackages() {
86-
@SuppressWarnings("UnnecessaryLocalVariable")
87-
List<ReactPackage> packages = new PackageList(this).getPackages();
88-
//建议在调试期间将参数都设置为true,便于调试
89-
packages.add(new JPushPackage(true,true));
90-
return packages;
91-
}
92-
93-
@Override
94-
protected String getJSMainModuleName() {
95-
return "index";
96-
}
97-
};
98-
99-
@Override
100-
public void onCreate() {
101-
super.onCreate();
102-
SoLoader.init(this, /* native exopackage */ false);
103-
//强烈建议在Application初始化时调用原生接口的init方法
104-
JPushInterface.init(this);
105-
}
106-
}
107-
```
108-
109-
110-
111-
### API
112-
113-
**Android v1.6.6 版本后新增 notifyJSDidLoad,请务必在接收事件之前调用此方法。**
114-
115-
- [API](documents/api_en.md)
116-
117-
### 关于点击通知跳转到指定界面
118-
119-
- Android v1.6.7 新增 API `jumpToPushActivity`,使用参考 [demo](example/App.js#L113)
120-
121-
## [常见问题](./documents/common_problems.md)
122-
123-
------
124-
125-
## 贡献者列表
126-
127-
- [bang88](https://github.com/bang88)
128-
- [pampang](https://github.com/pampang)
129-
- [huhuanming](https://github.com/huhuanming)
130-
- [arniu](https://github.com/arniu)
60+
```
13161

62+
###2.2 iOS

README_en.md

Lines changed: 0 additions & 100 deletions
This file was deleted.

android/.classpath

Lines changed: 0 additions & 6 deletions
This file was deleted.

android/.project

Lines changed: 0 additions & 23 deletions
This file was deleted.

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

android/build.gradle

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,16 @@ def safeExtGet(prop, fallback) {
66

77
android {
88
compileSdkVersion safeExtGet('compileSdkVersion', 27)
9-
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.2')
10-
119
defaultConfig {
1210
minSdkVersion safeExtGet('minSdkVersion', 16)
1311
targetSdkVersion safeExtGet('targetSdkVersion', 27)
1412
versionCode 1
1513
versionName "1.0"
16-
}
17-
lintOptions {
18-
abortOnError false
19-
warning 'InvalidPackage'
20-
}
21-
sourceSets.main {
22-
jniLibs.srcDirs = ['libs']
23-
}
24-
}
2514

26-
repositories {
27-
mavenCentral()
15+
}
2816
}
2917

3018
dependencies {
31-
api fileTree(include: ['*.jar'], dir: 'libs')
19+
implementation fileTree(dir: 'libs', include: ['*.jar'])
3220
implementation 'com.facebook.react:react-native:+'
3321
}
-52.4 KB
Binary file not shown.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)