Skip to content

Commit f85d913

Browse files
authored
Release 8.1.0 (#231)
* Now exposing new APIs * Updated to include privacy manifest in sample Xcode project * Fixed linting errors
1 parent 1b2a448 commit f85d913

File tree

13 files changed

+164
-14
lines changed

13 files changed

+164
-14
lines changed

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/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/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
7D95B168267240E3008096E0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
1818
7D95B169267240E3008096E0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1919
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
20-
DE090379E5BDFCC31EBBB1FC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D19CD0A976BD44CB326047B6 /* PrivacyInfo.xcprivacy */; };
20+
DE090379E5BDFCC31EBBB1FC /* BuildFile in Resources */ = {isa = PBXBuildFile; };
2121
/* End PBXBuildFile section */
2222

2323
/* Begin PBXFileReference section */
@@ -75,7 +75,6 @@
7575
13B07FB61A68108700A75B9A /* Info.plist */,
7676
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
7777
13B07FB71A68108700A75B9A /* main.m */,
78-
D19CD0A976BD44CB326047B6 /* PrivacyInfo.xcprivacy */,
7978
);
8079
name = IntercomReactNativeExample;
8180
sourceTree = "<group>";
@@ -223,7 +222,7 @@
223222
files = (
224223
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
225224
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
226-
DE090379E5BDFCC31EBBB1FC /* PrivacyInfo.xcprivacy in Resources */,
225+
DE090379E5BDFCC31EBBB1FC /* BuildFile in Resources */,
227226
);
228227
runOnlyForDeploymentPostprocessing = 0;
229228
};
@@ -646,7 +645,10 @@
646645
ONLY_ACTIVE_ARCH = YES;
647646
OTHER_CFLAGS = "$(inherited)";
648647
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
649-
OTHER_LDFLAGS = "$(inherited) ";
648+
OTHER_LDFLAGS = (
649+
"$(inherited)",
650+
" ",
651+
);
650652
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
651653
SDKROOT = iphoneos;
652654
USE_HERMES = false;
@@ -712,7 +714,10 @@
712714
MTL_ENABLE_DEBUG_INFO = NO;
713715
OTHER_CFLAGS = "$(inherited)";
714716
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
715-
OTHER_LDFLAGS = "$(inherited) ";
717+
OTHER_LDFLAGS = (
718+
"$(inherited)",
719+
" ",
720+
);
716721
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
717722
SDKROOT = iphoneos;
718723
USE_HERMES = false;

example/ios/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ PODS:
1111
- ReactCommon/turbomodule/core (= 0.73.8)
1212
- fmt (6.2.1)
1313
- glog (0.3.5)
14-
- Intercom (18.1.0)
15-
- intercom-react-native (8.0.0):
16-
- Intercom (~> 18.1.0)
14+
- Intercom (18.2.0)
15+
- intercom-react-native (8.1.0):
16+
- Intercom (~> 18.2.0)
1717
- React-Core
1818
- RCT-Folly (2022.05.16.00):
1919
- boost
@@ -1197,8 +1197,8 @@ SPEC CHECKSUMS:
11971197
FBReactNativeSpec: bbe8b686178e5ce03d1d8a356789f211f91f31b8
11981198
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
11991199
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
1200-
Intercom: b3a7282d46c7a670d805b70430cb929d9473ddb1
1201-
intercom-react-native: f4e484301273c2a2ff7c1839eb3c9c2da1c0aa26
1200+
Intercom: e6febbddf5cfa4a15629c1d075b01a9825a23ad9
1201+
intercom-react-native: 2f0b89429e93befa1180dde37fc7d8916b762157
12021202
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
12031203
RCTRequired: 0c7f03a41ee32dec802c74c341e317a4165973d5
12041204
RCTTypeSafety: 57698bb7fcde424922e201dab377f496a08a63e3
@@ -1247,4 +1247,4 @@ SPEC CHECKSUMS:
12471247

12481248
PODFILE CHECKSUM: 15fb131f3e1a2b2d9a606515df1414680c8e67b5
12491249

1250-
COCOAPODS: 1.12.1
1250+
COCOAPODS: 1.15.2

