diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..8c23d434 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,2 @@ +team-messenger: + - base-branch: 'main' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..659ac26b --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 5efda89f..85ad2683 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,5 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version ruby '2.7.5' -gem 'cocoapods', '~> 1.11', '>= 1.11.2' +gem 'activesupport', '7.0.8' +gem 'cocoapods', '~> 1.12.1' diff --git a/README.md b/README.md index 906e47c2..b28238f9 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ public void onCreate() { } ``` -- Open `android/build.gradle` and change `minSdkVersion` to **21**, `compileSdkVersion` and `targetSdkVersion` to at least **33** +- Open `android/build.gradle` and change `minSdkVersion` to **21**, `compileSdkVersion` to at least **34** and `targetSdkVersion` to at least **33** ```Gradle buildscript { @@ -97,7 +97,7 @@ buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 // <-- Here - compileSdkVersion = 33 // <-- Here + compileSdkVersion = 34 // <-- Here targetSdkVersion = 33 // <-- Here } // ... @@ -427,6 +427,52 @@ See the [example app](https://github.com/intercom/intercom-react-native/blob/mai ___ +### Expo + +If you are using Expo, you can use the built-in plugin. + +After installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`: + +```json +{ + "expo": { + "plugins": ["@intercom/intercom-react-native"] + } +} +``` + +The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used. + +- `appId` (_string_): App ID from Intercom. +- `androidApiKey` (_string_): Android API Key from Intercom. +- `iosApiKey` (_string_): iOS API Key from Intercom. +- `intercomRegion` (_string_): Region for Intercom `US`, `EU`, `AU`. Optional. Defaults to `US`. + +```json +{ + "expo": { + "plugins": [ + [ + "@intercom/intercom-react-native", + { + "appId": "abc123", + "androidApiKey": "android_sdk-abc123", + "iosApiKey": "ios_sdk-abc123", + "intercomRegion": "EU" // Europe + } + ] + ] + } +} +``` + +Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide. + +#### Limitations + +- **No push notifications support**: Intercom push notifications currently aren't supported by this config plugin extension. This will be added in the future. + + ## Methods ## Import @@ -613,7 +659,7 @@ Handles the opening of an Intercom push message. This will retrieve the URI from `Promise` ___ -### `Intercom.displayMessenger()` +### `Intercom.present()` Opens the Intercom Messenger automatically to the best place for your users. diff --git a/REPO_OWNER b/REPO_OWNER new file mode 100644 index 00000000..5f38657c --- /dev/null +++ b/REPO_OWNER @@ -0,0 +1 @@ +team-messenger diff --git a/android/build.gradle b/android/build.gradle index 94c7b02c..f1fe27fc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -23,10 +23,16 @@ def safeExtGet(prop, fallback) { } android { - compileSdkVersion safeExtGet('IntercomReactNative_compileSdkVersion', 33) + // Compatibility for AGP v. <4.2/Gradle 8 + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger() + if (agpVersion >= 7) { + namespace 'com.intercom.reactnative' + } + + compileSdkVersion safeExtGet('IntercomReactNative_compileSdkVersion', 34) defaultConfig { minSdkVersion safeExtGet('IntercomReactNative_minSdkVersion', 21) - targetSdkVersion safeExtGet('IntercomReactNative_targetSdkVersion', 33) + targetSdkVersion safeExtGet('IntercomReactNative_targetSdkVersion', 34) versionCode 1 versionName "1.0" buildConfigField 'String', 'INTERCOM_VERSION_NAME', packageVersion @@ -40,9 +46,12 @@ android { lintOptions { disable 'GradleCompatible' } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + + if (agpVersion < 8) { + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } } @@ -60,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.1.+' + implementation 'io.intercom.android:intercom-sdk:15.4.0' } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index c894b62c..0a0938ae 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,3 @@ - + diff --git a/android/src/main/java/com/intercom/reactnative/IntercomModule.java b/android/src/main/java/com/intercom/reactnative/IntercomModule.java index f53f6959..623f54fe 100644 --- a/android/src/main/java/com/intercom/reactnative/IntercomModule.java +++ b/android/src/main/java/com/intercom/reactnative/IntercomModule.java @@ -267,18 +267,21 @@ public void presentIntercom(Promise promise) { public void presentIntercomSpace(String space, Promise promise) { try { IntercomSpace selectedSpace = IntercomSpace.Home; - if (space.equals("HOME")) { - selectedSpace = IntercomSpace.Home; - Intercom.client().present(selectedSpace); - } else { - if (space.equals("MESSAGES")) { + switch (space) { + case "TICKETS": + selectedSpace = IntercomSpace.Tickets; + break; + case "MESSAGES": selectedSpace = IntercomSpace.Messages; - } else if (space.equals("HELP_CENTER")) { + break; + case "HELP_CENTER": selectedSpace = IntercomSpace.HelpCenter; - } - Intercom.client().present(selectedSpace); - promise.resolve(true); + break; + default: + selectedSpace = IntercomSpace.Home; } + Intercom.client().present(selectedSpace); + promise.resolve(true); } catch (Exception error) { Log.e(NAME, "presentIntercomSpace error:"); Log.e(NAME, error.toString()); diff --git a/app.plugin.js b/app.plugin.js new file mode 100644 index 00000000..7020f912 --- /dev/null +++ b/app.plugin.js @@ -0,0 +1,16 @@ +const packageJson = require('./package.json'); + +const pkg = { + // Prevent this plugin from being run more than once. + // This pattern enables users to safely migrate off of this + // out-of-tree `@config-plugins/intercom-react-native` to a future + // upstream plugin in `intercom-react-native` + name: packageJson.name, + // Indicates that this plugin is dangerously linked to a module, + // and might not work with the latest version of that module. + version: packageJson.version, +}; + +const plugin = require('./lib/commonjs/expo-plugins'); + +module.exports = plugin.default(pkg); diff --git a/example/README.md b/example/README.md index 8ccdd637..e3f9df48 100644 --- a/example/README.md +++ b/example/README.md @@ -5,8 +5,6 @@ To get started with the @intercom/intercom-react-native example app, please follow the instructions below: 1. Install XCode before you setup the app. ->Please note that there is a known bug that prevents the iOS app from building on the latest Xcode. Therefore, it's recommended to use Xcode 14.2. - 2. Setup the app using: ```sh @@ -21,7 +19,11 @@ sh scripts/generateEnv.sh This command will create a .env file inside the example directory. Fill in the required App ID in the .env file. Other variables are optional. +## Before you run the app + +Please set up your React Native Development Environment for Android as described in the guide below (if you didn't do it before): +[Android enviroment setup](https://reactnative.dev/docs/environment-setup?package-manager=yarn&guide=native&platform=android) ## Running the app @@ -46,4 +48,4 @@ pod install 2. For issues related to android, try opening and running the example app from the android studio. -3. For general iOS build errors, opening and running the example app from XCode also helps. \ No newline at end of file +3. For general iOS build errors, opening and running the example app from XCode also helps. diff --git a/example/android/build.gradle b/example/android/build.gradle index 5a4f5ec7..286af022 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -7,7 +7,7 @@ buildscript { ext { buildToolsVersion = "30.0.2" minSdkVersion = 21 - compileSdkVersion = 33 + compileSdkVersion = 34 targetSdkVersion = 33 ndkVersion = "20.1.5948944" } diff --git a/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj b/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj index f76f52d7..b06a3eeb 100644 --- a/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj +++ b/example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj @@ -166,8 +166,8 @@ 7D95B165267240E3008096E0 /* Frameworks */, 7D95B167267240E3008096E0 /* Resources */, 7D95B16A267240E3008096E0 /* Bundle React Native code and images */, - 2E290AEE444BD7895C572BEF /* [CP] Embed Pods Frameworks */, AD4381D24626F6203C6978AC /* [CP] Copy Pods Resources */, + AA5BB63B02167C167F5286EE /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -250,23 +250,6 @@ shellPath = /bin/sh; shellScript = "set -e\n\nexport NODE_BINARY=node\nexport ENTRY_FILE=index.tsx\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; }; - 2E290AEE444BD7895C572BEF /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExampleUI/Pods-IntercomReactNativeExampleUI-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExampleUI/Pods-IntercomReactNativeExampleUI-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExampleUI/Pods-IntercomReactNativeExampleUI-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 4F0A6FC082772762E3E4C96C /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -344,6 +327,23 @@ shellPath = /bin/sh; shellScript = "set -e\n\nexport NODE_BINARY=node\nexport ENTRY_FILE=index.tsx\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; }; + AA5BB63B02167C167F5286EE /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExampleUI/Pods-IntercomReactNativeExampleUI-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExampleUI/Pods-IntercomReactNativeExampleUI-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExampleUI/Pods-IntercomReactNativeExampleUI-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; AD4381D24626F6203C6978AC /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/example/ios/IntercomReactNativeExample/IntercomReactNativeExample.entitlements b/example/ios/IntercomReactNativeExample/IntercomReactNativeExample.entitlements index 0c67376e..903def2a 100644 --- a/example/ios/IntercomReactNativeExample/IntercomReactNativeExample.entitlements +++ b/example/ios/IntercomReactNativeExample/IntercomReactNativeExample.entitlements @@ -1,5 +1,8 @@ - + + aps-environment + development + diff --git a/example/ios/IntercomReactNativeExample/IntercomReactNativeExampleRelease.entitlements b/example/ios/IntercomReactNativeExample/IntercomReactNativeExampleRelease.entitlements index 903def2a..28c29bf6 100644 --- a/example/ios/IntercomReactNativeExample/IntercomReactNativeExampleRelease.entitlements +++ b/example/ios/IntercomReactNativeExample/IntercomReactNativeExampleRelease.entitlements @@ -3,6 +3,6 @@ aps-environment - development + production diff --git a/example/ios/Podfile b/example/ios/Podfile index 28c9f666..002d606b 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -44,6 +44,7 @@ target 'IntercomReactNativeExample' do config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0' end config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION'] end end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 1dd2e76f..bb7e799b 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -73,9 +73,9 @@ PODS: - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) - - Intercom (15.0.2) - - intercom-react-native (5.1.2): - - Intercom (~> 15.0.2) + - Intercom (16.5.9) + - intercom-react-native (6.6.0): + - Intercom (~> 16.5.9) - React-Core - libevent (2.1.12) - OpenSSL-Universal (1.1.1100) @@ -360,7 +360,7 @@ PODS: - React-perflogger (= 0.70.9) - RNCAsyncStorage (1.18.1): - React-Core - - SocketRocket (0.6.0) + - SocketRocket (0.6.1) - Yoga (1.14.0) - YogaKit (1.18.1): - Yoga (~> 1.14) @@ -533,8 +533,8 @@ SPEC CHECKSUMS: FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b - Intercom: bb499c2bdeacaabb498c94572afa5fcfd74294eb - intercom-react-native: 00d89b6267abc4470949a071bfac4550fbeb6deb + Intercom: d9c81b3e45e6ecd9b2db2dc188d0521a40393f56 + intercom-react-native: 4f1166b40dd470211521a55893a4957614cccfd5 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda @@ -565,10 +565,10 @@ SPEC CHECKSUMS: React-runtimeexecutor: ed23be8c1e02b73e7e2f88ac7eaab8faf6961a38 ReactCommon: 153bd73ed963731a8e3e7f03a747b353fed7363e RNCAsyncStorage: b90b71f45b8b97be43bc4284e71a6af48ac9f547 - SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 + SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: dc109b79db907f0f589fc423e991b09ec42d2295 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 9f0fd08562d3218b07861937dd89c963bff7aaa8 +PODFILE CHECKSUM: a7cafffdaddc0dfe4e20cc0d2b857d47f9bcf58b COCOAPODS: 1.12.1 diff --git a/example/src/App.tsx b/example/src/App.tsx index b56349f4..aae70dc4 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -29,6 +29,7 @@ import { COLLECTION_ID, SEARCH_TERM, TOKEN, + CONVERSATION_ID, } from './constants'; import Button from './components/Button'; @@ -48,6 +49,9 @@ export default function App() { const [launcherVisibility, setLauncherVisibility] = useState(false); const [user, setUser] = useState({ email: '' }); + const [conversationId, setConversationId] = useState( + CONVERSATION_ID + ); const [articleId, setArticleId] = useState(ARTICLE_ID); const [carouselId, setCarouselId] = useState(CAROUSEL_ID); const [surveyId, setSurveyId] = useState(SURVEY_ID); @@ -90,6 +94,7 @@ export default function App() { Intercom.setInAppMessageVisibility(Visibility.VISIBLE).then(() => setInAppMessageVisibility(true) ); + setConversationId(CONVERSATION_ID); setArticleId(ARTICLE_ID); setCarouselId(CAROUSEL_ID); setSurveyId(SURVEY_ID); @@ -249,13 +254,21 @@ export default function App() { }} />