Skip to content

Commit 59d9a7a

Browse files
authored
Merge pull request #78 from channel-io/develop
0.7.0
2 parents b7a85aa + 9c532fb commit 59d9a7a

File tree

11 files changed

+77
-68
lines changed

11 files changed

+77
-68
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.7.0
2+
## Update
3+
* Updated channeltalk plugin v10
4+
15
# 0.6.8
26

37
## 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:9.0.9'
58+
api 'io.channel:plugin-android:10.0.0'
5959
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public class Const {
1313
public static final String KEY_MEMBER_HASH = "memberHash";
1414
public static final String KEY_PROFILE = "profile";
1515
public static final String KEY_LANGUAGE = "language";
16-
public static final String KEY_UNSUBSCRIBED = "unsubscribed";
16+
public static final String KEY_UNSUBSCRIBED_EMAIL = "unsubscribedEmail";
17+
public static final String KEY_UNSUBSCRIBED_TEXTING = "unsubscribedTexting";
1718
public static final String KEY_TRACK_DEFAULT_EVENT = "trackDefaultEvent";
1819
public static final String KEY_HIDE_POPUP = "hidePopup";
1920
public static final String KEY_CHANNEL_BUTTON_OPTION = "channelButtonOption";
@@ -57,11 +58,9 @@ public class Const {
5758
public static final String KEY_EVENT_COUNT = "count";
5859
public static final String KEY_EVENT_URL = "url";
5960
public static final String KEY_EVENT_POPUP = "popup";
60-
public static final String KEY_PROFILE_KEY = "key";
61-
public static final String KEY_PROFILE_VALUE = "value";
6261

6362
public static final String KEY_ON_BADGE_CHANGED = "ON_BADGE_CHANGED";
64-
public static final String KEY_ON_PROFILE_CHANGED = "ON_PROFILE_CHANGED";
63+
public static final String KEY_ON_FOLLOW_UP_CHANGED = "ON_FOLLOW_UP_CHANGED";
6564
public static final String KEY_ON_POPUP_DATA_RECEIVED = "ON_POPUP_DATA_RECEIVED";
6665
public static final String KEY_ON_SHOW_MESSENGER = "ON_SHOW_MESSENGER";
6766
public static final String KEY_ON_HIDE_MESSENGER = "ON_HIDE_MESSENGER";
@@ -70,7 +69,7 @@ public class Const {
7069
public static final String KEY_ON_PRE_URL_CLICKED = "ON_PRE_URL_CLICKED";
7170

7271
public static final String EVENT_ON_BADGE_CHANGED = "ChannelIO:Event:OnBadgeChanged";
73-
public static final String EVENT_ON_PROFILE_CHANGED = "ChannelIO:Event:OnProfileChanged";
72+
public static final String EVENT_ON_FOLLOW_UP_CHANGED = "ChannelIO:Event:OnFollowUpChanged";
7473
public static final String EVENT_ON_POPUP_DATA_RECEIVED = "ChannelIO:Event:OnPopupDataReceive";
7574
public static final String EVENT_ON_SHOW_MESSENGER = "ChannelIO:Event:OnShowMessenger";
7675
public static final String EVENT_ON_HIDE_MESSENGER = "ChannelIO:Event:OnHideMessenger";

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

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ public static WritableMap toWritableMap(Map<String, Object> map) {
7777
return writableMap;
7878
}
7979

80+
public static WritableMap toWritableStringMap(Map<String, String> map) {
81+
WritableMap writableMap = Arguments.createMap();
82+
83+
if (map == null) {
84+
return writableMap;
85+
}
86+
87+
for (Map.Entry<String, String> pair : map.entrySet()) {
88+
writableMap.putString(pair.getKey(), pair.getValue());
89+
}
90+
91+
return writableMap;
92+
}
93+
8094
public static Map<String, Object> toHashMap(ReadableMap readableMap) {
8195
HashMap<String, Object> hashMap = new HashMap<>();
8296

@@ -261,9 +275,14 @@ public static BootConfig toBootConfig(ReadableMap configMap) {
261275
bootConfig.setHidePopup(hidePopup.getValue());
262276
}
263277

264-
MapEntry<Boolean> unsubscribed = Utils.getBoolean(configMap, Const.KEY_UNSUBSCRIBED);
265-
if (unsubscribed.hasValue()) {
266-
bootConfig.setUnsubscribed(unsubscribed.getValue());
278+
MapEntry<Boolean> unsubscribedEmail = Utils.getBoolean(configMap, Const.KEY_UNSUBSCRIBED_EMAIL);
279+
if (unsubscribedEmail.hasValue()) {
280+
bootConfig.setUnsubscribeEmail(unsubscribedEmail.getValue());
281+
}
282+
283+
MapEntry<Boolean> unsubscribedTexting = Utils.getBoolean(configMap, Const.KEY_UNSUBSCRIBED_TEXTING);
284+
if (unsubscribedTexting.hasValue()) {
285+
bootConfig.setUnsubscribeTexting(unsubscribedTexting.getValue());
267286
}
268287

269288
MapEntry<ReadableMap> channelButtonOption = Utils.getReadableMap(configMap, Const.KEY_CHANNEL_BUTTON_OPTION, Const.KEY_LAUNCHER_CONFIG);
@@ -320,9 +339,14 @@ public static UserData toUserData(ReadableMap userDataMap) {
320339
userDataBuilder.setProfileOnceMap(toHashMap(profileOnce.getValue()));
321340
}
322341

323-
MapEntry<Boolean> unsubscribed = Utils.getBoolean(userDataMap, Const.KEY_UNSUBSCRIBED);
324-
if (unsubscribed.hasValue()) {
325-
userDataBuilder.setUnsubscribed(unsubscribed.getValue());
342+
MapEntry<Boolean> unsubscribedEmail = Utils.getBoolean(userDataMap, Const.KEY_UNSUBSCRIBED_EMAIL);
343+
if (unsubscribedEmail.hasValue()) {
344+
userDataBuilder.setUnsubscribeEmail(unsubscribedEmail.getValue());
345+
}
346+
347+
MapEntry<Boolean> unsubscribedTexting = Utils.getBoolean(userDataMap, Const.KEY_UNSUBSCRIBED_TEXTING);
348+
if (unsubscribedTexting.hasValue()) {
349+
userDataBuilder.setUnsubscribeTexting(unsubscribedTexting.getValue());
326350
}
327351

328352
return userDataBuilder.build();
@@ -391,7 +415,8 @@ public static WritableMap userToWritableMap(User user) {
391415
userMap.putString(Const.KEY_NAME, user.getName());
392416
userMap.putString(Const.KEY_AVATAR_URL, user.getAvatarUrl());
393417
userMap.putInt(Const.KEY_ALERT, user.getAlert());
394-
userMap.putBoolean(Const.KEY_UNSUBSCRIBED, user.isUnsubscribed());
418+
userMap.putBoolean(Const.KEY_UNSUBSCRIBED_EMAIL, user.isUnsubscribeEmail());
419+
userMap.putBoolean(Const.KEY_UNSUBSCRIBED_TEXTING, user.isUnsubscribeTexting());
395420
userMap.putString(Const.KEY_LANGUAGE, user.getLanguage());
396421

397422
Map<String, Object> profile = user.getProfile();
@@ -421,13 +446,6 @@ public static WritableMap popupDataToWritableMap(PopupData popupData) {
421446
return resultMap;
422447
}
423448

424-
public static WritableMap createKeyValueMap(String keyName, String keyContent, String valueName, Object valueContent) {
425-
Map<String, Object> map = new HashMap<>();
426-
map.put(keyName, keyContent);
427-
map.put(valueName, valueContent);
428-
return toWritableMap(map);
429-
}
430-
431449
public static WritableMap createSingleMap(String key, Object object) {
432450
Map<String, Object> map = new HashMap<>();
433451
map.put(key, object);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Map<String, Object> getConstants() {
4343
eventMap.put(Const.KEY_ON_SHOW_MESSENGER, Const.EVENT_ON_SHOW_MESSENGER);
4444
eventMap.put(Const.KEY_ON_HIDE_MESSENGER, Const.EVENT_ON_HIDE_MESSENGER);
4545
eventMap.put(Const.KEY_ON_CHAT_CREATED, Const.EVENT_ON_CHAT_CREATED);
46-
eventMap.put(Const.KEY_ON_PROFILE_CHANGED, Const.EVENT_ON_PROFILE_CHANGED);
46+
eventMap.put(Const.KEY_ON_FOLLOW_UP_CHANGED, Const.EVENT_ON_FOLLOW_UP_CHANGED);
4747
eventMap.put(Const.KEY_ON_URL_CLICKED, Const.EVENT_ON_URL_CLICKED);
4848
eventMap.put(Const.KEY_ON_PRE_URL_CLICKED, Const.EVENT_ON_PRE_URL_CLICKED);
4949

@@ -226,11 +226,11 @@ public void onBadgeChanged(int count) {
226226
}
227227

228228
@Override
229-
public void onProfileChanged(String key, @Nullable Object value) {
229+
public void onFollowUpChanged(Map<String, String> data) {
230230
Utils.sendEvent(
231231
reactContext,
232-
Const.EVENT_ON_PROFILE_CHANGED,
233-
ParseUtils.createKeyValueMap(Const.KEY_PROFILE_KEY, key, Const.KEY_PROFILE_VALUE, value)
232+
Const.EVENT_ON_FOLLOW_UP_CHANGED,
233+
ParseUtils.toWritableStringMap(data)
234234
);
235235
}
236236

index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -340,32 +340,32 @@ export const ChannelIO = {
340340

341341
/**
342342
* @deprecated
343-
* Event listener that triggers when guest profile is updated
344-
* @param {Function} cb a callback function that takes a key, value
343+
* 'onChangeProfile' is deprecated. Please use 'onFollowUpChanged'.
345344
*/
346345
onChangeProfile: (cb) => {
347-
console.log('ChannelIO', 'ChannelIO.onChangeProfile(cb) is deprecated. Please use ChannelIO.onProfileChanged(cb)')
348-
if (cb) {
349-
const subscription = ChannelEventEmitter.addListener(ChannelModule.Event.ON_PROFILE_CHANGED, (data) => {
350-
cb(data.key, data.value);
351-
});
352-
replaceSubscriber(ChannelModule.Event.ON_PROFILE_CHANGED, subscription);
353-
} else {
354-
replaceSubscriber(ChannelModule.Event.ON_PROFILE_CHANGED, null);
355-
}
346+
console.warn("'onChangeProfile' is deprecated. Please use 'onFollowUpChanged'.")
347+
},
348+
349+
/**
350+
* @deprecated
351+
* 'onProfileChanged' is deprecated. Please use 'onFollowUpChanged'.
352+
*/
353+
onProfileChanged: (cb) => {
354+
console.warn("'onProfileChanged' is deprecated. Please use 'onFollowUpChanged'.")
356355
},
356+
357357
/**
358358
* Event listener that triggers when guest profile is updated
359-
* @param {Function} cb a callback function that takes a key, value
359+
* @param {Function} cb a callback function that takes a map
360360
*/
361-
onProfileChanged: (cb) => {
361+
onFollowUpChanged: (cb) => {
362362
if (cb) {
363-
const subscription = ChannelEventEmitter.addListener(ChannelModule.Event.ON_PROFILE_CHANGED, (data) => {
364-
cb(data.key, data.value);
363+
const subscription = ChannelEventEmitter.addListener(ChannelModule.Event.ON_FOLLOW_UP_CHANGED, (data) => {
364+
cb(data);
365365
});
366-
replaceSubscriber(ChannelModule.Event.ON_PROFILE_CHANGED, subscription);
366+
replaceSubscriber(ChannelModule.Event.ON_FOLLOW_UP_CHANGED, subscription);
367367
} else {
368-
replaceSubscriber(ChannelModule.Event.ON_PROFILE_CHANGED, null);
368+
replaceSubscriber(ChannelModule.Event.ON_FOLLOW_UP_CHANGED, null);
369369
}
370370
},
371371

ios/RCTConvert+ChannelIO.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import <Foundation/Foundation.h>
1010
#import <React/RCTConvert.h>
11-
#import <ChannelIOFront/ChannelIOFront-Swift.h>
11+
#import <ChannelIOFront/ChannelIOFront-swift.h>
1212

1313
NS_ASSUME_NONNULL_BEGIN
1414

@@ -50,6 +50,8 @@ static NSString * const KEY_MEMBER_HASH = @"memberHash";
5050
static NSString * const KEY_HIDE_POPUP = @"hidePopup";
5151
static NSString * const KEY_TRACK_DEFAULT_EVENT = @"trackDefaultEvent";
5252
static NSString * const KEY_CHANNEL_BUTTON_OPTION = @"channelButtonOption";
53+
static NSString * const KEY_UNSUBSCRIBE_EMAIL = @"unsubscribeEmail";
54+
static NSString * const KEY_UNSUBSCRIBE_TEXTING = @"unsubscribeTexting";
5355

5456
static NSString * const KEY_MEMBER_ID = @"memberId";
5557
static NSString * const KEY_LANGUAGE = @"language";

ios/RCTConvert+ChannelIO.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ + (BootConfig *)bootConfig:(id)json {
5757
? [RCTConvert BOOL:json[KEY_HIDE_POPUP]] : [RCTConvert BOOL:json[KEY_HIDE_DEFAULT_IN_APP_PUSH]];
5858
config.trackDefaultEvent = json[KEY_TRACK_DEFAULT_EVENT] != nil
5959
? [RCTConvert BOOL:json[KEY_TRACK_DEFAULT_EVENT]] : [RCTConvert BOOL:json[KEY_ENABLED_TRACK_DEFAULT_EVENT]];
60-
60+
config.unsubscribeEmail = [RCTConvert BOOL:json[KEY_UNSUBSCRIBE_EMAIL]];
61+
config.unsubscribeTexting = [RCTConvert BOOL:json[KEY_UNSUBSCRIBE_TEXTING]];
62+
6163
if (json[KEY_LAUNCHER_CONFIG] == nil && json[KEY_CHANNEL_BUTTON_OPTION] != nil) {
6264
config.channelButtonOption = [RCTConvert channelButtonOption:json[KEY_CHANNEL_BUTTON_OPTION]];
6365
} else if (json[KEY_LAUNCHER_CONFIG] != nil && json[KEY_CHANNEL_BUTTON_OPTION] == nil) {

ios/RNChannelIO.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <Foundation/Foundation.h>
1010
#import <React/RCTBridgeModule.h>
1111
#import <React/RCTEventEmitter.h>
12-
#import <ChannelIOFront/ChannelIOFront-Swift.h>
12+
#import <ChannelIOFront/ChannelIOFront-swift.h>
1313

1414
NS_ASSUME_NONNULL_BEGIN
1515

@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
2020
static NSString * const EVENT = @"Event";
2121

2222
static NSString * const KEY_EVENT_ON_BADGE_CHANGED = @"ON_BADGE_CHANGED";
23-
static NSString * const KEY_EVENT_ON_PROFILE_CHANGED = @"ON_PROFILE_CHANGED";
23+
static NSString * const KEY_EVENT_ON_FOLLOW_UP_CHANGED = @"ON_FOLLOW_UP_CHANGED";
2424
static NSString * const KEY_EVENT_ON_POPUP_DATA_RECEIVED = @"ON_POPUP_DATA_RECEIVED";
2525
static NSString * const KEY_EVENT_ON_SHOW_MESSENGER = @"ON_SHOW_MESSENGER";
2626
static NSString * const KEY_EVENT_ON_HIDE_MESSENGER = @"ON_HIDE_MESSENGER";
@@ -29,7 +29,7 @@ static NSString * const KEY_EVENT_ON_PRE_URL_CLICKED = @"ON_PRE_URL_CLICKED";
2929
static NSString * const KEY_EVENT_ON_URL_CLICKED = @"ON_URL_CLICKED";
3030

3131
static NSString * const EVENT_ON_BADGE_CHANGED = @"ChannelIO:Event:OnBadgeChanged";
32-
static NSString * const EVENT_ON_PROFILE_CHANGED = @"ChannelIO:Event:OnProfileChanged";
32+
static NSString * const EVENT_ON_FOLLOW_UP_CHANGED = @"ChannelIO:Event:OnFollowUpChanged";
3333
static NSString * const EVENT_ON_POPUP_DATA_RECEIVED = @"ChannelIO:Event:OnPopupDataReceive";
3434
static NSString * const EVENT_ON_SHOW_MESSENGER = @"ChannelIO:Event:OnShowMessenger";
3535
static NSString * const EVENT_ON_HIDE_MESSENGER = @"ChannelIO:Event:OnHideMessenger";
@@ -69,8 +69,6 @@ static NSString * const KEY_COUNT = @"count";
6969
static NSString * const KEY_URL = @"url";
7070
static NSString * const KEY_POPUP = @"popup";
7171
static NSString * const KEY_PROFILE_ONCE = @"profileOnce";
72-
static NSString * const KEY_PROFILE_KEY = @"key";
73-
static NSString * const KEY_PROFILE_VALUE = @"value";
7472
static NSString * const KEY_USER = @"user";
7573
static NSString * const KEY_ERROR = @"error";
7674
static NSString * const KEY_TAGS = @"tags";

ios/RNChannelIO.m

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ - (NSDictionary *)constantsToExport {
5858
return @{
5959
EVENT: @{
6060
KEY_EVENT_ON_BADGE_CHANGED: EVENT_ON_BADGE_CHANGED,
61-
KEY_EVENT_ON_PROFILE_CHANGED: EVENT_ON_PROFILE_CHANGED,
61+
KEY_EVENT_ON_FOLLOW_UP_CHANGED: EVENT_ON_FOLLOW_UP_CHANGED,
6262
KEY_EVENT_ON_POPUP_DATA_RECEIVED: EVENT_ON_POPUP_DATA_RECEIVED,
6363
KEY_EVENT_ON_SHOW_MESSENGER: EVENT_ON_SHOW_MESSENGER,
6464
KEY_EVENT_ON_HIDE_MESSENGER: EVENT_ON_HIDE_MESSENGER,
@@ -85,20 +85,6 @@ - (NSDictionary *)constantsToExport {
8585
CHANNEL_BUTTON_POSITION: @{
8686
KEY_CHANNEL_BUTTON_OPTION_POSITION_RIGHT: @(ChannelButtonPositionRight),
8787
KEY_CHANNEL_BUTTON_OPTION_POSITION_LEFT: @(ChannelButtonPositionLeft)
88-
},
89-
CHANNEL_PLUGIN_COMPLETION_STATUS: @{
90-
KEY_BOOT_STATUS_SUCCESS: @(ChannelPluginCompletionStatusSuccess),
91-
KEY_BOOT_STATUS_NOT_INITIALIZED: @(ChannelPluginCompletionStatusNotInitialized),
92-
KEY_BOOT_STATUS_NETWORK_TIMEOUT: @(ChannelPluginCompletionStatusNetworkTimeout),
93-
KEY_BOOT_STATUS_NOT_AVAILABLE_VERSION: @(ChannelPluginCompletionStatusNotAvailableVersion),
94-
KEY_BOOT_STATUS_SERVICE_UNDER_CONSTRUCTION: @(ChannelPluginCompletionStatusServiceUnderConstruction),
95-
KEY_BOOT_STATUS_REQUIRE_PAYMENT: @(ChannelPluginCompletionStatusRequirePayment),
96-
KEY_BOOT_STATUS_ACCESS_DENIED: @(ChannelPluginCompletionStatusAccessDenied),
97-
KEY_BOOT_STATUS_UNKNOWN_ERROR: @(ChannelPluginCompletionStatusUnknown)
98-
},
99-
LAUNCHER_POSITION: @{
100-
KEY_CHANNEL_BUTTON_OPTION_POSITION_RIGHT: @(LauncherPositionRight),
101-
KEY_CHANNEL_BUTTON_OPTION_POSITION_LEFT: @(LauncherPositionLeft)
10288
}
10389
};
10490
}
@@ -111,7 +97,7 @@ - (NSDictionary *)constantsToExport {
11197
EVENT_ON_SHOW_MESSENGER,
11298
EVENT_ON_PRE_URL_CLICKED,
11399
EVENT_ON_URL_CLICKED,
114-
EVENT_ON_PROFILE_CHANGED,
100+
EVENT_ON_FOLLOW_UP_CHANGED,
115101
EVENT_ON_POPUP_DATA_RECEIVED
116102
];
117103
}
@@ -120,6 +106,7 @@ - (NSDictionary *)constantsToExport {
120106
resolver:(RCTPromiseResolveBlock)resolve
121107
rejecter:(RCTPromiseRejectBlock)reject) {
122108
BootConfig * config = [RCTConvert bootConfig:bootConfig];
109+
123110
[ChannelIO bootWith:config completion:^(BootStatus status, User *user) {
124111
NSString * stringStatus = BOOT_STATUS_UNKNOWN_ERROR;
125112
switch (status) {
@@ -394,10 +381,9 @@ - (BOOL)onUrlClickedWithUrl:(NSURL *)url {
394381
return true;
395382
}
396383

397-
- (void)onProfileChangedWithKey:(NSString *)key value:(id)value {
384+
- (void)onFollowUpChangedWithData:(NSDictionary<NSString *,id> *)data {
398385
if (hasListeners) {
399-
[self sendEventWithName:EVENT_ON_PROFILE_CHANGED
400-
body: @{KEY_PROFILE_KEY: key, KEY_PROFILE_VALUE: value}];
386+
[self sendEventWithName:EVENT_ON_FOLLOW_UP_CHANGED body:data];
401387
}
402388
}
403389

0 commit comments

Comments
 (0)