Skip to content

Commit 5056a29

Browse files
committed
chore: add expo example
1 parent aca1320 commit 5056a29

File tree

21 files changed

+3813
-36613
lines changed

21 files changed

+3813
-36613
lines changed

example/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AppRegistry } from 'react-native';
22
import App from './src/App';
33
import { name as appName } from './app.json';
44
import CustomIncomingCall from './src/CustomIncomingCall';
5+
import { IncomingCallAppName } from './src/constants';
56

6-
AppRegistry.registerComponent('MyReactNativeApp', () => CustomIncomingCall);
7+
AppRegistry.registerComponent(IncomingCallAppName, () => CustomIncomingCall);
78
AppRegistry.registerComponent(appName, () => App);

example/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
"@react-native-picker/picker": "^2.9.0",
1616
"@react-navigation/native": "^5.8.0",
1717
"@react-navigation/stack": "^5.10.0",
18-
"@types/react": "18.3.1",
19-
"add": "^2.0.6",
2018
"react": "18.2.0",
2119
"react-native": "0.74.1",
2220
"react-native-background-timer": "^2.4.1",
@@ -25,8 +23,7 @@
2523
"react-native-permissions": "^3.8.0",
2624
"react-native-safe-area-context": "^4.4.1",
2725
"react-native-screens": "3.29.0",
28-
"uuid-random": "^1.3.2",
29-
"yarn": "^1.22.22"
26+
"uuid-random": "^1.3.2"
3027
},
3128
"devDependencies": {
3229
"@babel/core": "^7.20.0",
@@ -35,6 +32,7 @@
3532
"@react-native/babel-preset": "0.74.83",
3633
"@react-native/metro-config": "0.74.83",
3734
"@react-native/typescript-config": "0.74.83",
35+
"@types/react": "18.3.1",
3836
"babel-plugin-module-resolver": "^5.0.0"
3937
},
4038
"engines": {

example/src/CustomIncomingCall/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react';
22
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
33
import type { CustomIncomingActivityProps } from 'react-native-full-screen-notification-incoming-call';
4-
import RNNotificationCall from '../../../src/index';
4+
import RNNotificationCall from 'react-native-full-screen-notification-incoming-call';
5+
import { defaultUserImgUrl } from '../constants';
56

67
export default function CustomIncomingCall(props: CustomIncomingActivityProps) {
78
console.log('props===', props);
@@ -14,9 +15,7 @@ export default function CustomIncomingCall(props: CustomIncomingActivityProps) {
1415
<Text style={styles.callerName}>{props.name || 'Unknown Caller'}</Text>
1516
<Image
1617
source={{
17-
uri:
18-
payload.callerImage ||
19-
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKet-b99huP_BtZT_HUqvsaSz32lhrcLtIDQ&s',
18+
uri: payload.callerImage || defaultUserImgUrl,
2019
}}
2120
style={styles.callerImage}
2221
/>

example/src/Home/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useNavigation } from '@react-navigation/native';
1212
import { CallKeepService } from '../services/CallKeepService';
1313
import CheckBox from '@react-native-community/checkbox';
1414
import { Picker } from '@react-native-picker/picker';
15+
import { IncomingCallAppName, defaultUserImgUrl } from '../constants';
1516

1617
CallKeepService.instance().setupCallKeep();
1718

@@ -26,9 +27,7 @@ const IncomingCallDemo = () => {
2627
CallKeepService.navigation = navigation;
2728

2829
const [callerName, setCallerName] = useState('John Doe');
29-
const [callerImageURL, setCallerImageURL] = useState(
30-
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKet-b99huP_BtZT_HUqvsaSz32lhrcLtIDQ&s'
31-
);
30+
const [callerImageURL, setCallerImageURL] = useState(defaultUserImgUrl);
3231
const [selectedRingtone, setSelectedRingtone] = useState<
3332
'default' | 'skype_ring'
3433
>('default');
@@ -47,7 +46,7 @@ const IncomingCallDemo = () => {
4746
hasVideo: isVideoCall,
4847
other: {
4948
ringtone: selectedRingtone !== 'default' ? selectedRingtone : null,
50-
mainComponent: useCustomIncomingCallUI ? 'MyReactNativeApp' : null,
49+
mainComponent: useCustomIncomingCallUI ? IncomingCallAppName : null,
5150
channelId:
5251
ringtoneChannelIds[selectedRingtone] || ringtoneChannelIds.default,
5352
},

example/src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const IncomingCallAppName = 'MyReactNativeApp';
2+
3+
export const defaultUserImgUrl =
4+
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKet-b99huP_BtZT_HUqvsaSz32lhrcLtIDQ&s';

example/src/services/CallKeepService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Platform } from 'react-native';
22
import RNNotificationCall, {
33
type AnswerPayload,
44
type DeclinePayload,
5-
} from '../../../src/index';
5+
} from 'react-native-full-screen-notification-incoming-call';
66
import RNCallKeep from 'react-native-callkeep';
77
import type { HandleType } from 'react-native-callkeep';
88
import {
@@ -11,6 +11,7 @@ import {
1111
RESULTS,
1212
requestMultiple,
1313
} from 'react-native-permissions';
14+
import { defaultUserImgUrl } from '../constants';
1415

1516
const appName = 'Incoming-Test';
1617
const isAndroid = Platform.OS === 'android';
@@ -115,7 +116,7 @@ export class CallKeepService {
115116
const isVideo = hasVideo === 'true';
116117
RNNotificationCall.displayNotification(
117118
callUUID,
118-
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKet-b99huP_BtZT_HUqvsaSz32lhrcLtIDQ&s',
119+
defaultUserImgUrl,
119120
30000,
120121
{
121122
...answerOption,

expo-example/.gitignore

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

expo-example/app.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"expo": {
3+
"name": "expo-example",
4+
"slug": "expo-example",
5+
"scheme": "expo-example",
6+
"version": "1.0.0",
7+
"orientation": "portrait",
8+
"icon": "./assets/icon.png",
9+
"userInterfaceStyle": "light",
10+
"newArchEnabled": false,
11+
"splash": {
12+
"image": "./assets/splash-icon.png",
13+
"resizeMode": "contain",
14+
"backgroundColor": "#ffffff"
15+
},
16+
"ios": {
17+
"supportsTablet": true
18+
},
19+
"android": {
20+
"adaptiveIcon": {
21+
"foregroundImage": "./assets/adaptive-icon.png",
22+
"backgroundColor": "#ffffff"
23+
},
24+
"edgeToEdgeEnabled": true,
25+
"package": "com.expoexample"
26+
},
27+
"web": {
28+
"favicon": "./assets/favicon.png"
29+
},
30+
"plugins": [
31+
"@config-plugins/react-native-callkeep",
32+
[
33+
"../app.plugin.js",
34+
{
35+
"statusBarColor": "#000000"
36+
}
37+
]
38+
]
39+
}
40+
}
17.1 KB
Loading

expo-example/assets/favicon.png

1.43 KB
Loading

0 commit comments

Comments
 (0)