Skip to content

Commit 24a103a

Browse files
authored
Add a new expo app for react native (#188)
* added expo app * Added README * removed app id * removed android and ios folders * pr review * added minimum deployment target for ios * install expo-system-ui
1 parent 87d4be1 commit 24a103a

File tree

15 files changed

+21352
-0
lines changed

15 files changed

+21352
-0
lines changed

sandboxes/IntercomExpo/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# android and iOS folders
7+
android/
8+
ios/
9+
10+
# Expo
11+
.expo/
12+
dist/
13+
web-build/
14+
15+
# Native
16+
*.orig.*
17+
*.jks
18+
*.p8
19+
*.p12
20+
*.key
21+
*.mobileprovision
22+
23+
# Metro
24+
.metro-health-check*
25+
26+
# debug
27+
npm-debug.*
28+
yarn-debug.*
29+
yarn-error.*
30+
31+
# macOS
32+
.DS_Store
33+
*.pem
34+
35+
# local env files
36+
.env*.local
37+
38+
# typescript
39+
*.tsbuildinfo

sandboxes/IntercomExpo/App.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { useEffect } from 'react';
2+
import { StatusBar } from 'expo-status-bar';
3+
import {
4+
StyleSheet,
5+
AppState,
6+
Text,
7+
TextInput,
8+
TouchableOpacity,
9+
View,
10+
} from 'react-native';
11+
import Intercom, { Visibility } from '@intercom/intercom-react-native';
12+
import { useIntercom } from './useIntercom';
13+
import { styles } from './App.styles';
14+
15+
export default function App() {
16+
useEffect(() => {
17+
const subscription = AppState.addEventListener(
18+
'change',
19+
(nextStatus) => nextStatus === 'active' && Intercom.handlePushMessage()
20+
);
21+
return subscription.remove;
22+
}, []);
23+
24+
useEffect(() => {
25+
(async () => {
26+
await Intercom.setLauncherVisibility(Visibility.VISIBLE);
27+
})();
28+
}, []);
29+
30+
const {
31+
handleLoginIdentifiedUser,
32+
handleLoginUnidentifiedUser,
33+
handleLogout,
34+
setUserIdentifier,
35+
isLoggedIn,
36+
} = useIntercom();
37+
38+
return (
39+
<View style={styles.screenWrapper}>
40+
<Text style={styles.title}>Push Notifications Sandbox</Text>
41+
<View style={styles.wrapper}>
42+
{!isLoggedIn ? (
43+
<>
44+
<TextInput style={styles.input} onChangeText={setUserIdentifier} />
45+
<TouchableOpacity
46+
style={styles.button}
47+
onPress={handleLoginIdentifiedUser}
48+
>
49+
<Text style={styles.buttonText}>Login Identified User</Text>
50+
</TouchableOpacity>
51+
52+
<View style={styles.divider} />
53+
54+
<TouchableOpacity
55+
style={styles.button}
56+
onPress={handleLoginUnidentifiedUser}
57+
>
58+
<Text style={styles.buttonText}>Login Unidentified User</Text>
59+
</TouchableOpacity>
60+
</>
61+
) : (
62+
<TouchableOpacity style={styles.button} onPress={handleLogout}>
63+
<Text style={styles.buttonText}>Logout</Text>
64+
</TouchableOpacity>
65+
)}
66+
</View>
67+
</View>
68+
);
69+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
export const styles = StyleSheet.create({
4+
screenWrapper: {
5+
flex: 1,
6+
alignItems: 'center',
7+
justifyContent: 'center',
8+
},
9+
title: {
10+
position: 'absolute',
11+
top: '25%',
12+
fontWeight: 'bold',
13+
fontSize: 20,
14+
},
15+
wrapper: {
16+
width: '50%',
17+
},
18+
input: {
19+
borderWidth: 1,
20+
borderColor: 'rgba(0,0,80,0.2)',
21+
backgroundColor: '#f3f8ff',
22+
paddingVertical: 10,
23+
fontSize: 18,
24+
marginBottom: 10,
25+
},
26+
button: {
27+
backgroundColor: '#7284c5',
28+
paddingVertical: 13,
29+
alignItems: 'center',
30+
},
31+
buttonText: {
32+
color: '#fff',
33+
},
34+
divider: {
35+
marginVertical: 18,
36+
borderWidth: 0.5,
37+
borderColor: '#5757ca',
38+
},
39+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { MMKVLoader } from 'react-native-mmkv-storage';
2+
3+
export const storage = new MMKVLoader().initialize();

sandboxes/IntercomExpo/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Intercom React Native Expo Sandbox
2+
3+
# Setup
4+
5+
## Step 1: Install dependencies
6+
7+
```shell
8+
# using npm
9+
npm install
10+
11+
# OR using Yarn
12+
yarn install
13+
```
14+
15+
## Step 2: Add your app id and api keys
16+
17+
Go to `app.json` and replace the `appId`, `androidApiKey` and `iosApiKey` under `plugins`.
18+
You can also change the intercomRegion to US, EU or AU.
19+
Check our docs for a detailed explanation about these fields [here](https://developers.intercom.com/installing-intercom/react-native/installation/#using-intercom-with-expo)
20+
21+
```shell
22+
"plugins": [
23+
[
24+
"@intercom/intercom-react-native",
25+
{
26+
"appId": "<app-id>",
27+
"androidApiKey": "<android-api-key>",
28+
"iosApiKey": "<ios-api-key>",
29+
"intercomRegion": "US"
30+
}
31+
]
32+
],
33+
```
34+
35+
## Step 3: Prebuild the app
36+
37+
```shell
38+
# using npx
39+
npx expo prebuild
40+
41+
# OR using Yarn
42+
yarn expo prebuild
43+
```
44+
45+
## Step 4: Run pod install
46+
47+
Go to the `ios` folder and run pod install
48+
49+
```shell
50+
npx pod install
51+
```
52+
53+
## Step 5: Run the app
54+
55+
### For Android
56+
57+
```shell
58+
# using npm
59+
npx expo run:android
60+
61+
# OR using Yarn
62+
yarn expo run:android
63+
```
64+
65+
### For iOS
66+
67+
```shell
68+
# using npm
69+
npx expo run:ios
70+
71+
# OR using Yarn
72+
yarn expo run:ios
73+
```

sandboxes/IntercomExpo/app.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"expo": {
3+
"plugins": [
4+
[
5+
"@intercom/intercom-react-native",
6+
{
7+
"appId": "<app-id>",
8+
"androidApiKey": "<android-api-key>",
9+
"iosApiKey": "<ios-api-key>",
10+
"intercomRegion": "US"
11+
}
12+
],
13+
[
14+
"expo-build-properties",
15+
{
16+
"ios": {
17+
"deploymentTarget": "15.0"
18+
}
19+
}
20+
]
21+
],
22+
"name": "IntercomExpo",
23+
"slug": "IntercomExpo",
24+
"version": "1.0.0",
25+
"orientation": "portrait",
26+
"icon": "./assets/icon.png",
27+
"userInterfaceStyle": "light",
28+
"splash": {
29+
"image": "./assets/splash.png",
30+
"resizeMode": "contain",
31+
"backgroundColor": "#ffffff"
32+
},
33+
"assetBundlePatterns": [
34+
"**/*"
35+
],
36+
"ios": {
37+
"supportsTablet": true,
38+
"bundleIdentifier": "io.intercom.ios.enterprise.sample"
39+
},
40+
"android": {
41+
"adaptiveIcon": {
42+
"foregroundImage": "./assets/adaptive-icon.png",
43+
"backgroundColor": "#ffffff"
44+
},
45+
"permissions": [
46+
"android.permission.READ_EXTERNAL_STORAGE",
47+
"android.permission.VIBRATE"
48+
],
49+
"package": "com.intercom.sample"
50+
},
51+
"web": {
52+
"favicon": "./assets/favicon.png"
53+
}
54+
}
55+
}
17.1 KB
Loading
1.43 KB
Loading
21.9 KB
Loading
46.2 KB
Loading

0 commit comments

Comments
 (0)