From f85d913e03379248fb7c87d0f1c196e554c99353 Mon Sep 17 00:00:00 2001 From: Matthew Pierce Date: Mon, 4 Nov 2024 17:51:17 +0000 Subject: [PATCH] Release 8.1.0 (#231) * Now exposing new APIs * Updated to include privacy manifest in sample Xcode project * Fixed linting errors --- android/build.gradle | 2 +- .../intercom/reactnative/IntercomHelpers.java | 14 +++++++ .../intercom/reactnative/IntercomModule.java | 11 ++++++ .../project.pbxproj | 15 +++++--- example/ios/Podfile.lock | 12 +++--- example/ios/PrivacyInfo.xcprivacy | 37 +++++++++++++++++++ example/src/App.tsx | 28 ++++++++++++++ intercom-react-native.podspec | 2 +- ios/IntercomAttributesBuilder.h | 1 + ios/IntercomAttributesBuilder.m | 29 +++++++++++++++ ios/IntercomModule.m | 10 +++++ package.json | 2 +- src/index.tsx | 15 ++++++++ 13 files changed, 164 insertions(+), 14 deletions(-) create mode 100644 example/ios/PrivacyInfo.xcprivacy diff --git a/android/build.gradle b/android/build.gradle index 60ff9630..515e7410 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -69,5 +69,5 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '20.2.+')}" - implementation 'io.intercom.android:intercom-sdk:15.10.+' + implementation 'io.intercom.android:intercom-sdk:15.11.+' } diff --git a/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java b/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java index 3e50c408..584754df 100644 --- a/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java +++ b/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java @@ -6,6 +6,8 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMapKeySetIterator; import com.facebook.react.bridge.ReadableType; +import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.WritableMap; import java.util.ArrayList; import java.util.Date; @@ -16,6 +18,7 @@ import io.intercom.android.sdk.Company; import io.intercom.android.sdk.Intercom; import io.intercom.android.sdk.UserAttributes; +import io.intercom.android.sdk.identity.Registration; public class IntercomHelpers { @@ -241,4 +244,15 @@ public static String getValueAsStringForKey(ReadableMap map, String key) { } return value; } + + public static WritableMap deconstructRegistration(Registration registration) { + WritableMap registrationMap = Arguments.createMap(); + if (registration.getEmail() != null) { + registrationMap.putString("email", registration.getEmail()); + } + if (registration.getUserId() != null) { + registrationMap.putString("userId", registration.getUserId()); + } + return registrationMap; + } } diff --git a/android/src/main/java/com/intercom/reactnative/IntercomModule.java b/android/src/main/java/com/intercom/reactnative/IntercomModule.java index bd463e23..2b94bab5 100644 --- a/android/src/main/java/com/intercom/reactnative/IntercomModule.java +++ b/android/src/main/java/com/intercom/reactnative/IntercomModule.java @@ -196,6 +196,17 @@ public void onFailure(@NonNull IntercomError intercomError) { }); } + @ReactMethod + public void isUserLoggedIn(Promise promise) { + promise.resolve(Intercom.client().isUserLoggedIn()); + } + + @ReactMethod + public void fetchLoggedInUserAttributes(Promise promise) { + Registration registration = Intercom.client().fetchLoggedInUserAttributes(); + promise.resolve(IntercomHelpers.deconstructRegistration(registration)); + } + @ReactMethod public void logout(Promise promise) { try { diff --git a/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj b/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj index 62dd41e8..eeb4a373 100644 --- a/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj +++ b/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj @@ -17,7 +17,7 @@ 7D95B168267240E3008096E0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 7D95B169267240E3008096E0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; - DE090379E5BDFCC31EBBB1FC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D19CD0A976BD44CB326047B6 /* PrivacyInfo.xcprivacy */; }; + DE090379E5BDFCC31EBBB1FC /* BuildFile in Resources */ = {isa = PBXBuildFile; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -75,7 +75,6 @@ 13B07FB61A68108700A75B9A /* Info.plist */, 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 13B07FB71A68108700A75B9A /* main.m */, - D19CD0A976BD44CB326047B6 /* PrivacyInfo.xcprivacy */, ); name = IntercomReactNativeExample; sourceTree = ""; @@ -223,7 +222,7 @@ files = ( 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, - DE090379E5BDFCC31EBBB1FC /* PrivacyInfo.xcprivacy in Resources */, + DE090379E5BDFCC31EBBB1FC /* BuildFile in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -646,7 +645,10 @@ ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "$(inherited)"; OTHER_CPLUSPLUSFLAGS = "$(inherited)"; - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = false; @@ -712,7 +714,10 @@ MTL_ENABLE_DEBUG_INFO = NO; OTHER_CFLAGS = "$(inherited)"; OTHER_CPLUSPLUSFLAGS = "$(inherited)"; - OTHER_LDFLAGS = "$(inherited) "; + OTHER_LDFLAGS = ( + "$(inherited)", + " ", + ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; USE_HERMES = false; diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f13c658d..70132c85 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -11,9 +11,9 @@ PODS: - ReactCommon/turbomodule/core (= 0.73.8) - fmt (6.2.1) - glog (0.3.5) - - Intercom (18.1.0) - - intercom-react-native (8.0.0): - - Intercom (~> 18.1.0) + - Intercom (18.2.0) + - intercom-react-native (8.1.0): + - Intercom (~> 18.2.0) - React-Core - RCT-Folly (2022.05.16.00): - boost @@ -1197,8 +1197,8 @@ SPEC CHECKSUMS: FBReactNativeSpec: bbe8b686178e5ce03d1d8a356789f211f91f31b8 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b - Intercom: b3a7282d46c7a670d805b70430cb929d9473ddb1 - intercom-react-native: f4e484301273c2a2ff7c1839eb3c9c2da1c0aa26 + Intercom: e6febbddf5cfa4a15629c1d075b01a9825a23ad9 + intercom-react-native: 2f0b89429e93befa1180dde37fc7d8916b762157 RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0 RCTRequired: 0c7f03a41ee32dec802c74c341e317a4165973d5 RCTTypeSafety: 57698bb7fcde424922e201dab377f496a08a63e3 @@ -1247,4 +1247,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 15fb131f3e1a2b2d9a606515df1414680c8e67b5 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/example/ios/PrivacyInfo.xcprivacy b/example/ios/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..41b8317f --- /dev/null +++ b/example/ios/PrivacyInfo.xcprivacy @@ -0,0 +1,37 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + NSPrivacyCollectedDataTypes + + NSPrivacyTracking + + + diff --git a/example/src/App.tsx b/example/src/App.tsx index 54932b60..6abbc6f8 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -77,6 +77,18 @@ export default function App() { Alert.alert(field, `Provided ${field} is not of correct format`); }; + const showLoggedInStatusAlert = () => { + Intercom.isUserLoggedIn().then((res) => { + Alert.alert(`Logged in status: ${res ? 'Yes' : 'No'}`); + }); + }; + + const showLoggedInUserAttributes = () => { + Intercom.fetchLoggedInUserAttributes().then((res) => { + Alert.alert('User Attributes', JSON.stringify(res)); + }); + }; + const validateEmail = (email: string | undefined) => { return String(email) .toLowerCase() @@ -295,6 +307,22 @@ export default function App() { }); }} /> +