example/ios/PrivacyInfo.xcprivacy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyAccessedAPITypes</key>
6+
<array>
7+
<dict>
8+
<key>NSPrivacyAccessedAPIType</key>
9+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
10+
<key>NSPrivacyAccessedAPITypeReasons</key>
11+
<array>
12+
<string>C617.1</string>
13+
</array>
14+
</dict>
15+
<dict>
16+
<key>NSPrivacyAccessedAPIType</key>
17+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
18+
<key>NSPrivacyAccessedAPITypeReasons</key>
19+
<array>
20+
<string>CA92.1</string>
21+
</array>
22+
</dict>
23+
<dict>
24+
<key>NSPrivacyAccessedAPIType</key>
25+
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
26+
<key>NSPrivacyAccessedAPITypeReasons</key>
27+
<array>
28+
<string>35F9.1</string>
29+
</array>
30+
</dict>
31+
</array>
32+
<key>NSPrivacyCollectedDataTypes</key>
33+
<array/>
34+
<key>NSPrivacyTracking</key>
35+
<false/>
36+
</dict>
37+
</plist>

example/src/App.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ export default function App() {
7777
Alert.alert(field, `Provided ${field} is not of correct format`);
7878
};
7979

80+
const showLoggedInStatusAlert = () => {
81+
Intercom.isUserLoggedIn().then((res) => {
82+
Alert.alert(`Logged in status: ${res ? 'Yes' : 'No'}`);
83+
});
84+
};
85+
86+
const showLoggedInUserAttributes = () => {
87+
Intercom.fetchLoggedInUserAttributes().then((res) => {
88+
Alert.alert('User Attributes', JSON.stringify(res));
89+
});
90+
};
91+
8092
const validateEmail = (email: string | undefined) => {
8193
return String(email)
8294
.toLowerCase()
@@ -295,6 +307,22 @@ export default function App() {
295307
});
296308
}}
297309
/>
310+
<Button
311+
intercom_accessibilityLabel="show-logged-in-status"
312+
intercom_title="Show logged in status"
313+
intercom_onPress={() => {
314+
showLoggedInStatusAlert();
315+
}}
316+
/>
317+
<Button
318+
intercom_accessibilityLabel="show-logged-in-attributes"
319+
// intercom_disabled={!loggedUser}
320+
intercom_title="Show logged in attributes"
321+
intercom_onPress={() => {
322+
showLoggedInUserAttributes();
323+
}}
324+
/>
325+
298326
<Input
299327
title="Conversation Id"
300328
accessibilityLabel="conversation-id"

intercom-react-native.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ Pod::Spec.new do |s|
1818
s.resource_bundles = { 'IntercomFramework' => ['ios/assets/*'] }
1919

2020
s.dependency "React-Core"
21-
s.dependency "Intercom", '~> 18.1.0'
21+
s.dependency "Intercom", '~> 18.2.0'
2222
end

ios/IntercomAttributesBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
@interface IntercomAttributesBuilder : NSObject
55
+ (ICMUserAttributes *)userAttributesForDictionary:(NSDictionary *)attributesDict;
6+
+ (NSMutableDictionary *)dictionaryForUserAttributes:(ICMUserAttributes *)attributes;
67
@end

ios/IntercomAttributesBuilder.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,35 @@ + (ICMUserAttributes *)userAttributesForDictionary:(NSDictionary *)attributesDic
3939
return attributes;
4040
}
4141

42+
+ (NSMutableDictionary *)dictionaryForUserAttributes:(ICMUserAttributes *)attributes {
43+
NSMutableDictionary *attributesDict = [NSMutableDictionary new];
44+
if (attributes.email) {
45+
attributesDict[@"email"] = attributes.email;
46+
}
47+
if (attributes.userId) {
48+
attributesDict[@"userId"] = attributes.userId;
49+
}
50+
if (attributes.name) {
51+
attributesDict[@"name"] = attributes.name;
52+
}
53+
if (attributes.phone) {
54+
attributesDict[@"phone"] = attributes.phone;
55+
}
56+
if (attributes.languageOverride) {
57+
attributesDict[@"languageOverride"] = attributes.languageOverride;
58+
}
59+
if (attributes.signedUpAt) {
60+
attributesDict[@"signedUpAt"] = @([attributes.signedUpAt timeIntervalSince1970]);
61+
}
62+
if (attributes.unsubscribedFromEmails) {
63+
attributesDict[@"unsubscribedFromEmails"] = @(attributes.unsubscribedFromEmails);
64+
}
65+
if (attributes.customAttributes) {
66+
attributesDict[@"customAttributes"] = attributes.customAttributes;
67+
}
68+
return attributesDict;
69+
}
70+
4271
+ (ICMCompany *)companyForDictionary:(NSDictionary *)attributesDict {
4372
ICMCompany *company = [ICMCompany new];
4473
if ([self stringValueForKey:@"id" inDictionary:attributesDict]) {

0 commit comments

Comments
 (0)