Skip to content

Commit 519a96e

Browse files
Add presentArticle method (#439)
* replace deprecated reset with logout method * feature: add presentArticle method * fix: rename react method Co-authored-by: iagormoraesdevsquad <iagor@devsquad.com>
1 parent 89cd1a4 commit 519a96e

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

android/src/main/java/com/robinpowered/react/Intercom/IntercomModule.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ public void presentCarousel(String carouselID, Promise promise) {
106106
}
107107
}
108108

109+
@ReactMethod
110+
public void presentArticle(String articleID, Promise promise) {
111+
try {
112+
Intercom.client().displayArticle(articleID);
113+
Log.i(TAG, "displayArticle");
114+
promise.resolve(null);
115+
} catch(Exception e) {
116+
promise.reject(e.toString());
117+
}
118+
}
119+
109120
@ReactMethod
110121
public void registerUnidentifiedUser(Promise promise) {
111122
try {

iOS/IntercomWrapper.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,20 @@ @implementation IntercomWrapper
6161
resolve([NSNull null]);
6262
};
6363

64-
// Available as NativeModules.IntercomWrapper.registerUnidentifiedUser
64+
// Available as NativeModules.IntercomWrapper.presentCarousel
6565
RCT_EXPORT_METHOD(presentCarousel:(NSString*)carouselID resolver: (RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) {
66-
NSLog(@"registerUnidentifiedUser");
66+
NSLog(@"presentCarousel");
6767
[Intercom presentCarousel:carouselID];
6868
resolve([NSNull null]);
6969
};
7070

71+
// Available as NativeModules.IntercomWrapper.presentArticle
72+
RCT_EXPORT_METHOD(presentArticle:(NSString*)articleID resolver: (RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) {
73+
NSLog(@"presentArticle");
74+
[Intercom presentArticle:articleID];
75+
resolve([NSNull null]);
76+
};
77+
7178
// Available as NativeModules.IntercomWrapper.logout
7279
RCT_EXPORT_METHOD(logout :(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject) {
7380
NSLog(@"logout");

index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ export function sendTokenToIntercom(token: any): Promise<void>;
2020

2121
/**
2222
* presentCarousel
23-
* @param token
23+
* @param carouselID
2424
*/
2525
export function presentCarousel(carouselID: String): Promise<void>;
2626

27+
/**
28+
* presentArticle
29+
* @param articleID
30+
*/
31+
export function presentArticle(articleID: String): Promise<void>;
32+
2733
/**
2834
* registerUnidentifiedUser
2935
* @returns {Promise<void>}

lib/IntercomClient.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ class IntercomClient {
8787
return IntercomWrapper.displayHelpCenter();
8888
}
8989

90-
setLauncherVisibility(visibility: String) {
90+
setLauncherVisibility(visibility) {
9191
return IntercomWrapper.setLauncherVisibility(visibility);
9292
}
9393

94-
setInAppMessageVisibility(visibility: String) {
94+
setInAppMessageVisibility(visibility) {
9595
return IntercomWrapper.setInAppMessageVisibility(visibility);
9696
}
9797

@@ -111,10 +111,14 @@ class IntercomClient {
111111
return IntercomWrapper.setBottomPadding(padding);
112112
}
113113

114-
presentCarousel(carousel: String) {
114+
presentCarousel(carousel) {
115115
return IntercomWrapper.presentCarousel(carousel);
116116
}
117117

118+
presentArticle(articleId) {
119+
return IntercomWrapper.presentArticle(articleId);
120+
}
121+
118122
addEventListener(type, handler) {
119123
if (!this._eventEmitter) {
120124
this._eventEmitter = new NativeEventEmitter(IntercomEventEmitter);

0 commit comments

Comments
 (0)