|
5 | 5 |
|
6 | 6 | import React, { Component } from 'react' |
7 | 7 | import { |
| 8 | + Alert, |
| 9 | + Platform, |
8 | 10 | ScrollView, |
9 | 11 | StyleSheet, |
10 | 12 | Text, |
@@ -141,8 +143,8 @@ export default class App extends Component { |
141 | 143 | }) |
142 | 144 | } |
143 | 145 |
|
144 | | - cleanAllTags = () => { |
145 | | - JPushModule.cleanAllTags(map => { |
| 146 | + cleanTags = () => { |
| 147 | + JPushModule.cleanTags(map => { |
146 | 148 | if (map.errorCode === 0) { |
147 | 149 | console.log('Clean all tags succeed') |
148 | 150 | } else { |
@@ -185,48 +187,62 @@ export default class App extends Component { |
185 | 187 | } |
186 | 188 |
|
187 | 189 | setBaseStyle () { |
188 | | - JPushModule.setStyleBasic() |
| 190 | + if (Platform.OS === 'android') { |
| 191 | + JPushModule.setStyleBasic() |
| 192 | + } else { |
| 193 | + Alert.alert('iOS not support this function', '') |
| 194 | + } |
189 | 195 | } |
190 | 196 |
|
191 | 197 | setCustomStyle () { |
192 | | - JPushModule.setStyleCustom() |
| 198 | + if (Platform.OS === 'android') { |
| 199 | + JPushModule.setStyleCustom() |
| 200 | + } else { |
| 201 | + Alert.alert('iOS not support this function', '') |
| 202 | + } |
193 | 203 | } |
194 | 204 |
|
195 | 205 | componentWillMount () {} |
196 | 206 |
|
197 | 207 | componentDidMount () { |
198 | | - JPushModule.initPush() |
199 | | - JPushModule.getInfo(map => { |
200 | | - this.setState({ |
201 | | - appkey: map.myAppKey, |
202 | | - imei: map.myImei, |
203 | | - package: map.myPackageName, |
204 | | - deviceId: map.myDeviceId, |
205 | | - version: map.myVersion |
| 208 | + if (Platform.OS === 'android') { |
| 209 | + JPushModule.initPush() |
| 210 | + JPushModule.getInfo(map => { |
| 211 | + this.setState({ |
| 212 | + appkey: map.myAppKey, |
| 213 | + imei: map.myImei, |
| 214 | + package: map.myPackageName, |
| 215 | + deviceId: map.myDeviceId, |
| 216 | + version: map.myVersion |
| 217 | + }) |
206 | 218 | }) |
207 | | - }) |
208 | | - JPushModule.notifyJSDidLoad(resultCode => { |
209 | | - if (resultCode === 0) { |
210 | | - } |
211 | | - }) |
| 219 | + JPushModule.notifyJSDidLoad(resultCode => { |
| 220 | + if (resultCode === 0) { |
| 221 | + } |
| 222 | + }) |
| 223 | + } |
| 224 | + |
212 | 225 | JPushModule.addReceiveCustomMsgListener(map => { |
213 | 226 | this.setState({ |
214 | 227 | pushMsg: map.message |
215 | 228 | }) |
216 | 229 | console.log('extras: ' + map.extras) |
217 | 230 | }) |
| 231 | + |
218 | 232 | JPushModule.addReceiveNotificationListener(map => { |
219 | 233 | console.log('alertContent: ' + map.alertContent) |
220 | 234 | console.log('extras: ' + map.extras) |
221 | 235 | // var extra = JSON.parse(map.extras); |
222 | 236 | // console.log(extra.key + ": " + extra.value); |
223 | 237 | }) |
| 238 | + |
224 | 239 | JPushModule.addReceiveOpenNotificationListener(map => { |
225 | 240 | console.log('Opening notification!') |
226 | 241 | console.log('map.extra: ' + map.extras) |
227 | 242 | this.jumpSecondActivity() |
228 | 243 | // JPushModule.jumpToPushActivity("SecondActivity"); |
229 | 244 | }) |
| 245 | + |
230 | 246 | JPushModule.addGetRegistrationIdListener(registrationId => { |
231 | 247 | console.log('Device register succeed, registrationId ' + registrationId) |
232 | 248 | }) |
@@ -437,9 +453,9 @@ export default class App extends Component { |
437 | 453 | underlayColor='#0866d9' |
438 | 454 | activeOpacity={0.5} |
439 | 455 | style={styles.bigBtn} |
440 | | - onPress={this.cleanAllTags} |
| 456 | + onPress={this.cleanTags} |
441 | 457 | > |
442 | | - <Text style={styles.bigTextStyle}>Clean All Tags</Text> |
| 458 | + <Text style={styles.bigTextStyle}>Clean Tags</Text> |
443 | 459 | </TouchableHighlight> |
444 | 460 | </View> |
445 | 461 | <View style={styles.title}> |
|
0 commit comments