Skip to content

Commit 6863867

Browse files
authored
0.8.0
* [Feature] v11 지원 및 다크모드 지원 * [Fix] 리뷰반영 * [Fix] isAppearance 삭제 후 toAppearance에 합침
1 parent 101dcaf commit 6863867

File tree

12 files changed

+140
-21
lines changed

12 files changed

+140
-21
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.8.0
2+
## Update
3+
* Updated channeltalk plugin v11
4+
* Supports dark mode
5+
* Redesigned UI / UX
6+
17
# 0.7.12
28

39
## Update

RNChannelIO.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "RNChannelIO"
3-
s.version = "0.1.1"
3+
s.version = "0.2.0"
44
s.summary = "RNChannelIO"
55
s.description = "channel plugin for react native"
66
s.homepage = "https://channel.io"
@@ -15,5 +15,5 @@ Pod::Spec.new do |s|
1515
s.ios.deployment_target = '11.0'
1616

1717
s.dependency "React"
18-
s.dependency "ChannelIOSDK", '~> 10'
18+
s.dependency "ChannelIOSDK", '~> 11'
1919
end

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.9'
58+
api 'io.channel:plugin-android:11.0.1'
5959
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ public class Const {
2525
public static final String KEY_PROFILE_ONCE = "profileOnce";
2626
public static final String KEY_ID = "id";
2727
public static final String KEY_ALERT = "alert";
28+
public static final String KEY_UNREAD = "unread";
2829
public static final String KEY_NAME = "name";
2930
public static final String KEY_EMAIL = "email";
3031
public static final String KEY_MOBILE_NUMBER = "mobileNumber";
3132
public static final String KEY_AVATAR_URL = "avatarUrl";
3233
public static final String KEY_CHAT_ID = "chatId";
3334
public static final String KEY_MESSAGE = "message";
35+
public static final String KEY_APPEARANCE = "appearance";
3436

3537
// Legacy
3638
public static final String KEY_USER_ID = "userId";
@@ -50,6 +52,11 @@ public class Const {
5052
public static final String KEY_BUBBLE_POSITION_TOP = "top";
5153
public static final String KEY_BUBBLE_POSITION_BOTTOM = "bottom";
5254

55+
// Appearance
56+
public static final String KEY_APPEARANCE_SYSTEM = "system";
57+
public static final String KEY_APPEARANCE_LIGHT = "light";
58+
public static final String KEY_APPEARANCE_DARK = "dark";
59+
5360
// Result
5461
public static final String RESULT_KEY_STATUS = "status";
5562
public static final String RESULT_KEY_ERROR = "error";

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
import java.util.*;
1313

14+
import javax.annotation.Nullable;
15+
1416
import io.channel.plugin.android.enumerate.BubblePosition;
17+
import io.channel.plugin.android.open.model.Appearance;
1518
import io.channel.plugin.android.open.option.BubbleOption;
1619

1720
/**
@@ -229,6 +232,20 @@ public static BubbleOption toBubbleOption(ReadableMap bubbleOptionMap) {
229232
return null;
230233
}
231234

235+
@Nullable
236+
public static Appearance toAppearance(String appearance) {
237+
if (appearance == null) {
238+
return null;
239+
}
240+
241+
switch (appearance) {
242+
case Const.KEY_APPEARANCE_LIGHT: return Appearance.LIGHT;
243+
case Const.KEY_APPEARANCE_DARK: return Appearance.DARK;
244+
case Const.KEY_APPEARANCE_SYSTEM: return Appearance.SYSTEM;
245+
default: return null;
246+
}
247+
}
248+
232249
private static Profile toProfile(ReadableMap profileMap) {
233250
if (profileMap != null) {
234251
Profile profile = Profile.create();
@@ -329,6 +346,15 @@ public static BootConfig toBootConfig(ReadableMap configMap) {
329346
bootConfig.setProfile(toProfile(profile.getValue()));
330347
}
331348

349+
MapEntry<String> appearanceMap = Utils.getString(configMap, Const.KEY_APPEARANCE);
350+
if (appearanceMap.hasValue()) {
351+
Appearance appearance = toAppearance(appearanceMap.getValue());
352+
353+
if (appearance != null) {
354+
bootConfig.setAppearance(appearance);
355+
}
356+
}
357+
332358
return bootConfig;
333359
}
334360

@@ -427,6 +453,13 @@ public static Map<String, String> toPushNotification(ReadableMap pushNotificatio
427453
return pushNotification;
428454
}
429455

456+
public static WritableMap toBadgeChanged(int unread, int alert) {
457+
HashMap<String, Object> result = new HashMap<>();
458+
result.put(Const.KEY_UNREAD, unread);
459+
result.put(Const.KEY_ALERT, alert);
460+
return toWritableMap(result);
461+
}
462+
430463
public static WritableMap getBootResult(
431464
BootStatus status,
432465
User user

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.HashMap;
2121
import java.util.Map;
2222

23+
import io.channel.plugin.android.open.model.Appearance;
24+
2325
public class RNChannelIO extends ReactContextBaseJavaModule implements ChannelPluginListener {
2426

2527
private ReactContext reactContext;
@@ -226,8 +228,11 @@ public void onChatCreated(String chatId) {
226228
}
227229

228230
@Override
229-
public void onBadgeChanged(int count) {
230-
Utils.sendEvent(reactContext, Const.EVENT_ON_BADGE_CHANGED, ParseUtils.createSingleMap(Const.KEY_EVENT_COUNT, count));
231+
public void onBadgeChanged(int i) { }
232+
233+
@Override
234+
public void onBadgeChanged(int unread, int alert) {
235+
Utils.sendEvent(reactContext, Const.EVENT_ON_BADGE_CHANGED, ParseUtils.toBadgeChanged(unread, alert));
231236
}
232237

233238
@Override
@@ -260,12 +265,12 @@ public boolean onPushNotificationClicked(final String chatId) {
260265
if (userId == null) { return false; }
261266

262267
Utils.sendEvent(
263-
reactContext,
264-
Const.EVENT_ON_PUSH_NOTIFICATION_CLICKED,
265-
ParseUtils.toWritableMap(new HashMap<String, Object>() {{
266-
put(Const.KEY_USER_ID, userId);
267-
put(Const.KEY_CHAT_ID, chatId);
268-
}})
268+
reactContext,
269+
Const.EVENT_ON_PUSH_NOTIFICATION_CLICKED,
270+
ParseUtils.toWritableMap(new HashMap<String, Object>() {{
271+
put(Const.KEY_USER_ID, userId);
272+
put(Const.KEY_CHAT_ID, chatId);
273+
}})
269274
);
270275
return true; // defer push notification click handling -- the JavaScript code will call `performDefaultPushNotificationClickAction` if needed.
271276
}
@@ -324,4 +329,12 @@ public void setPage(@Nullable String page) {
324329
public void resetPage() {
325330
ChannelIO.resetPage();
326331
}
332+
333+
@ReactMethod
334+
public void setAppearance(@Nullable String appearance) {
335+
Appearance appearanceValue = ParseUtils.toAppearance(appearance);
336+
if (appearanceValue != null) {
337+
ChannelIO.setAppearance(appearanceValue);
338+
}
339+
}
327340
}

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,18 @@ export const ChannelIO = {
239239
*/
240240
resetPage: () => ChannelModule.resetPage(),
241241

242+
/**
243+
* Sets the appearance of the SDK.
244+
* @param {String} appearance system | light | dark
245+
*/
246+
setAppearance: (appearance) => {
247+
if (typeof appearance === "string") {
248+
ChannelModule.setAppearance(appearance)
249+
} else {
250+
console.error('ChannelIO', '"appearance" must be type of "string". ex) "system", "light", "dark"')
251+
}
252+
},
253+
242254
/**
243255
* @deprecated
244256
* Event listener that triggers when badge count has been changed
@@ -248,7 +260,7 @@ export const ChannelIO = {
248260
console.log('ChannelIO', 'ChannelIO.onChangeBadge(cb) is deprecated. Please use ChannelIO.onBadgeChanged(cb)')
249261
if (cb) {
250262
const subscription = ChannelEventEmitter.addListener(ChannelModule.Event.ON_BADGE_CHANGED, (data) => {
251-
cb(data.count);
263+
cb(data.unread, data.alert);
252264
});
253265
replaceSubscriber(ChannelModule.Event.ON_BADGE_CHANGED, subscription);
254266
} else {
@@ -263,7 +275,7 @@ export const ChannelIO = {
263275
onBadgeChanged: (cb) => {
264276
if (cb) {
265277
const subscription = ChannelEventEmitter.addListener(ChannelModule.Event.ON_BADGE_CHANGED, (data) => {
266-
cb(data.count);
278+
cb(data.unread, data.alert);
267279
});
268280
replaceSubscriber(ChannelModule.Event.ON_BADGE_CHANGED, subscription);
269281
} else {

ios/RCTConvert+ChannelIO.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ static NSString * const CHANNEL_BUTTON_OPTION_Y_MARGIN = @"yMargin";
4949
static NSString * const KEY_BUBBLE_POSITION_TOP = @"top";
5050
static NSString * const KEY_BUBBLE_POSITION_BOTTOM = @"bottom";
5151

52+
// Appearance
53+
static NSString * const APPEARANCE_SYSTEM = @"system";
54+
static NSString * const APPEARANCE_LIGHT = @"light";
55+
static NSString * const APPEARANCE_DARK = @"dark";
56+
5257
// BubbleOption
5358
static NSString * const BUBBLE_OPTION_POSITION = @"position";
5459
static NSString * const BUBBLE_OPTION_POSITION_TOP = @"top";
@@ -63,6 +68,7 @@ static NSString * const KEY_CHANNEL_BUTTON_OPTION = @"channelButtonOption";
6368
static NSString * const KEY_BUBBLE_OPTION = @"bubbleOption";
6469
static NSString * const KEY_UNSUBSCRIBE_EMAIL = @"unsubscribeEmail";
6570
static NSString * const KEY_UNSUBSCRIBE_TEXTING = @"unsubscribeTexting";
71+
static NSString * const KEY_APPEARANCE = @"appearance";
6672

6773
static NSString * const KEY_MEMBER_ID = @"memberId";
6874
static NSString * const KEY_LANGUAGE = @"language";

ios/RCTConvert+ChannelIO.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ @implementation RCTConvert (ChannelIOEnums)
5454
integerValue
5555
)
5656

57+
RCT_ENUM_CONVERTER(
58+
Appearance,
59+
(@{APPEARANCE_SYSTEM: @(AppearanceSystem),
60+
APPEARANCE_DARK: @(AppearanceDark),
61+
APPEARANCE_LIGHT: @(AppearanceLight)
62+
}),
63+
AppearanceSystem,
64+
integerValue
65+
)
66+
5767
@end
5868

5969
@implementation RCTConvert (ChannelIO)
@@ -116,6 +126,17 @@ + (BootConfig *)bootConfig:(id)json {
116126
config.profile = [RCTConvert profile:json[KEY_PROFILE]];
117127
}
118128

129+
NSString *appearance = [RCTConvert NSString:json[KEY_APPEARANCE]];
130+
if (json[KEY_APPEARANCE] != nil) {
131+
if ([appearance isEqualToString:APPEARANCE_SYSTEM]) {
132+
[config setWithAppearance:AppearanceSystem];
133+
} else if ([appearance isEqualToString:APPEARANCE_LIGHT]) {
134+
[config setWithAppearance:AppearanceLight];
135+
} else if ([appearance isEqualToString:APPEARANCE_DARK]) {
136+
[config setWithAppearance:AppearanceDark];
137+
}
138+
}
139+
119140
return config;
120141
}
121142

ios/RNChannelIO.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ static NSString * const KEY_PROFILE_ONCE = @"profileOnce";
7272
static NSString * const KEY_USER = @"user";
7373
static NSString * const KEY_ERROR = @"error";
7474
static NSString * const KEY_TAGS = @"tags";
75+
static NSString * const KEY_UNREAD = @"unread";
76+
static NSString * const KEY_ALERT = @"alert";
77+
78+
// Appearance
79+
static NSString * const CHANNEL_APPEARANCE = @"Appearance";
80+
81+
static NSString * const KEY_APPEARANCE_SYSTEM = @"system";
82+
static NSString * const KEY_APPEARANCE_LIGHT = @"light";
83+
static NSString * const KEY_APPEARANCE_DARK = @"dark";
84+
7585

7686
// deprecated
7787

ios/RNChannelIO.m

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ - (NSDictionary *)constantsToExport {
8585
CHANNEL_BUTTON_POSITION: @{
8686
KEY_CHANNEL_BUTTON_OPTION_POSITION_RIGHT: @(ChannelButtonPositionRight),
8787
KEY_CHANNEL_BUTTON_OPTION_POSITION_LEFT: @(ChannelButtonPositionLeft)
88-
}
88+
},
89+
CHANNEL_APPEARANCE: @{
90+
KEY_APPEARANCE_SYSTEM: @(AppearanceSystem),
91+
KEY_APPEARANCE_DARK: @(AppearanceDark),
92+
KEY_APPEARANCE_LIGHT: @(AppearanceLight)
93+
},
8994
};
9095
}
9196

@@ -355,16 +360,22 @@ - (NSDictionary *)constantsToExport {
355360
[ChannelIO resetPage];
356361
}
357362

358-
#pragma mark ChannelPluginDelegate
359-
- (void)onBadgeChangedWithCount:(NSInteger)count {
360-
if (hasListeners) {
361-
[self sendEventWithName:EVENT_ON_BADGE_CHANGED body:@{KEY_COUNT: @(count)}];
363+
RCT_EXPORT_METHOD(setAppearance:(NSString *)appearance) {
364+
if (appearance != nil) {
365+
if ([appearance isEqualToString:APPEARANCE_SYSTEM]) {
366+
[ChannelIO setAppearance:AppearanceSystem];
367+
} else if ([appearance isEqualToString:APPEARANCE_LIGHT]) {
368+
[ChannelIO setAppearance:AppearanceLight];
369+
} else if ([appearance isEqualToString:APPEARANCE_DARK]) {
370+
[ChannelIO setAppearance:AppearanceDark];
371+
}
362372
}
363373
}
364374

365-
- (void)onBadgeChangedWithAlert:(NSInteger)alert {
375+
#pragma mark ChannelPluginDelegate
376+
- (void)onBadgeChangedWithUnread:(NSInteger)unread alert:(NSInteger)alert {
366377
if (hasListeners) {
367-
[self sendEventWithName:EVENT_ON_BADGE_CHANGED body:@{KEY_COUNT: @(alert)}];
378+
[self sendEventWithName:EVENT_ON_BADGE_CHANGED body:@{KEY_UNREAD: @(unread), KEY_ALERT: @(alert)}];
368379
}
369380
}
370381

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.12",
3+
"version": "0.8.0",
44
"description": "react native module for channel io",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)