Skip to content

Commit aa51612

Browse files
Merge pull request #268 from jpush/dev
update to 1.7.0
2 parents b748d2d + ef9e588 commit aa51612

File tree

4 files changed

+88
-61
lines changed

4 files changed

+88
-61
lines changed

example/documents/iOS_API.md

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,69 @@
1-
## jpush-react-native iOS API
2-
3-
All apis can find in jpush-react-native/index.js.
4-
5-
- setBadge(badge, cb)
6-
7-
设置 badge 值
8-
```
9-
JPushModule.setBadge(5, (success) => {
10-
console.log(success)
11-
});
12-
```
13-
14-
- setLocalNotification( date,
15-
textContain, // date
16-
badge, // int
17-
alertAction, // String
18-
notificationKey, // String
19-
userInfo, // Dictionary
20-
soundName // String
21-
)
22-
23-
设置本地推送
24-
```
25-
JPushModule.setLocalNotification( this.state.date,
26-
this.state.textContain,
27-
5,
28-
'dfsa',
29-
'dfaas',
30-
null,
31-
null);
32-
```
33-
34-
## 事件
35-
监听 `ReceiveNotification` 事件,收到到推送的时候会回调
36-
```
37-
var subscription = NativeAppEventEmitter.addListener(
38-
'ReceiveNotification',
39-
(notification) => console.log(notification)
40-
);
41-
```
42-
43-
监听 `OpenNotification` 事件,点击推送的时候会执行这个回调
44-
```
45-
var subscription = NativeAppEventEmitter.addListener(
46-
'OpenNotification',
47-
(notification) => console.log(notification)
48-
);
49-
```
50-
51-
监听 `networkDidReceiveMessage` 事件,收到 JPush 应用内消息会执行这个回调
52-
```
53-
var subscription = NativeAppEventEmitter.addListener(
54-
'networkDidReceiveMessage',
55-
(message) => console.log(message)
56-
);
57-
```
1+
## jpush-react-native iOS API
2+
3+
All apis can find in jpush-react-native/index.js.
4+
5+
- setBadge(badge, cb)
6+
7+
设置 badge 值
8+
```
9+
JPushModule.setBadge(5, (success) => {
10+
console.log(success)
11+
});
12+
```
13+
14+
- setLocalNotification( date,
15+
textContain, // date
16+
badge, // int
17+
alertAction, // String
18+
notificationKey, // String
19+
userInfo, // Dictionary
20+
soundName // String
21+
)
22+
23+
设置本地推送
24+
```
25+
JPushModule.setLocalNotification( this.state.date,
26+
this.state.textContain,
27+
5,
28+
'dfsa',
29+
'dfaas',
30+
null,
31+
null);
32+
```
33+
34+
## 事件
35+
监听 `ReceiveNotification` 事件,收到到推送的时候会回调
36+
```
37+
var subscription = NativeAppEventEmitter.addListener(
38+
'ReceiveNotification',
39+
(notification) => console.log(notification)
40+
);
41+
```
42+
43+
监听 `OpenNotificationToLaunchApp` 事件,点击推送**启动 App **的时候会触发这个事件
44+
45+
```
46+
var subscription = NativeAppEventEmitter.addListener(
47+
'OpenNotificationToLaunchApp',
48+
(notification) => console.log(notification)
49+
);
50+
```
51+
52+
53+
54+
监听 `OpenNotification` 事件,点击推送的时候会执行这个回调(注意:iOS10 才开始触发这个事件)
55+
56+
```
57+
var subscription = NativeAppEventEmitter.addListener(
58+
'OpenNotification',
59+
(notification) => console.log(notification)
60+
);
61+
```
62+
63+
监听 `networkDidReceiveMessage` 事件,收到 JPush 应用内消息会执行这个回调
64+
```
65+
var subscription = NativeAppEventEmitter.addListener(
66+
'networkDidReceiveMessage',
67+
(message) => console.log(message)
68+
);
69+
```

ios/RCTJPushModule/RCTJPushModule/RCTJPushModule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
#define kJPFDidReceiveRemoteNotification @"kJPFDidReceiveRemoteNotification"
2222

23-
#define kJPFOpenNotification @"kJPFOpenNotification" // 通过点击通知 Notification 启动应用
23+
#define kJPFOpenNotification @"kJPFOpenNotification" // 通过点击通知事件
24+
#define kJPFOpenNotificationToLaunchApp @"kJPFOpenNotificationToLaunchApp" // 通过点击通知启动应用
2425

2526
@interface RCTJPushModule : NSObject <RCTBridgeModule>
2627
@property(strong,nonatomic)RCTResponseSenderBlock asyCallback;

ios/RCTJPushModule/RCTJPushModule/RCTJPushModule.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ - (id)init {
8686
name:kJPFOpenNotification
8787
object:nil];
8888

89+
[defaultCenter addObserver:self
90+
selector:@selector(openNotificationToLaunchApp:)
91+
name:kJPFOpenNotificationToLaunchApp
92+
object:nil];
93+
94+
if ([RCTJPushActionQueue sharedInstance].openedLocalNotification != nil) {
95+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
96+
}
97+
8998
return self;
9099
}
91100

@@ -94,11 +103,11 @@ - (void)reactJSDidload {
94103
[[RCTJPushActionQueue sharedInstance] scheduleNotificationQueue];
95104

96105
if ([RCTJPushActionQueue sharedInstance].openedRemoteNotification != nil) {
97-
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:[RCTJPushActionQueue sharedInstance].openedRemoteNotification];
106+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedRemoteNotification];
98107
}
99108

100109
if ([RCTJPushActionQueue sharedInstance].openedLocalNotification != nil) {
101-
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
110+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
102111
}
103112

104113
}
@@ -126,6 +135,11 @@ - (void)setBridge:(RCTBridge *)bridge {
126135
}
127136
}
128137

138+
- (void)openNotificationToLaunchApp:(NSNotification *)notification {
139+
id obj = [notification object];
140+
[self.bridge.eventDispatcher sendAppEventWithName:@"OpenNotificationToLaunchApp" body:obj];
141+
}
142+
129143
- (void)openNotification:(NSNotification *)notification {
130144
id obj = [notification object];
131145
[self.bridge.eventDispatcher sendAppEventWithName:@"OpenNotification" body:obj];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jpush-react-native",
3-
"version": "1.6.7",
3+
"version": "1.7.0",
44
"description": "a jpush plugin for react native application",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)