Skip to content

Commit 0216591

Browse files
committed
udpate demo adapt to rn-50.3
1 parent 6823195 commit 0216591

File tree

11 files changed

+223
-236
lines changed

11 files changed

+223
-236
lines changed

example/.flowconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ suppress_type=$FlowIssue
3434
suppress_type=$FlowFixMe
3535
suppress_type=$FixMe
3636

37+
<<<<<<< ours
3738
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
3839
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]+
40+
=======
41+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
42+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
43+
>>>>>>> theirs
3944
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4045

4146
unsafe.enable_getters_and_setters=true
4247

4348
[version]
49+
<<<<<<< ours
4450
^0.37.0
51+
=======
52+
^0.56.0
53+
>>>>>>> theirs

example/index.ios.js

Lines changed: 15 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,28 @@
22

33

44
import React from 'react';
5-
import ReactNative from 'react-native';
5+
import {
6+
AppRegistry,
7+
} from 'react-native';
8+
9+
import {
10+
StackNavigator
11+
} from 'react-navigation';
612

713
var PushActivity = require('./react-native-iOS/push_activity.js');
814
var SetActivity = require('./react-native-iOS/set_activity');
915
var LocalPushActivity = require('./react-native-iOS/localPush_activity');
1016

11-
var {
12-
Text,
13-
TextInput,
14-
View,
15-
Navigator,
16-
BackAndroid,
17-
NativeModules,
18-
StyleSheet,
19-
AppRegistry
20-
} = ReactNative;
21-
22-
var PushDemo = React.createClass({
23-
24-
configureScene(route) {
25-
return Navigator.SceneConfigs.FloatFromRight;
17+
const PushDemo = StackNavigator({
18+
Home: {
19+
screen: PushActivity
2620
},
27-
28-
renderScene(router, navigator) {
29-
var Component = null;
30-
this._navigator = navigator;
31-
switch(router.name) {
32-
case "pushActivity":
33-
Component = PushActivity;
34-
break;
35-
case "setActivity":
36-
Component = SetActivity;
37-
break;
38-
case "LocalPushActivity":
39-
Component = LocalPushActivity;
40-
break;
41-
}
42-
return <Component navigator = { navigator } />
43-
},
44-
45-
render() {
46-
return (
47-
<Navigator
48-
initialRoute = { {name: 'pushActivity' }}
49-
configureScene = { this.configureScene }
50-
renderScene = { this.renderScene } />
51-
);
52-
}
53-
});
54-
55-
56-
var styles = StyleSheet.create({
57-
58-
// For the container View
59-
parent: {
60-
padding: 16
61-
},
62-
63-
backBtnStyle: {
64-
borderWidth: 1,
65-
borderColor: '#3f80dc',
66-
borderRadius: 5
67-
},
68-
69-
backBtnText: {
70-
textAlign: 'center',
71-
fontSize: 25,
72-
color: '#ffffff'
73-
},
74-
buttonStyle: {
75-
marginTop: 15,
76-
padding: 5,
77-
borderWidth: 1,
78-
borderColor: '#48bbec',
79-
borderRadius: 8,
80-
justifyContent:'center',
81-
alignSelf:'stretch',
82-
flexDirection: 'row',
83-
backgroundColor:'#48bbec'
84-
21+
Setting: {
22+
screen: SetActivity
8523
},
86-
buttonText: {
87-
fontSize: 25,
88-
color: '#ffffff',
24+
LocalPush: {
25+
screen: LocalPushActivity
8926
}
90-
});
27+
})
9128

9229
AppRegistry.registerComponent('PushDemo', () => PushDemo);

example/ios/PushDemo.xcodeproj/project.pbxproj

Lines changed: 116 additions & 18 deletions
Large diffs are not rendered by default.

example/ios/PushDemo/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3131
// jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
3232

3333
// jsCodeLocation = [NSURL URLWithString:@"http://192.168.8.185:8081/index.ios.bundle?platform=ios&dev=true"];
34-
jsCodeLocation = [NSURL URLWithString:@"http://192.168.10.222:8081/index.ios.bundle?platform=ios&dev=true"];
34+
jsCodeLocation = [NSURL URLWithString:@"http://192.168.9.251:8081/index.ios.bundle?platform=ios&dev=true"];
3535
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
3636
moduleName:@"PushDemo"
3737
initialProperties:nil
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

example/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"start": "node node_modules/react-native/local-cli/cli.js start"
88
},
99
"dependencies": {
10-
"jcore-react-native": "^1.2.0",
11-
"jpush-react-native": "^2.1.2",
12-
"react": "^16.0.0-alpha.12",
13-
"react-native": "^0.47.1",
10+
"jcore-react-native": "^1.2.2",
11+
"jpush-react-native": "^2.1.3",
12+
"react": "^16.0.0",
13+
"react-native": "^0.50.3",
1414
"react-native-onesignal": "^3.0.4",
15-
"react-navigation": "^1.0.0-beta.11"
15+
"react-navigation": "^1.0.0-beta.21"
1616
},
1717
"devDependencies": {
1818
"babel-core": "^6.23.1",

example/react-native-iOS/localPush_activity.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import React from 'react';
3+
import React, { Component } from 'react';
44
import ReactNative from 'react-native';
55

66
var PushActivity = require('./push_activity');
@@ -20,28 +20,22 @@ const {
2020
} = ReactNative;
2121
import JPushModule from 'jpush-react-native';
2222

23-
var LocalPushActivity = React.createClass({
24-
getDefaultProps: function () {
25-
return {
26-
date: new Date(),
27-
timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60,
28-
29-
};
30-
},
31-
32-
getInitialState: function() {
33-
return {
34-
date: this.props.date,
35-
timeZoneOffsetInHours: this.props.timeZoneOffsetInHours,
36-
textContain: '',
37-
butonTitle: '',
38-
};
39-
},
40-
onDateChange: function(date) {
23+
export default class LocalPushActivity extends Component {
24+
constructor(props) {
25+
super(props);
26+
this.state = {
27+
date: new Date(),
28+
timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60,
29+
textContain: '',
30+
butonTitle: '',
31+
};
32+
}
33+
34+
onDateChange(dateTime) {
4135
console.log('the date is change ');
4236
console.log(date.toString);
43-
this.setState({date: date});
44-
},
37+
this.setState({date: dateTime});
38+
}
4539

4640
addLocationNotification() {
4741
// setLocalNotification 和 sendLocalNotification 都可以触发本地推送,推荐使用 sendLocalNotification 方法。
@@ -64,7 +58,7 @@ var LocalPushActivity = React.createClass({
6458

6559

6660

67-
},
61+
}
6862

6963
render() {
7064
return (
@@ -115,7 +109,7 @@ var LocalPushActivity = React.createClass({
115109
)
116110
}
117111

118-
})
112+
}
119113

120114
var styles = StyleSheet.create({
121115
parent: {

example/react-native-iOS/push_activity.js

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
import React from 'react';
3+
import React, { Component } from 'react';
44
import ReactNative from 'react-native';
55

66
const {
@@ -18,36 +18,44 @@ const {
1818
Alert,
1919
} = ReactNative;
2020

21+
2122
import JPushModule from 'jpush-react-native';
23+
export default class PushActivity extends Component {
24+
25+
constructor(props) {
26+
super(props);
27+
28+
this.state = {
29+
bg: '#ffffff',
30+
regid: '',
31+
connectStatus: '',
32+
package: 'PackageName',
33+
deviceId: 'DeviceId',
34+
};
35+
36+
this.onInitPress = this.onInitPress.bind(this)
37+
}
2238

23-
var PushActivity = React.createClass({
24-
25-
getInitialState: function() {
26-
return {
27-
bg: '#ffffff',
28-
regid: '',
29-
connectStatus: '',
30-
package: 'PackageName',
31-
deviceId: 'DeviceId',
32-
};
33-
},
3439
jumpSetActivity() {
35-
this.props.navigator.push({ name:'setActivity' });
36-
},
40+
this.props.navigation.navigate('Setting')
41+
}
42+
3743
onInitPress() {
3844

3945
console.log('on click init push ');
4046
JPushModule.getRegistrationID((registrationid) => {
4147
console.log(registrationid);
4248
this.setState({regid: registrationid});
4349
});
44-
},
50+
}
4551
onSetuplocalNotificationPress() {
4652
this.props.navigator.push({ name:'LocalPushActivity' });
47-
},
53+
}
54+
4855
componentWillMount() {
4956

5057
JPushModule.setupPush() // if you add register notification in Appdelegate.m 有 don't need call this function
58+
JPushModule.getBadge((badge) => {Alert.alert("badge", badge)})
5159
JPushModule.addnetworkDidLoginListener(() => {
5260
console.log('连接已登录')
5361
JPushModule.addTags(['dasffas'], (result)=> {
@@ -78,14 +86,14 @@ var PushActivity = React.createClass({
7886
// JPushModule.addReceiveNotificationListener((notification) => {
7987
// Alert.alert(JSON.stringify(notification))
8088
// })
81-
},
89+
}
8290
componentDidMount() {
8391

84-
},
92+
}
8593
componentWillUnmount() {
8694
DeviceEventEmitter.removeAllListeners();
8795
NativeAppEventEmitter.removeAllListeners();
88-
},
96+
}
8997
render() {
9098

9199
return (
@@ -107,7 +115,7 @@ var PushActivity = React.createClass({
107115
underlayColor = '#0866d9'
108116
activeOpacity = { 0.5 }
109117
style = { styles.btnStyle }
110-
onPress = { this.jumpSetActivity }>
118+
onPress = { () => { this.props.navigation.navigate("Setting")} }>
111119
<Text style = { styles.btnTextStyle }>
112120
设置
113121
</Text>
@@ -125,7 +133,7 @@ var PushActivity = React.createClass({
125133
underlayColor = '#e4083f'
126134
activeOpacity = { 0.5 }
127135
style = { styles.btnStyle }
128-
onPress = { this.onSetuplocalNotificationPress }>
136+
onPress = { () => {this.props.navigation.navigate("LocalPush")} }>
129137
<Text style = { styles.btnTextStyle }>
130138
local notification
131139
</Text>
@@ -134,7 +142,7 @@ var PushActivity = React.createClass({
134142

135143
)
136144
}
137-
});
145+
};
138146

139147
var styles = StyleSheet.create({
140148
parent: {
@@ -165,7 +173,7 @@ var styles = StyleSheet.create({
165173
borderColor: '#48bbec',
166174
borderWidth: 1,
167175

168-
},
176+
}
169177
});
170178

171179

0 commit comments

Comments
 (0)