Skip to content

Commit a5b7504

Browse files
authored
Merge pull request #22 from zoyi/develop
0.4.0
2 parents da45fc3 + ca30610 commit a5b7504

File tree

11 files changed

+48
-112
lines changed

11 files changed

+48
-112
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.4.0
2+
## Updates
3+
* Updated channeltalk plugin v7.0
4+
15
# 0.3.7
26
## Updates
37
* 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Const {
99

1010
// Boot
1111
public static final String KEY_PLUGIN_KEY = "pluginKey";
12-
public static final String KEY_USER_ID = "userId";
12+
public static final String KEY_MEMBER_ID = "memberId";
1313
public static final String KEY_LOCALE = "locale";
1414
public static final String KEY_DEBUG_MODE = "debugMode";
1515
public static final String KEY_ENABLED_TRACK_DEFAULT_EVENT = "enabledTrackDefaultEvent";

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

Lines changed: 14 additions & 26 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..
@@ -228,7 +216,7 @@ public static Profile toProfile(ReadableMap profileMap) {
228216

229217
public static ChannelPluginSettings toChannelPluginSettings(ReadableMap settingsMap) {
230218
String pluginKey = Utils.getString(settingsMap, Const.KEY_PLUGIN_KEY);
231-
String userId = Utils.getString(settingsMap, Const.KEY_USER_ID);
219+
String userId = Utils.getString(settingsMap, Const.KEY_MEMBER_ID);
232220
String locale = Utils.getString(settingsMap, Const.KEY_LOCALE);
233221

234222
boolean debugMode = Utils.getBoolean(settingsMap, Const.KEY_DEBUG_MODE, false);
@@ -239,7 +227,7 @@ public static ChannelPluginSettings toChannelPluginSettings(ReadableMap settings
239227
ReadableMap profile = Utils.getReadableMap(settingsMap, Const.KEY_PROFILE);
240228

241229
return new ChannelPluginSettings(pluginKey)
242-
.setUserId(userId)
230+
.setMemberId(userId)
243231
.setLocale(CHLocale.fromString(locale))
244232
.setDebugMode(debugMode)
245233
.setEnabledTrackDefaultEvent(enabledTrackDefaultEvent)
@@ -268,33 +256,33 @@ public static Map<String, String> toPushNotification(ReadableMap pushNotificatio
268256
public static WritableMap getBootResult(
269257
ChannelPluginListener listener,
270258
ChannelPluginCompletionStatus status,
271-
Guest guest) {
259+
User user) {
272260

273261
WritableMap result = Arguments.createMap();
274262

275263
if (status == ChannelPluginCompletionStatus.SUCCESS) {
276264
ChannelIO.setChannelPluginListener(listener);
277-
result.putMap(Const.KEY_GUEST, ParseUtils.guestToWritableMap(guest));
265+
result.putMap(Const.KEY_GUEST, ParseUtils.guestToWritableMap(user));
278266
}
279267

280268
result.putString(Const.KEY_STATUS, status.toString());
281269

282270
return result;
283271
}
284272

285-
public static WritableMap guestToWritableMap(Guest guest) {
273+
public static WritableMap guestToWritableMap(User user) {
286274
WritableMap guestMap = Arguments.createMap();
287275

288-
if (guest == null) {
276+
if (user == null) {
289277
return guestMap;
290278
}
291279

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());
280+
guestMap.putString(Const.KEY_ID, user.getId());
281+
guestMap.putString(Const.KEY_NAME, user.getName());
282+
guestMap.putString(Const.KEY_AVATAR_URL, user.getAvatarUrl());
283+
guestMap.putInt(Const.KEY_ALERT, user.getAlert());
296284

297-
Map<String, Object> profile = guest.getProfile();
285+
Map<String, Object> profile = user.getProfile();
298286
if (profile != null) {
299287
guestMap.putMap(Const.KEY_PROFILE, toWritableMap(profile));
300288
}

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

Lines changed: 10 additions & 20 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;
@@ -81,8 +77,8 @@ public void boot(ReadableMap settings, final Promise promise) {
8177
ParseUtils.toProfile(Utils.getReadableMap(settings, Const.KEY_PROFILE)),
8278
new OnBootListener() {
8379
@Override
84-
public void onCompletion(ChannelPluginCompletionStatus status, Guest guest) {
85-
promise.resolve(ParseUtils.getBootResult(RNChannelIO.this, status, guest));
80+
public void onCompletion(ChannelPluginCompletionStatus status, User user) {
81+
promise.resolve(ParseUtils.getBootResult(RNChannelIO.this, status, user));
8682
}
8783
});
8884
}
@@ -121,7 +117,7 @@ public void openChat(String chatId, boolean animated) {
121117
public void initPushToken(String tokenData) {
122118
Context context = getCurrentActivity();
123119

124-
if (context != null){
120+
if (context != null) {
125121
PrefSupervisor.setDeviceToken(context, tokenData);
126122
}
127123
}
@@ -130,7 +126,7 @@ public void initPushToken(String tokenData) {
130126
public void handlePushNotification(ReadableMap userInfo, Promise promise) {
131127
Context context = getCurrentActivity();
132128

133-
if (context != null){
129+
if (context != null) {
134130
ChannelIO.showPushNotification(context, ParseUtils.toPushNotification(userInfo));
135131
}
136132

@@ -141,7 +137,7 @@ public void handlePushNotification(ReadableMap userInfo, Promise promise) {
141137
public void handlePush() {
142138
Activity activity = getCurrentActivity();
143139

144-
if (activity != null){
140+
if (activity != null) {
145141
ChannelIO.handlePushNotification(activity);
146142
}
147143
}
@@ -196,18 +192,12 @@ public boolean onClickChatLink(String url) {
196192
return handleChatLink;
197193
}
198194

199-
@Override
200-
public boolean onClickRedirectUrl(String url) {
201-
Utils.sendEvent(reactContext, Const.EVENT_ON_CLICK_REDIRECT_LINK, ParseUtils.createSingleMap(Const.KEY_EVENT_LINK, url));
202-
return handleRedirectLink;
203-
}
204-
205195
@Override
206196
public void onChangeProfile(String key, Object value) {
207197
Utils.sendEvent(
208-
reactContext,
209-
Const.EVENT_ON_CHANGE_PROFILE,
210-
ParseUtils.createKeyValueMap(Const.KEY_PROFILE_KEY, key, Const.KEY_PROFILE_VALUE, value)
198+
reactContext,
199+
Const.EVENT_ON_CHANGE_PROFILE,
200+
ParseUtils.createKeyValueMap(Const.KEY_PROFILE_KEY, key, Const.KEY_PROFILE_VALUE, value)
211201
);
212202
}
213-
}
203+
}

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
21
package com.zoyi.channel.rn;
32

43
import android.content.Context;
5-
import android.util.Log;
6-
7-
import com.facebook.react.bridge.Arguments;
8-
import com.facebook.react.bridge.ReactContext;
9-
import com.facebook.react.bridge.ReadableArray;
10-
import com.facebook.react.bridge.ReadableMap;
11-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
12-
import com.facebook.react.bridge.ReadableType;
13-
import com.facebook.react.bridge.WritableArray;
14-
import com.facebook.react.bridge.WritableMap;
15-
import com.facebook.react.modules.core.DeviceEventManagerModule;
16-
import com.zoyi.channel.plugin.android.model.entity.Guest;
17-
import com.zoyi.channel.plugin.android.*;
18-
import com.zoyi.channel.plugin.android.global.*;
194

20-
import java.util.HashMap;
21-
import java.util.Iterator;
22-
import java.util.Map;
5+
import com.facebook.react.bridge.*;
6+
import com.facebook.react.modules.core.DeviceEventManagerModule;
7+
import com.zoyi.channel.plugin.android.global.PrefSupervisor;
238

249
/**
2510
* Created by mika on 2018. 9. 18..

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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ + (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+
settings.memberId = [RCTConvert NSString:json[@"memberId"]];
5858

59-
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;
59+
NSString *language = [RCTConvert NSString:json[@"language"]];
60+
if ([language isEqualToString:@"ko"]) {
61+
settings.language = CHLocaleKorean;
62+
} else if ([language isEqualToString:@"ja"]) {
63+
settings.language = CHLocaleJapanese;
64+
} else if ([language isEqualToString:@"en"]) {
65+
settings.language = CHLocaleEnglish;
6666
} else {
67-
settings.locale = CHLocaleDevice;
67+
settings.language = CHLocaleDevice;
6868
}
6969
return settings;
7070
}

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

ios/RNChannelIO.m

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ @implementation RNChannelIO
1818
{
1919
BOOL hasListeners;
2020
BOOL handleChatLink;
21-
BOOL handleRedirectLink;
2221
}
2322

2423
RCT_EXPORT_MODULE()
@@ -62,8 +61,7 @@ - (NSDictionary *)constantsToExport {
6261
@"ON_RECEIVE_PUSH": ON_RECEIVE_PUSH,
6362
@"WILL_SHOW_MESSENGER": WILL_SHOW_MESSENGER,
6463
@"WILL_HIDE_MESSENGER": WILL_HIDE_MESSENGER,
65-
@"ON_CLICK_CHAT_LINK": ON_CLICK_CHAT_LINK,
66-
@"ON_CLICK_REDIRECT_LINK": ON_CLICK_REDIRECT_LINK
64+
@"ON_CLICK_CHAT_LINK": ON_CLICK_CHAT_LINK
6765
},
6866
@"Locale": @{
6967
@"korean": @(CHLocaleKorean),
@@ -92,8 +90,7 @@ - (NSDictionary *)constantsToExport {
9290
ON_RECEIVE_PUSH,
9391
WILL_SHOW_MESSENGER,
9492
WILL_HIDE_MESSENGER,
95-
ON_CLICK_CHAT_LINK,
96-
ON_CLICK_REDIRECT_LINK
93+
ON_CLICK_CHAT_LINK
9794
];
9895
}
9996

@@ -103,8 +100,8 @@ - (NSDictionary *)constantsToExport {
103100
rejecter:(RCTPromiseRejectBlock)reject) {
104101
ChannelPluginSettings * pluginSettings = [RCTConvert settings:settings];
105102
Profile *userProfile = [RCTConvert profile:settings[@"profile"]];
106-
[ChannelIO bootWith:pluginSettings profile:userProfile completion:^(ChannelPluginCompletionStatus status, Guest *guest) {
107-
resolve(@{@"status": @(status), @"guest": guest != nil ? guest.toJson : NSNull.null });
103+
[ChannelIO bootWith:pluginSettings profile:userProfile completion:^(ChannelPluginCompletionStatus status, User *user) {
104+
resolve(@{@"status": @(status), @"user": user != nil ? user.toJson : NSNull.null });
108105
}];
109106
}
110107

@@ -168,10 +165,6 @@ - (NSDictionary *)constantsToExport {
168165
handleChatLink = handle;
169166
}
170167

171-
RCT_EXPORT_METHOD(setRedirectLinkHandle:(BOOL)handle) {
172-
handleRedirectLink = handle;
173-
}
174-
175168
#pragma mark ChannelPluginDelegate
176169

177170
- (void)onChangeBadgeWithCount:(NSInteger)count {
@@ -194,14 +187,6 @@ - (BOOL)onClickChatLinkWithUrl:(NSURL *)url {
194187
return handleChatLink;
195188
}
196189

197-
- (BOOL)onClickRedirectWithUrl:(NSURL *)url {
198-
if (hasListeners) {
199-
[self sendEventWithName:ON_CLICK_REDIRECT_LINK body:@{@"link": url.absoluteString}];
200-
return handleRedirectLink;
201-
}
202-
return handleRedirectLink;
203-
}
204-
205190
- (void)onChangeProfileWithKey:(NSString *)key value:(id)value {
206191
if (hasListeners) {
207192
[self sendEventWithName:ON_CHANGE_PROFILE body: @{@"key": key, @"value": value}];

0 commit comments

Comments
 (0)