Skip to content

Commit 11c7103

Browse files
authored
Merge pull request #301 from jpush/dev
Dev
2 parents 15afcc8 + 351904d commit 11c7103

File tree

10 files changed

+75
-36
lines changed

10 files changed

+75
-36
lines changed

android/src/main/java/cn/jpush/reactnativejpush/JPushModule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public void onCatalystInstanceDestroy() {
7878
mCachedBundle = null;
7979
if (null != sCacheMap) {
8080
sCacheMap.clear();
81-
sCacheMap = null;
8281
}
8382
}
8483

android/src/main/java/cn/jpush/reactnativejpush/JPushPackage.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cn.jpush.reactnativejpush;
22

33
import com.facebook.react.ReactPackage;
4-
import com.facebook.react.bridge.JavaScriptModule;
54
import com.facebook.react.bridge.NativeModule;
65
import com.facebook.react.bridge.ReactApplicationContext;
76
import com.facebook.react.uimanager.ViewManager;
@@ -24,11 +23,6 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
2423
});
2524
}
2625

27-
@Override
28-
public List<Class<? extends JavaScriptModule>> createJSModules() {
29-
return Collections.emptyList();
30-
}
31-
3226
@Override
3327
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
3428
return Collections.emptyList();

example/.flowconfig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ node_modules/react-native/flow
2222
flow/
2323

2424
[options]
25-
emoji=true
26-
2725
module.system=haste
2826

2927
experimental.strict_type_args=true
@@ -36,11 +34,11 @@ suppress_type=$FlowIssue
3634
suppress_type=$FlowFixMe
3735
suppress_type=$FixMe
3836

39-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
40-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
37+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-7]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
4139
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4240

4341
unsafe.enable_getters_and_setters=true
4442

4543
[version]
46-
^0.38.0
44+
^0.37.0

example/.gitignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,33 @@ DerivedData
2222
*.xcuserstate
2323
project.xcworkspace
2424

25-
# Android/IJ
25+
# Android/IntelliJ
2626
#
27+
build/
2728
.idea
2829
.gradle
2930
local.properties
31+
*.iml
3032

3133
# node.js
3234
#
3335
node_modules/
3436
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
android/app/libs
43+
*.keystore
44+
45+
# fastlane
46+
#
47+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48+
# screenshots whenever they are needed.
49+
# For more information about the recommended setup visit:
50+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51+
52+
fastlane/report.xml
53+
fastlane/Preview.html
54+
fastlane/screenshots

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ dependencies {
145145
compile project(':jpush-react-native')
146146
compile project(':jcore-react-native')
147147
compile "com.android.support:appcompat-v7:25.3.1"
148-
compile "com.facebook.react:react-native:+" // From node_modules
148+
compile "com.facebook.react:react-native:0.47.1" // From node_modules
149149
}
150150

151151
// Run this once to be able to run the application with BUCK

example/app.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "PushDemo",
3+
"displayName": "PushDemo"
4+
}

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"dependencies": {
1010
"jcore-react-native": "^1.1.5",
1111
"jpush-react-native": "^1.7.1",
12-
"react": "^15.4.0",
13-
"react-native": "^0.41.2",
12+
"react": "^16.0.0-alpha.12",
13+
"react-native": "^0.47.1",
1414
"react-native-onesignal": "^3.0.4",
1515
"react-navigation": "^1.0.0-beta.11"
1616
},

