Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/example/e2e/chromedr…
Browse files Browse the repository at this point in the history
…iver-119.0.1
  • Loading branch information
uddish authored Mar 11, 2024
2 parents 617044d + 82faf60 commit c506148
Show file tree
Hide file tree
Showing 17 changed files with 472 additions and 50 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
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ___
- [Permissions](#ios-permissions)
- [Push Notifications](#ios-push-notifications)
- [Push notification deep links support](#ios-push-notification-deep-links-support)
- [Expo](#expo)
- [Limitations](#limitations)
- [Common methods](#methods)
- [Types](#types)
- [Usage](#usage)
Expand Down Expand Up @@ -427,6 +429,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 +661,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
15 changes: 12 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def safeExtGet(prop, fallback) {
}

android {
// 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)
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 Down
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>
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);
2 changes: 0 additions & 2 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 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>
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 (16.0.1)
- intercom-react-native (6.0.0):
- Intercom (~> 16.0.1)
- 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 @@ -519,7 +519,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: bc76253beb7463b688aa6af913b822ed631de31a
FBReactNativeSpec: 85d34420d92cb178897de05e3aba90e7a8568162
Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0
Expand All @@ -532,9 +532,9 @@ SPEC CHECKSUMS:
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 5337263514dd6f09803962437687240c5dc39aa4
Intercom: 62fe4d94519fba99f17df3f7a0c62dc7dbcb7b02
intercom-react-native: 7bf5734cca0629303b514e188e60d7d87c17338c
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
Intercom: d9c81b3e45e6ecd9b2db2dc188d0521a40393f56
intercom-react-native: 4f1166b40dd470211521a55893a4957614cccfd5
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
Expand Down Expand Up @@ -571,4 +571,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: a7cafffdaddc0dfe4e20cc0d2b857d47f9bcf58b

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
28 changes: 14 additions & 14 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1792,11 +1792,11 @@ available-typed-arrays@^1.0.5:
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

axios@^1.1.3:
version "1.4.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
version "1.6.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
dependencies:
follow-redirects "^1.15.0"
follow-redirects "^1.15.4"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

Expand Down Expand Up @@ -3021,10 +3021,10 @@ flow-parser@^0.121.0:
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.121.0.tgz#9f9898eaec91a9f7c323e9e992d81ab5c58e618f"
integrity sha512-1gIBiWJNR0tKUNv8gZuk7l9rVX06OuLzY9AoGio7y/JT4V1IZErEMEq2TJS+PFcw/y0RshZ1J/27VfK1UQzYVg==

follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
follow-redirects@^1.15.4:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==

for-each@^0.3.3:
version "0.3.3"
Expand Down Expand Up @@ -5770,14 +5770,14 @@ scheduler@^0.22.0:
loose-envify "^1.1.0"

"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
version "5.7.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==

semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

[email protected]:
version "0.18.0"
Expand Down
2 changes: 1 addition & 1 deletion intercom-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Pod::Spec.new do |s|
s.resource_bundles = { 'IntercomFramework' => ['ios/assets/*'] }

s.dependency "React-Core"
s.dependency "Intercom", '~> 16.2.3'
s.dependency "Intercom", '~> 16.5.9'
end
11 changes: 2 additions & 9 deletions ios/IntercomModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,8 @@ - (NSData *)dataFromHexString:(NSString *)string {
RCT_EXPORT_METHOD(loginUserWithUserAttributes:(NSDictionary *)userAttributes
success:(RCTPromiseResolveBlock)successCallback
failure:(RCTResponseErrorBlock)failureCallback) {
NSString *userId = userAttributes[@"userId"];
NSString *userEmail = userAttributes[@"email"];
ICMUserAttributes *attributes = [IntercomAttributesBuilder userAttributesForDictionary:userAttributes];

if ([userId isKindOfClass:[NSNumber class]]) {
userId = [(NSNumber *) userId stringValue];
}
ICMUserAttributes *attributes = [ICMUserAttributes new];
attributes.userId = userId;
attributes.email = userEmail;
[Intercom loginUserWithUserAttributes:attributes success:^{
successCallback(@(YES));
} failure:^(NSError * _Nonnull error) {
Expand Down Expand Up @@ -203,7 +196,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
selectedSpace = messages;
} else if ([space isEqualToString:@"TICKETS"]) {
selectedSpace = tickets;
}
}
[Intercom presentIntercom:selectedSpace];
RCTLog(@"Presenting Intercom Space : %@", space);
resolve(@(YES));
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@intercom/intercom-react-native",
"version": "6.2.0",
"version": "6.8.1",
"description": "React Native wrapper to bridge our iOS and Android SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand All @@ -13,6 +13,7 @@
"android",
"ios",
"cpp",
"app.plugin.js",
"intercom-react-native.podspec",
"!lib/typescript/example",
"!android/build",
Expand Down Expand Up @@ -53,6 +54,7 @@
"access": "public"
},
"devDependencies": {
"@expo/config-plugins": "^7.8.4",
"@react-native-community/eslint-config": "^2.0.0",
"@types/jest": "^26.0.0",
"@types/mocha": "^8.2.2",
Expand Down
8 changes: 8 additions & 0 deletions src/expo-plugins/@types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type IntercomRegion = 'US' | 'EU' | 'AU';

export type IntercomPluginProps = {
iosApiKey: string;
androidApiKey: string;
appId: string;
intercomRegion?: IntercomRegion;
};
Loading

0 comments on commit c506148

Please sign in to comment.