Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/example/semver-5.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
uddish authored Mar 11, 2024
2 parents 8d8a238 + e72b72e commit 797077e
Show file tree
Hide file tree
Showing 26 changed files with 768 additions and 222 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
team-messenger:
- base-branch: 'main'
12 changes: 12 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ 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 {
// ...
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 21 // <-- Here
compileSdkVersion = 33 // <-- Here
compileSdkVersion = 34 // <-- Here
targetSdkVersion = 33 // <-- Here
}
// ...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -613,7 +659,7 @@ Handles the opening of an Intercom push message. This will retrieve the URI from
`Promise<boolean>`
___

### `Intercom.displayMessenger()`
### `Intercom.present()`

Opens the Intercom Messenger automatically to the best place for your users.

Expand Down
1 change: 1 addition & 0 deletions REPO_OWNER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
team-messenger
21 changes: 15 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}

Expand All @@ -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'
}
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intercom.reactnative">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
21 changes: 12 additions & 9 deletions android/src/main/java/com/intercom/reactnative/IntercomModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
16 changes: 16 additions & 0 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -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);
8 changes: 5 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +19,11 @@ sh scripts/generateEnv.sh
This command will create a .env file <b>inside the example directory</b>.
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

Expand All @@ -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.
3. For general iOS build errors, opening and running the example app from XCode also helps.
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 33
ndkVersion = "20.1.5948944"
}
Expand Down
36 changes: 18 additions & 18 deletions example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<string>production</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading

0 comments on commit 797077e

Please sign in to comment.