Skip to content

Commit 0d19246

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/example/e2e/follow-redirects-and-appium-base-driver-1.15.6
2 parents ce6ca0d + 820f934 commit 0d19246

23 files changed

+2647
-1972
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ Fetch a list of all Collections.
853853
___
854854
### `Intercom.fetchHelpCenterCollection(collectionId)`
855855

856-
Get a list of sections/articles for a collection.
856+
Get a list of subcollections/articles for a collection.
857857

858858
### Options
859859

@@ -1022,11 +1022,6 @@ type HelpCenterArticle = {
10221022
title: string;
10231023
};
10241024

1025-
type HelpCenterSection = {
1026-
name: string;
1027-
articles: HelpCenterArticle;
1028-
};
1029-
10301025
type HelpCenterCollectionItem = {
10311026
id: string;
10321027
title: string;
@@ -1038,7 +1033,7 @@ type HelpCenterCollectionContent = {
10381033
name: string;
10391034
summary: string;
10401035
articles: HelpCenterArticle[];
1041-
sections: HelpCenterSection[];
1036+
collections: HelpCenterCollectionItem[];
10421037
};
10431038

10441039
type HelpCenterArticleSearchResult = {

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ dependencies {
6969
//noinspection GradleDynamicVersion
7070
implementation "com.facebook.react:react-native:+" // From node_modules
7171
implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '20.2.+')}"
72-
implementation 'io.intercom.android:intercom-sdk:15.10.+'
72+
implementation 'io.intercom.android:intercom-sdk:15.11.+'
7373
}

android/src/main/java/com/intercom/reactnative/IntercomHelpCenterHelpers.java

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import io.intercom.android.sdk.helpcenter.collections.HelpCenterCollection;
1515
import io.intercom.android.sdk.helpcenter.sections.HelpCenterArticle;
1616
import io.intercom.android.sdk.helpcenter.sections.HelpCenterCollectionContent;
17-
import io.intercom.android.sdk.helpcenter.sections.HelpCenterSection;
1817

1918
public class IntercomHelpCenterHelpers {
2019

@@ -59,38 +58,13 @@ public static WritableMap parseHelpCenterCollectionsContentToReadableMap(HelpCen
5958
WritableArray articles = parseArticlesToReadableArray(helpCenterCollectionContent.getHelpCenterArticles());
6059
helpCenterCollection.putArray("articles", articles);
6160

62-
WritableArray sections = parseHelpCenterSectionsToReadableArray(helpCenterCollectionContent.getHelpCenterSections());
63-
helpCenterCollection.putArray("sections", sections);
61+
WritableArray collections = parseHelpCenterCollectionsToReadableArray(helpCenterCollectionContent.getSubCollections());
62+
helpCenterCollection.putArray("collections", collections);
6463

6564

6665
return helpCenterCollection;
6766
}
6867

69-
public static WritableMap parseHelpCenterSectionToReadableMap(HelpCenterSection helpCenterSection) {
70-
WritableMap section = Arguments.createMap();
71-
section.putString("title", helpCenterSection.getTitle());
72-
73-
74-
WritableArray articles = parseArticlesToReadableArray(helpCenterSection.getHelpCenterArticles());
75-
section.putArray("articles", articles);
76-
77-
78-
return section;
79-
}
80-
81-
public static WritableArray parseHelpCenterSectionsToReadableArray(List<HelpCenterSection> helpCenterSectionList) {
82-
WritableArray sections = Arguments.createArray();
83-
84-
HelpCenterSection[] sectionsArray = new HelpCenterSection[helpCenterSectionList.size()];
85-
sectionsArray = helpCenterSectionList.toArray(sectionsArray);
86-
;
87-
88-
for (HelpCenterSection section : sectionsArray) {
89-
sections.pushMap(parseHelpCenterSectionToReadableMap(section));
90-
}
91-
return sections;
92-
}
93-
9468
public static WritableArray parseHelpCenterCollectionsToReadableArray(List<HelpCenterCollection> helpCenterCollections) {
9569
HelpCenterCollection[] collectionsArray = new HelpCenterCollection[helpCenterCollections.size()];
9670
collectionsArray = helpCenterCollections.toArray(collectionsArray);

android/src/main/java/com/intercom/reactnative/IntercomHelpers.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.facebook.react.bridge.ReadableMap;
77
import com.facebook.react.bridge.ReadableMapKeySetIterator;
88
import com.facebook.react.bridge.ReadableType;
9+
import com.facebook.react.bridge.Arguments;
10+
import com.facebook.react.bridge.WritableMap;
911

1012
import java.util.ArrayList;
1113
import java.util.Date;
@@ -16,6 +18,7 @@
1618
import io.intercom.android.sdk.Company;
1719
import io.intercom.android.sdk.Intercom;
1820
import io.intercom.android.sdk.UserAttributes;
21+
import io.intercom.android.sdk.identity.Registration;
1922

2023
public class IntercomHelpers {
2124

@@ -241,4 +244,15 @@ public static String getValueAsStringForKey(ReadableMap map, String key) {
241244
}
242245
return value;
243246
}
247+
248+
public static WritableMap deconstructRegistration(Registration registration) {
249+
WritableMap registrationMap = Arguments.createMap();
250+
if (registration.getEmail() != null) {
251+
registrationMap.putString("email", registration.getEmail());
252+
}
253+
if (registration.getUserId() != null) {
254+
registrationMap.putString("userId", registration.getUserId());
255+
}
256+
return registrationMap;
257+
}
244258
}

android/src/main/java/com/intercom/reactnative/IntercomModule.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ public void onFailure(@NonNull IntercomError intercomError) {
196196
});
197197
}
198198

199+
@ReactMethod
200+
public void isUserLoggedIn(Promise promise) {
201+
promise.resolve(Intercom.client().isUserLoggedIn());
202+
}
203+
204+
@ReactMethod
205+
public void fetchLoggedInUserAttributes(Promise promise) {
206+
Registration registration = Intercom.client().fetchLoggedInUserAttributes();
207+
promise.resolve(IntercomHelpers.deconstructRegistration(registration));
208+
}
209+
199210
@ReactMethod
200211
public void logout(Promise promise) {
201212
try {

example/e2e/package-lock.json

Lines changed: 71 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)