example/react-native-iOS/push_activity.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,12 @@ var PushActivity = React.createClass({
4747
this.props.navigator.push({ name:'LocalPushActivity' });
4848
},
4949
componentWillMount() {
50-
51-
// NativeAppEventEmitter.addListener('networkDidSetup', (token) => {
52-
// this.setState({ connectStatus: '已连接' });
53-
// });
54-
// NativeAppEventEmitter.addListener('networkDidClose', (token) => {
55-
// this.setState({ connectStatus: '连接已断开' });
56-
// });
57-
// NativeAppEventEmitter.addListener('networkDidRegister', (token) => {
58-
// this.setState({ connectStatus: '已注册' });
59-
// });
60-
// NativeAppEventEmitter.addListener('networkDidLogin', (token) => {
61-
// this.setState({ connectStatus: '已登陆' });
62-
// });
6350
JPushModule.addnetworkDidLoginListener(() => {
6451
Alert.alert('连接已登录')
52+
53+
JPushModule.addTags(['dasffas'], (result)=> {
54+
Alert.alert('addTags success:' + JSON.stringify(result))
55+
})
6556
})
6657

6758
JPushModule.addConnectionChangeListener((result) => {
@@ -71,11 +62,10 @@ var PushActivity = React.createClass({
7162
Alert.alert('网络已断开')
7263
}
7364
})
74-
var subscription = NativeAppEventEmitter.addListener(
75-
'ReceiveNotification',
76-
(notification) => console.log(notification)
77-
);
7865

66+
JPushModule.addReceiveNotificationListener((notification) => {
67+
Alert.alert(JSON.stringify(notification))
68+
})
7969
},
8070
componentDidMount() {
8171

ios/RCTJPushModule/RCTJPushModule.m

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,20 @@ + (id)allocWithZone:(NSZone *)zone {
5050

5151
- (id)init {
5252
self = [super init];
53-
5453
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
5554

5655
[defaultCenter removeObserver:self];
56+
57+
58+
[defaultCenter addObserver:self
59+
selector:@selector(networkConnecting:)
60+
name:kJPFNetworkIsConnectingNotification
61+
object:nil];
62+
63+
[defaultCenter addObserver:self
64+
selector:@selector(networkRegister:)
65+
name:kJPFNetworkDidRegisterNotification
66+
object:nil];
5767

5868
[defaultCenter addObserver:self
5969
selector:@selector(networkDidSetup:)
@@ -110,6 +120,12 @@ - (void)reactJSDidload {
110120
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
111121
}
112122

123+
if (_isJPushDidLogin) {
124+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFNetworkDidLoginNotification object:nil];
125+
} else {
126+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFNetworkDidCloseNotification object:nil];
127+
}
128+
113129
}
114130

115131
- (void)setBridge:(RCTBridge *)bridge {
@@ -144,22 +160,40 @@ - (void)openNotification:(NSNotification *)notification {
144160
[self.bridge.eventDispatcher sendAppEventWithName:@"openNotification" body:obj];
145161
}
146162

163+
164+
- (void)networkConnecting:(NSNotification *)notification {
165+
_isJPushDidLogin = false;
166+
[self.bridge.eventDispatcher sendAppEventWithName:@"connectionChange"
167+
body:@(false)];
168+
}
169+
170+
- (void)networkRegister:(NSNotification *)notification {
171+
_isJPushDidLogin = false;
172+
[self.bridge.eventDispatcher sendAppEventWithName:@"connectionChange"
173+
body:@(false)];
174+
}
175+
147176
- (void)networkDidSetup:(NSNotification *)notification {
177+
_isJPushDidLogin = false;
148178
[self.bridge.eventDispatcher sendAppEventWithName:@"connectionChange"
149179
body:@(true)];
150180
}
151181

152182
- (void)networkDidClose:(NSNotification *)notification {
183+
_isJPushDidLogin = false;
153184
[self.bridge.eventDispatcher sendAppEventWithName:@"connectionChange"
154-
body:@(true)];
185+
body:@(false)];
155186
}
156187

157188

158189
- (void)networkDidLogin:(NSNotification *)notification {
159190
_isJPushDidLogin = YES;
160191
[[RCTJPushActionQueue sharedInstance] scheduleGetRidCallbacks];
192+
// [self.bridge.eventDispatcher sendAppEventWithName:@"connectionChange"
193+
// body:@(true)];
161194
[self.bridge.eventDispatcher sendAppEventWithName:@"networkDidLogin"
162195
body:nil];
196+
163197
}
164198

165199
- (void)networkDidReceiveMessage:(NSNotification *)notification {

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": "2.0.0",
3+
"version": "2.0.1",
44
"description": "a jpush plugin for react native application",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)