Skip to content

Commit cc59b42

Browse files
authored
Merge pull request #31 from zoyi-jin/merge
merge master <-> develop
2 parents 3f726f3 + f168bfa commit cc59b42

File tree

133 files changed

+80
-35860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+80
-35860
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# 0.4.2
2+
## Bug fixes & support legacy
3+
# fix language bug
4+
# Legacy support - language / locale
5+
6+
# 0.4.1
7+
## Bug fixes
8+
* Android profile bug fixes
9+
* Legacy support - userId
10+
11+
# 0.4.0
12+
## Updates
13+
* Updated channeltalk plugin v7.0
14+
115
# 0.3.7
216
## Updates
317
* Updated ios target to 10.0 from 9.1

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 'com.zoyi.channel:plugin-android:6.1.+'
58+
api 'com.zoyi.channel:plugin-android:7.0.+'
5959
}

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
*/
66

77
public class Const {
8+
89
public static final String MODULE_NAME = "RNChannelIO";
910

1011
// Boot
1112
public static final String KEY_PLUGIN_KEY = "pluginKey";
13+
public static final String KEY_MEMBER_ID = "memberId";
1214
public static final String KEY_USER_ID = "userId";
1315
public static final String KEY_LOCALE = "locale";
16+
public static final String KEY_LANGUAGE = "language";
1417
public static final String KEY_DEBUG_MODE = "debugMode";
1518
public static final String KEY_ENABLED_TRACK_DEFAULT_EVENT = "enabledTrackDefaultEvent";
1619
public static final String KEY_HIDE_DEFAULT_IN_APP_PUSH = "hideDefaultInAppPush";
@@ -48,17 +51,6 @@ public class Const {
4851
public static final String LAUNCHER_RIGHT = "LauncherPositionRight";
4952
public static final String LAUNCHER_LEFT = "LauncherPositionLeft";
5053

51-
// Locale
52-
public static final String KEY_KOREAN = "korean";
53-
public static final String KEY_JAPANESE = "japanese";
54-
public static final String KEY_ENGLISH = "english";
55-
public static final String KEY_DEVICE = "device";
56-
57-
public static final String LOCALE_KOREAN = "CHLocaleKorean";
58-
public static final String LOCALE_JAPANESE = "CHLocaleJapanese";
59-
public static final String LOCALE_ENGLISH = "CHLocaleEnglish";
60-
public static final String LOCALE_DEVICE = "CHLocaleDevice";
61-
6254
// Boot Status
6355
public static final String BOOT_STATUS = "BootStatus";
6456

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

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
21
package com.zoyi.channel.rn;
32

4-
import com.facebook.react.bridge.Arguments;
5-
import com.facebook.react.bridge.ReadableArray;
6-
import com.facebook.react.bridge.ReadableMap;
7-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
8-
import com.facebook.react.bridge.ReadableType;
9-
import com.facebook.react.bridge.WritableArray;
10-
import com.facebook.react.bridge.WritableMap;
11-
12-
import com.zoyi.channel.plugin.android.model.etc.*;
3+
import com.facebook.react.bridge.*;
134
import com.zoyi.channel.plugin.android.*;
5+
import com.zoyi.channel.plugin.android.model.etc.PushEvent;
146
import com.zoyi.channel.react.android.Const;
157

16-
import java.util.ArrayList;
17-
import java.util.HashMap;
18-
import java.util.Iterator;
19-
import java.util.List;
20-
import java.util.Map;
8+
import java.util.*;
219

2210
/**
2311
* Created by jerry on 2018. 10. 11..
@@ -208,7 +196,7 @@ public static Profile toProfile(ReadableMap profileMap) {
208196
.setAvatarUrl(Utils.getString(profileMap, Const.KEY_AVATAR_URL));
209197

210198
Iterator propertyIterator = ParseUtils
211-
.toHashMap(Utils.getReadableMap(profileMap, Const.KEY_PROPERTY))
199+
.toHashMap(profileMap)
212200
.entrySet()
213201
.iterator();
214202

@@ -228,8 +216,13 @@ public static Profile toProfile(ReadableMap profileMap) {
228216

229217
public static ChannelPluginSettings toChannelPluginSettings(ReadableMap settingsMap) {
230218
String pluginKey = Utils.getString(settingsMap, Const.KEY_PLUGIN_KEY);
219+
String memberId = Utils.getString(settingsMap, Const.KEY_MEMBER_ID);
231220
String userId = Utils.getString(settingsMap, Const.KEY_USER_ID);
221+
222+
String id = memberId == null ? userId : memberId;
223+
232224
String locale = Utils.getString(settingsMap, Const.KEY_LOCALE);
225+
String language = Utils.getString(settingsMap, Const.KEY_LANGUAGE);
233226

234227
boolean debugMode = Utils.getBoolean(settingsMap, Const.KEY_DEBUG_MODE, false);
235228
boolean enabledTrackDefaultEvent = Utils.getBoolean(settingsMap, Const.KEY_ENABLED_TRACK_DEFAULT_EVENT, true);
@@ -239,8 +232,8 @@ public static ChannelPluginSettings toChannelPluginSettings(ReadableMap settings
239232
ReadableMap profile = Utils.getReadableMap(settingsMap, Const.KEY_PROFILE);
240233

241234
return new ChannelPluginSettings(pluginKey)
242-
.setUserId(userId)
243-
.setLocale(CHLocale.fromString(locale))
235+
.setMemberId(id)
236+
.setLocale(CHLocale.fromString(locale == null ? language : locale))
244237
.setDebugMode(debugMode)
245238
.setEnabledTrackDefaultEvent(enabledTrackDefaultEvent)
246239
.setHideDefaultInAppPush(hideDefaultInAppPush)
@@ -268,33 +261,33 @@ public static Map<String, String> toPushNotification(ReadableMap pushNotificatio
268261
public static WritableMap getBootResult(
269262
ChannelPluginListener listener,
270263
ChannelPluginCompletionStatus status,
271-
Guest guest) {
264+
User user) {
272265

273266
WritableMap result = Arguments.createMap();
274267

275268
if (status == ChannelPluginCompletionStatus.SUCCESS) {
276269
ChannelIO.setChannelPluginListener(listener);
277-
result.putMap(Const.KEY_GUEST, ParseUtils.guestToWritableMap(guest));
270+
result.putMap(Const.KEY_GUEST, ParseUtils.guestToWritableMap(user));
278271
}
279272

280273
result.putString(Const.KEY_STATUS, status.toString());
281274

282275
return result;
283276
}
284277

285-
public static WritableMap guestToWritableMap(Guest guest) {
278+
public static WritableMap guestToWritableMap(User user) {
286279
WritableMap guestMap = Arguments.createMap();
287280

288-
if (guest == null) {
281+
if (user == null) {
289282
return guestMap;
290283
}
291284

292-
guestMap.putString(Const.KEY_ID, guest.getId());
293-
guestMap.putString(Const.KEY_NAME, guest.getName());
294-
guestMap.putString(Const.KEY_AVATAR_URL, guest.getAvatarUrl());
295-
guestMap.putInt(Const.KEY_ALERT, guest.getAlert());
285+
guestMap.putString(Const.KEY_ID, user.getId());
286+
guestMap.putString(Const.KEY_NAME, user.getName());
287+
guestMap.putString(Const.KEY_AVATAR_URL, user.getAvatarUrl());
288+
guestMap.putInt(Const.KEY_ALERT, user.getAlert());
296289

297-
Map<String, Object> profile = guest.getProfile();
290+
Map<String, Object> profile = user.getProfile();
298291
if (profile != null) {
299292
guestMap.putMap(Const.KEY_PROFILE, toWritableMap(profile));
300293
}

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

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33

44
import android.app.Activity;
55
import android.content.Context;
6-
import android.widget.Toast;
76

87
import com.facebook.react.bridge.*;
98
import com.zoyi.channel.plugin.android.*;
10-
import com.zoyi.channel.plugin.android.global.*;
11-
12-
import com.facebook.react.bridge.ReadableMap;
9+
import com.zoyi.channel.plugin.android.global.PrefSupervisor;
1310
import com.zoyi.channel.plugin.android.model.etc.PushEvent;
14-
import com.zoyi.channel.react.android.*;
1511
import com.zoyi.channel.react.android.Const;
1612

1713
import java.util.HashMap;
@@ -51,11 +47,6 @@ public Map<String, Object> getConstants() {
5147
eventMap.put(Const.KEY_ON_CLICK_REDIRECT_LINK, Const.EVENT_ON_CLICK_REDIRECT_LINK);
5248
eventMap.put(Const.KEY_ON_CHANGE_PROFILE, Const.EVENT_ON_CHANGE_PROFILE);
5349

54-
localeMap.put(Const.KEY_KOREAN, Const.LOCALE_KOREAN);
55-
localeMap.put(Const.KEY_JAPANESE, Const.LOCALE_JAPANESE);
56-
localeMap.put(Const.KEY_ENGLISH, Const.LOCALE_ENGLISH);
57-
localeMap.put(Const.KEY_DEVICE, Const.LOCALE_DEVICE);
58-
5950
launcherPositionMap.put(Const.KEY_LAUNCHER_POSITION_RIGHT, Const.LAUNCHER_RIGHT);
6051
launcherPositionMap.put(Const.KEY_LAUNCHER_POSITION_LEFT, Const.LAUNCHER_LEFT);
6152

@@ -64,7 +55,6 @@ public Map<String, Object> getConstants() {
6455
bootStatusMap.put(Const.KEY_BOOT_ACCESS_DENIED, Const.BOOT_ACCESS_DENIED);
6556
bootStatusMap.put(Const.KEY_BOOT_NOT_INITIALIZED, Const.BOOT_NOT_INITIALIZED);
6657
bootStatusMap.put(Const.KEY_BOOT_REQUIRE_PAYMENT, Const.BOOT_REQUIRE_PAYMENT);
67-
bootStatusMap.put(Const.KEY_BOOT_NOT_INITIALIZED, Const.BOOT_NOT_INITIALIZED);
6858

6959
constants.put(Const.Event, eventMap);
7060
constants.put(Const.Locale, localeMap);
@@ -81,8 +71,8 @@ public void boot(ReadableMap settings, final Promise promise) {
8171
ParseUtils.toProfile(Utils.getReadableMap(settings, Const.KEY_PROFILE)),
8272
new OnBootListener() {
8373
@Override
84-
public void onCompletion(ChannelPluginCompletionStatus status, Guest guest) {
85-
promise.resolve(ParseUtils.getBootResult(RNChannelIO.this, status, guest));
74+
public void onCompletion(ChannelPluginCompletionStatus status, User user) {
75+
promise.resolve(ParseUtils.getBootResult(RNChannelIO.this, status, user));
8676
}
8777
});
8878
}
@@ -121,7 +111,7 @@ public void openChat(String chatId, boolean animated) {
121111
public void initPushToken(String tokenData) {
122112
Context context = getCurrentActivity();
123113

124-
if (context != null){
114+
if (context != null) {
125115
PrefSupervisor.setDeviceToken(context, tokenData);
126116
}
127117
}
@@ -131,9 +121,8 @@ public void handlePushNotification(ReadableMap userInfo, Promise promise) {
131121
if (reactContext != null) {
132122
Context context = reactContext.getApplicationContext();
133123

134-
if (context != null) {
135-
ChannelIO.showPushNotification(context, ParseUtils.toPushNotification(userInfo));
136-
}
124+
if (context != null) {
125+
ChannelIO.showPushNotification(context, ParseUtils.toPushNotification(userInfo));
137126
}
138127

139128
promise.resolve(true);
@@ -143,7 +132,7 @@ public void handlePushNotification(ReadableMap userInfo, Promise promise) {
143132
public void handlePush() {
144133
Activity activity = getCurrentActivity();
145134

146-
if (activity != null){
135+
if (activity != null) {
147136
ChannelIO.handlePushNotification(activity);
148137
}
149138
}
@@ -198,18 +187,12 @@ public boolean onClickChatLink(String url) {
198187
return handleChatLink;
199188
}
200189

201-
@Override
202-
public boolean onClickRedirectUrl(String url) {
203-
Utils.sendEvent(reactContext, Const.EVENT_ON_CLICK_REDIRECT_LINK, ParseUtils.createSingleMap(Const.KEY_EVENT_LINK, url));
204-
return handleRedirectLink;
205-
}
206-
207190
@Override
208191
public void onChangeProfile(String key, Object value) {
209192
Utils.sendEvent(
210-
reactContext,
211-
Const.EVENT_ON_CHANGE_PROFILE,
212-
ParseUtils.createKeyValueMap(Const.KEY_PROFILE_KEY, key, Const.KEY_PROFILE_VALUE, value)
193+
reactContext,
194+
Const.EVENT_ON_CHANGE_PROFILE,
195+
ParseUtils.createKeyValueMap(Const.KEY_PROFILE_KEY, key, Const.KEY_PROFILE_VALUE, value)
213196
);
214197
}
215-
}
198+
}

index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,6 @@ export const ChannelIO = {
151151
replaceListener(ChannelModule.Event.ON_CLICK_CHAT_LINK, subscription);
152152
},
153153

154-
/**
155-
* Event listener that triggers when a redirect on push bot link has been clicked by a user
156-
* @param {Boolean} handle True if you want to handle a link, otherwise false
157-
* @param {Function} cb a callback function that takes a string link as parameter
158-
*/
159-
onClickRedirectLink: (handle, cb) => {
160-
let subscription = ChannelModule.setRedirectLinkHandle(handle);
161-
ChannelEventEmitter.addListener(ChannelModule.Event.ON_CLICK_REDIRECT_LINK, (data) => {
162-
cb(data.link);
163-
});
164-
165-
replaceListener(ChannelModule.Event.ON_CLICK_REDIRECT_LINK, subscription);
166-
},
167-
168154
/**
169155
* Event listener that triggers when guest profile is updated
170156
* @param {Function} cb a callback function that takes a key, value
@@ -198,9 +184,8 @@ export const ChannelIO = {
198184
ON_CHANGE_BADGE: ChannelModule.Event.ON_CHANGE_BADGE,
199185
ON_RECEIVE_PUSH: ChannelModule.Event.ON_RECEIVE_PUSH,
200186
ON_CLICK_CHAT_LINK: ChannelModule.Event.ON_CLICK_CHAT_LINK,
201-
ON_CLICK_REDIRECT_LINK: ChannelModule.Event.ON_CLICK_REDIRECT_LINK,
202187
ON_CHANGE_PROFILE: ChannelModule.Event.ON_CHANGE_PROFILE,
203188
WILL_SHOW_MESSENGER: ChannelModule.Event.WILL_SHOW_MESSENGER,
204189
WILL_HIDE_MESSENGER: ChannelModule.Event.WILL_HIDE_MESSENGER
205190
}
206-
}
191+
}

ios/RCTConvert+ChannelIO.m

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,34 @@ + (ChannelPluginSettings *)settings:(id)json {
5454
settings.debugMode = [RCTConvert BOOL:json[@"debugMode"]];
5555
settings.hideDefaultInAppPush = [RCTConvert BOOL:json[@"hideDefaultInAppPush"]];
5656
settings.launcherConfig = [RCTConvert launcherConfig:json[@"launcherConfig"]];
57-
settings.userId = [RCTConvert NSString:json[@"userId"]];
57+
if ([json[@"memberId"] length] == 0 && [json[@"userId"] length] != 0) {
58+
settings.memberId = [RCTConvert NSString:json[@"userId"]];
59+
} else {
60+
settings.memberId = [RCTConvert NSString:json[@"memberId"]];
61+
}
5862

63+
NSString *language = [RCTConvert NSString:json[@"language"]];
5964
NSString *locale = [RCTConvert NSString:json[@"locale"]];
60-
if ([locale isEqualToString:@"ko"]) {
61-
settings.locale = CHLocaleKorean;
62-
} else if ([locale isEqualToString:@"ja"]) {
63-
settings.locale = CHLocaleJapanese;
64-
} else if ([locale isEqualToString:@"en"]) {
65-
settings.locale = CHLocaleEnglish;
65+
if (json[@"locale"] != 0) {
66+
if ([locale isEqualToString:@"ko"]) {
67+
settings.language = CHLocaleKorean;
68+
} else if ([locale isEqualToString:@"ja"]) {
69+
settings.language = CHLocaleJapanese;
70+
} else if ([locale isEqualToString:@"en"]) {
71+
settings.language = CHLocaleEnglish;
72+
} else {
73+
settings.language = CHLocaleDevice;
74+
}
6675
} else {
67-
settings.locale = CHLocaleDevice;
76+
if ([language isEqualToString:@"ko"]) {
77+
settings.language = CHLocaleKorean;
78+
} else if ([language isEqualToString:@"ja"]) {
79+
settings.language = CHLocaleJapanese;
80+
} else if ([language isEqualToString:@"en"]) {
81+
settings.language = CHLocaleEnglish;
82+
} else {
83+
settings.language = CHLocaleDevice;
84+
}
6885
}
6986
return settings;
7087
}

ios/RNChannelIO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ static NSString * const ON_RECEIVE_PUSH = @"ChannelIO:Event:OnReceivePush";
2222
static NSString * const WILL_SHOW_MESSENGER = @"ChannelIO:Event:WillShowMessenger";
2323
static NSString * const WILL_HIDE_MESSENGER = @"ChannelIO:Event:WillHideMessenger";
2424
static NSString * const ON_CLICK_CHAT_LINK = @"ChannelIO:Event:OnClickChatLink";
25-
static NSString * const ON_CLICK_REDIRECT_LINK = @"ChannelIO:Event:OnClickRedirectLink";
2625
static NSString * const ON_CHANGE_PROFILE = @"ChannelIO:Event:OnChangeProfile";
2726

2827
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)