Skip to content

Commit 101dcaf

Browse files
authored
Merge pull request #111 from channel-io/develop
0.7.12
2 parents e83e986 + 19aca42 commit 101dcaf

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 0.7.12
2+
3+
## Update
4+
* support android channel-io 10.0.9
5+
6+
## Bug Fixes
7+
* Android - Fixed an error in isChannelPushNotification.
8+
19
# 0.7.11
210

311
## Update

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ repositories {
5555

5656
dependencies {
5757
implementation 'com.facebook.react:react-native'
58-
api 'io.channel:plugin-android:10.0.8'
58+
api 'io.channel:plugin-android:10.0.9'
5959
}

android/src/main/java/com/zoyi/channel/rn/ParseUtils.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ public static Map<String, Object> toHashMap(ReadableMap readableMap) {
113113
break;
114114

115115
case Number:
116-
hashMap.put(key, Utils.getDouble(readableMap, key).getValue());
116+
try {
117+
int number = readableMap.getInt(key);
118+
hashMap.put(key, number);
119+
} catch (Exception e) {
120+
double number = readableMap.getDouble(key);
121+
hashMap.put(key, number);
122+
}
123+
117124
break;
118125

119126
case String:
@@ -380,16 +387,40 @@ public static UserData toUserData(ReadableMap userDataMap) {
380387
}
381388

382389
public static Map<String, String> toPushNotification(ReadableMap pushNotificationMap) {
383-
Map<String, String> pushNotification = new HashMap<>();
390+
HashMap<String, String> pushNotification = new HashMap<>();
384391
ReadableMapKeySetIterator iterator = pushNotificationMap.keySetIterator();
385392

386393
while (iterator.hasNextKey()) {
387394
String key = iterator.nextKey();
388395
ReadableType type = pushNotificationMap.getType(key);
389-
String value = pushNotificationMap.getString(key);
390396

391-
if (type == ReadableType.String && value != null) {
392-
pushNotification.put(key, value);
397+
switch (type) {
398+
case Boolean:
399+
boolean bool = pushNotificationMap.getBoolean(key);
400+
pushNotification.put(key, Boolean.toString(bool));
401+
break;
402+
403+
case Number:
404+
try {
405+
int number = pushNotificationMap.getInt(key);
406+
pushNotification.put(key, Integer.toString(number));
407+
} catch (Exception e) {
408+
double number = pushNotificationMap.getDouble(key);
409+
pushNotification.put(key, Double.toString(number));
410+
}
411+
412+
break;
413+
414+
case String:
415+
String str = pushNotificationMap.getString(key);
416+
417+
if (str != null) {
418+
pushNotification.put(key, str);
419+
}
420+
break;
421+
422+
default:
423+
break;
393424
}
394425
}
395426

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-channel-plugin",
3-
"version": "0.7.11",
3+
"version": "0.7.12",
44
"description": "react native module for channel io",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)