Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# 0.11.3

## Update
* support android channel-io 12.7.0
* support iOS channel-io 12.7.0

## Bug Fixes
* react-native 0.76.0 or higher: Fixes an issue where an error occurs when using setPage.

# 0.11.2

## Update
* support android channel-io 12.7.0
* support iOS channel-io 12.7.0
* remove deprecated functions
* show / hide / open / close / handlePushNotification / onChangeBadge / onReceivePush / onClickChatLink / onChangeProfile / onProfileChanged / willShowMessenger / willHideMessenger

# 0.11.1

Expand Down
4 changes: 2 additions & 2 deletions RNChannelIO.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RNChannelIO"
s.version = "0.5.2"
s.version = "0.5.3"
s.summary = "RNChannelIO"
s.description = "channel plugin for react native"
s.homepage = "https://channel.io"
Expand All @@ -15,6 +15,6 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '15.0'

s.dependency "React"
s.dependency "ChannelIOSDK", '12.7.0'
s.dependency "ChannelIOSDK", '12.9.0'

end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ repositories {

dependencies {
implementation 'com.facebook.react:react-native'
api 'io.channel:plugin-android:12.7.0'
api 'io.channel:plugin-android:12.8.1'
}
162 changes: 5 additions & 157 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ interface ChannelModuleType {
receivePushNotification: (userInfo: Record<string, any>) => Promise<void>;
hasStoredPushNotification: () => Promise<boolean>;
openStoredPushNotification: () => void;
setPageNull: (profile?: Profile) => void;
setPage: (page?: string | null, profile?: Profile) => void;
resetPage: () => void;
setAppearance: (appearance: Appearance) => void;
Expand Down Expand Up @@ -188,24 +189,12 @@ interface RNChannelIO extends Pick<ChannelModuleType,
| 'resetPage'
| 'setAppearance'
| 'hidePopup'> {
show: (animated: boolean) => void;
hide: (animated: boolean) => void;
open: (animated: boolean) => void;
close: (animated: boolean) => void;
handlePushNotification: (userInfo: Record<string, any>) => Promise<void>;
onChangeBadge: (cb?: (unread: number, alert: number) => void) => void;
onBadgeChanged: (cb?: (unread: number, alert: number) => void) => void;
onReceivePush: (cb?: (popup: PopupData) => void) => void;
onPopupDataReceived: (cb?: (popup: PopupData) => void) => void;
onClickChatLink: (handle: boolean, cb?: (url: string) => void) => void;
onUrlClicked: (cb?: (url: string, next: () => void) => void) => void;
onChangeProfile: (cb?: () => void) => void;
onProfileChanged: (cb?: (data: Record<string, any>) => void) => void;
onFollowUpChanged: (cb?: (data: Record<string, any>) => void) => void;
onPushNotificationClicked: (cb?: (chatId: string, next: () => void) => void) => void;
willShowMessenger: (cb?: () => void) => void;
onShowMessenger: (cb?: () => void) => void;
willHideMessenger: (cb?: () => void) => void;
onHideMessenger: (cb?: () => void) => void;
onChatCreated: (cb?: (chatId: string) => void) => void;
}
Expand Down Expand Up @@ -275,57 +264,21 @@ export const ChannelIO: RNChannelIO = {
ChannelModule.shutdown();
},

/**
* @deprecated
* Show `ChannelIO` button
* @param {Boolean} aniamted Animate the launcher if true
*/
show: (animated: boolean) => {
console.log('ChannelIO', 'ChannelIO.show(animated) is deprecated. Please use ChannelIO.showChannelButton()')
ChannelModule.showChannelButton()
},
/**
* Show `ChannelIO` button
*/
showChannelButton: () => ChannelModule.showChannelButton(),

/**
* @deprecated
* Hide `ChannelIO` button
* @param {Boolean} aniamted Animate the launcher if true
*/
hide: (animated: boolean) => {
console.log('ChannelIO', 'ChannelIO.hide(animated) is deprecated. Please use ChannelIO.hideChannelButton()')
ChannelModule.hideChannelButton()
},
/**
* Hide `ChannelIO` button
*/
hideChannelButton: () => ChannelModule.hideChannelButton(),

/**
* @deprecated
* Open `ChannelIO` messenger
* @param {Boolean} aniamted Animate messenger if true
*/
open: (animated: boolean) => {
console.log('ChannelIO', 'ChannelIO.open(animated) is deprecated. Please use ChannelIO.showMessenger()')
ChannelModule.showMessenger()
},
/**
* Show `ChannelIO` messenger
*/
showMessenger: () => ChannelModule.showMessenger(),

/**
* @deprecated
* Close `ChannelIO` messenger
* @param {Boolean} Animate messenger if true
*/
close: (animated: boolean) => {
console.log('ChannelIO', 'ChannelIO.close(animated) is deprecated. Please use ChannelIO.hideMessenger()')
ChannelModule.hideMessenger()
},
/**
* Hide `ChannelIO` messenger
*/
Expand Down Expand Up @@ -418,15 +371,6 @@ export const ChannelIO: RNChannelIO = {
*/
isChannelPushNotification: async (userInfo: Record<string, any>) => ChannelModule.isChannelPushNotification(userInfo),

/**
* @deprecated
* Handle `ChannelIO` push notification
* @param {Object} userInfo userInfo part from push data
*/
handlePushNotification: async (userInfo: Record<string, any>) => {
console.log('ChannelIO', 'ChannelIO.handlePushNotification(userInfo) is deprecated. Please use ChannelIO.receivePushNotification(userInfo)')
ChannelModule.receivePushNotification(userInfo)
},
/**
* Receive `ChannelIO` push notification
* @param {Object} userInfo userInfo part from push data
Expand All @@ -447,15 +391,15 @@ export const ChannelIO: RNChannelIO = {
/**
* Sets the name of the screen along with user chat profile. If track is called before setPage, the event will not reflect the page information.
* @param {String} page This is the screen name when track is called. When calling .track(), the event's page is set to null.
* @param {String} profile The user chat profile value.
* @param {Object} profile The user chat profile value.
* - When nil is assigned to a specific field within the profile object, only the value of that field is cleared.
* - The user chat profile value is applied when a user chat is created.
*/
setPage: (page?: string | null, profile?: Profile) => {
if (typeof page === "string") {
ChannelModule.setPage(page, profile)
ChannelModule.setPage(page, profile ?? {})
} else if (page === null || page === undefined) {
ChannelModule.setPage(null, profile)
ChannelModule.setPageNull(profile ?? {})
} else {
console.error('ChannelIO', '"page" must be type of "string", null or undefined.')
}
Expand Down Expand Up @@ -483,23 +427,6 @@ export const ChannelIO: RNChannelIO = {
*/
hidePopup: () => ChannelModule.hidePopup(),

/**
* @deprecated
* Event listener that triggers when badge count has been changed
* @param {Function} cb a callback function that takes a integer badge count as parameter
*/
onChangeBadge: (cb?: (unread: number, alert: number) => void) => {
console.log('ChannelIO', 'ChannelIO.onChangeBadge(cb) is deprecated. Please use ChannelIO.onBadgeChanged(cb)')
if (cb) {
const subscription = ChannelEventEmitter?.addListener(ChannelModule.Event.ON_BADGE_CHANGED, (data) => {
cb(data.unread, data.alert);
});
replaceSubscriber(ChannelModule.Event.ON_BADGE_CHANGED, subscription);
} else {
replaceSubscriber(ChannelModule.Event.ON_BADGE_CHANGED, null);
}

},
/**
* Event listener that triggers when badge count has been changed
* @param {Function} cb a callback function that takes a integer badge count as parameter
Expand All @@ -515,22 +442,6 @@ export const ChannelIO: RNChannelIO = {
}
},

/**
* @deprecated
* Event listener that triggers when in-app popup has been arrived
* @param {Function} cb a callback function that takes a object popup data as parameter
*/
onReceivePush: (cb?: (popup: PopupData) => void) => {
console.log('ChannelIO', 'ChannelIO.onReceivePush(cb) is deprecated. Please use ChannelIO.onPopupDataReceived(cb)')
if (cb) {
const subscription = ChannelEventEmitter?.addListener(ChannelModule.Event.ON_POPUP_DATA_RECEIVED, (data) => {
cb(data.popup);
});
replaceSubscriber(ChannelModule.Event.ON_POPUP_DATA_RECEIVED, subscription);
} else {
replaceSubscriber(ChannelModule.Event.ON_POPUP_DATA_RECEIVED, null);
}
},
/**
* Event listener that triggers when in-app popup has been arrived
* @param {Function} cb a callback function that takes a object popup data as parameter
Expand All @@ -546,25 +457,6 @@ export const ChannelIO: RNChannelIO = {
}
},

/**
* @deprecated
* Event listener that triggers when a link has been clicked by a user
* @param {Boolean} handle True if you want to handle a link, otherwise false
* @param {Function} cb a callback function that takes a string url as parameter
*/
onClickChatLink: (handle: boolean, cb?: (url: string) => void) => {
console.log('ChannelIO', 'ChannelIO.onClickChatLink(handle, cb) is deprecated. Please use ChannelIO.onUrlClicked(cb)')
if (cb) {
replaceSubscriber(ChannelModule.Event.ON_URL_CLICKED, (data) => {
if (!handle) {
ChannelModule.handleUrlClicked(data.url);
}
cb(data.url);
});
} else {
replaceSubscriber(ChannelModule.Event.ON_URL_CLICKED, null);
}
},
/**
* Event listener that triggers when a url has been clicked by a user
* @param {Function} cb a callback function that takes a string url as parameter
Expand All @@ -580,23 +472,7 @@ export const ChannelIO: RNChannelIO = {
} else {
replaceSubscriber(ChannelModule.Event.ON_URL_CLICKED, null);
}
},

/**
* @deprecated
* 'onChangeProfile' is deprecated. Please use 'onFollowUpChanged'.
*/
onChangeProfile: (cb?: () => void) => {
console.warn("'onChangeProfile' is deprecated. Please use 'onFollowUpChanged'.")
},

/**
* @deprecated
* 'onProfileChanged' is deprecated. Please use 'onFollowUpChanged'.
*/
onProfileChanged: (cb?: (data: Record<string, any>) => void) => {
console.warn("'onProfileChanged' is deprecated. Please use 'onFollowUpChanged'.")
},
},

/**
* Event listener that triggers when guest profile is updated
Expand Down Expand Up @@ -638,20 +514,6 @@ export const ChannelIO: RNChannelIO = {
}
},

/**
* @deprecated
* Event listener that triggers when `ChannelIO` messenger is about to display
* @param {Function} cb a callback function
*/
willShowMessenger: (cb?: () => void) => {
console.log('ChannelIO', 'ChannelIO.willShowMessenger(cb) is deprecated. Please use ChannelIO.onShowMessenger(cb)')
if (cb) {
const subscription = ChannelEventEmitter?.addListener(ChannelModule.Event.ON_SHOW_MESSENGER, cb);
replaceSubscriber(ChannelModule.Event.ON_SHOW_MESSENGER, subscription);
} else {
replaceSubscriber(ChannelModule.Event.ON_SHOW_MESSENGER, null);
}
},
/**
* Event listener that triggers when `ChannelIO` messenger is about to display
* @param {Function} cb a callback function
Expand All @@ -665,20 +527,6 @@ export const ChannelIO: RNChannelIO = {
}
},

/**
* @deprecated
* Event listener that triggers when `ChannelIO` messenger is about to dismiss
* @param {Function} cb a callback function
*/
willHideMessenger: (cb?: () => void) => {
console.log('ChannelIO', 'ChannelIO.willHideMessenger(cb) is deprecated. Please use ChannelIO.onHideMessenger(cb)')
if (cb) {
const subscription = ChannelEventEmitter?.addListener(ChannelModule.Event.ON_HIDE_MESSENGER, cb);
replaceSubscriber(ChannelModule.Event.ON_HIDE_MESSENGER, subscription);
} else {
replaceSubscriber(ChannelModule.Event.ON_HIDE_MESSENGER, null);
}
},
/**
* Event listener that triggers when `ChannelIO` messenger is about to dismiss
* @param {Function} cb a callback function
Expand Down
6 changes: 3 additions & 3 deletions ios/RNChannelIO.m
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@ - (NSDictionary *)constantsToExport {
[CrossPlatformUtils openBrowserWithUrl:url];
}

RCT_EXPORT_METHOD(setPage:(NSString *)page) {
[ChannelIO setPage:page profile:[[NSDictionary alloc] init]];
RCT_EXPORT_METHOD(setPageNull:(NSDictionary<NSString *, id> *)profile) {
[ChannelIO setPage:NULL profile:profile];
}

RCT_EXPORT_METHOD(setPage:(NSString *)page profile:(NSDictionary<NSString *, id> *)profile) {
RCT_EXPORT_METHOD(setPage:(nullable NSString *)page profile:(NSDictionary<NSString *, id> *)profile) {
[ChannelIO setPage:page profile:profile];
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-channel-plugin",
"version": "0.11.2",
"version": "0.11.3",
"description": "react native module for channel io",
"main": "index.ts",
"scripts": {
Expand Down