Skip to content

Commit 38fc2be

Browse files
huangminlinuxarniu
authored andcommitted
fix ios demo
1 parent abc94e0 commit 38fc2be

File tree

25 files changed

+565
-312
lines changed

25 files changed

+565
-312
lines changed

example/App.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import React, { Component } from 'react'
77
import {
8+
Alert,
9+
Platform,
810
ScrollView,
911
StyleSheet,
1012
Text,
@@ -141,8 +143,8 @@ export default class App extends Component {
141143
})
142144
}
143145

144-
cleanAllTags = () => {
145-
JPushModule.cleanAllTags(map => {
146+
cleanTags = () => {
147+
JPushModule.cleanTags(map => {
146148
if (map.errorCode === 0) {
147149
console.log('Clean all tags succeed')
148150
} else {
@@ -185,48 +187,62 @@ export default class App extends Component {
185187
}
186188

187189
setBaseStyle () {
188-
JPushModule.setStyleBasic()
190+
if (Platform.OS === 'android') {
191+
JPushModule.setStyleBasic()
192+
} else {
193+
Alert.alert('iOS not support this function', '')
194+
}
189195
}
190196

191197
setCustomStyle () {
192-
JPushModule.setStyleCustom()
198+
if (Platform.OS === 'android') {
199+
JPushModule.setStyleCustom()
200+
} else {
201+
Alert.alert('iOS not support this function', '')
202+
}
193203
}
194204

195205
componentWillMount () {}
196206

197207
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+
})
206218
})
207-
})
208-
JPushModule.notifyJSDidLoad(resultCode => {
209-
if (resultCode === 0) {
210-
}
211-
})
219+
JPushModule.notifyJSDidLoad(resultCode => {
220+
if (resultCode === 0) {
221+
}
222+
})
223+
}
224+
212225
JPushModule.addReceiveCustomMsgListener(map => {
213226
this.setState({
214227
pushMsg: map.message
215228
})
216229
console.log('extras: ' + map.extras)
217230
})
231+
218232
JPushModule.addReceiveNotificationListener(map => {
219233
console.log('alertContent: ' + map.alertContent)
220234
console.log('extras: ' + map.extras)
221235
// var extra = JSON.parse(map.extras);
222236
// console.log(extra.key + ": " + extra.value);
223237
})
238+
224239
JPushModule.addReceiveOpenNotificationListener(map => {
225240
console.log('Opening notification!')
226241
console.log('map.extra: ' + map.extras)
227242
this.jumpSecondActivity()
228243
// JPushModule.jumpToPushActivity("SecondActivity");
229244
})
245+
230246
JPushModule.addGetRegistrationIdListener(registrationId => {
231247
console.log('Device register succeed, registrationId ' + registrationId)
232248
})
@@ -437,9 +453,9 @@ export default class App extends Component {
437453
underlayColor='#0866d9'
438454
activeOpacity={0.5}
439455
style={styles.bigBtn}
440-
onPress={this.cleanAllTags}
456+
onPress={this.cleanTags}
441457
>
442-
<Text style={styles.bigTextStyle}>Clean All Tags</Text>
458+
<Text style={styles.bigTextStyle}>Clean Tags</Text>
443459
</TouchableHighlight>
444460
</View>
445461
<View style={styles.title}>

example/android/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import com.android.build.OutputFile
7373
*/
7474

7575
project.ext.react = [
76-
entryFile: "index.js"
76+
entryFile: "index.js"
7777
]
7878

7979
apply from: "../../node_modules/react-native/react.gradle"
@@ -107,8 +107,8 @@ android {
107107
abiFilters "armeabi-v7a", "x86"
108108
}
109109
manifestPlaceholders = [
110-
JPUSH_APPKEY: "d4ee2375846bc30fa51334f5", //在此替换你的APPKey
111-
APP_CHANNEL : "developer-default" //应用渠道号
110+
JPUSH_APPKEY: "d4ee2375846bc30fa51334f5", //在此替换你的APPKey
111+
APP_CHANNEL : "developer-default" //应用渠道号
112112
]
113113
}
114114
splits {
@@ -130,7 +130,7 @@ android {
130130
variant.outputs.each { output ->
131131
// For each separate APK per architecture, set a unique version code as described here:
132132
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
133-
def versionCodes = ["armeabi-v7a":1, "x86":2]
133+
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
134134
def abi = output.getFilter(OutputFile.ABI)
135135
if (abi != null) { // null for the universal-debug, universal-release variants
136136
output.versionCodeOverride =

example/android/app/src/main/java/com/pushdemo/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected void onCreate(Bundle savedInstanceState) {
4848

4949
@Override
5050
protected String getMainComponentName() {
51-
return "example";
51+
return "PushDemo";
5252
}
5353

5454
@Override
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
<string name="app_name">example</string>
2+
<string name="app_name">PushDemo</string>
33
</resources>

example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
rootProject.name = 'example'
1+
rootProject.name = 'PushDemo'
22
include ':app', ':jpush-react-native', ':jcore-react-native'
33
project(':jpush-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jpush-react-native/android')
44
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')

example/app.json

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

example/documents/APIs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ reset tags.
130130
badge: 8,
131131
sound: 'fasdfa',
132132
subtitle: 'subtitle',
133-
title: 'title',
133+
title: 'title'
134134
})
135135
```
136136

example/documents/APIs_zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ JPushModule.stopPush();
161161
badge: 8,
162162
sound: 'fasdfa',
163163
subtitle: 'subtitle',
164-
title: 'title',
164+
title: 'title'
165165
})
166166
```
167167

example/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StackNavigator } from 'react-navigation'
33
import Second from './Second'
44
import App from './App'
55

6-
const PushDemoApp = StackNavigator({
6+
const PushDemo = StackNavigator({
77
Home: {
88
screen: App
99
},
@@ -12,4 +12,4 @@ const PushDemoApp = StackNavigator({
1212
}
1313
})
1414

15-
AppRegistry.registerComponent('example', () => PushDemoApp)
15+
AppRegistry.registerComponent('PushDemo', () => PushDemo)

0 commit comments

Comments
 (0)