Skip to content

Commit aaeea40

Browse files
Merge pull request #75 from mrakesh0608/expo-plugin
feat: add expo plugin
2 parents 6c57ac8 + 32fd445 commit aaeea40

25 files changed

+16888
-46537
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ To run the example app on iOS:
4747
yarn example ios
4848
```
4949

50+
### Running the Expo Example
51+
52+
The project also includes an Expo example app in the `expo-example/` directory. To run the Expo example:
53+
54+
```sh
55+
yarn
56+
yarn prepare
57+
yarn expo-example android
58+
```
59+
5060
Make sure your code passes TypeScript and ESLint. Run the following to verify:
5161

5262
```sh
@@ -108,6 +118,8 @@ The `package.json` file contains various scripts for common tasks:
108118
- `yarn example start`: start the Metro server for the example app.
109119
- `yarn example android`: run the example app on Android.
110120
- `yarn example ios`: run the example app on iOS.
121+
- `yarn expo-example android`: run the Expo example app on Android.
122+
- `yarn expo-example ios`: run the Expo example app on iOS.
111123

112124
### Sending a pull request
113125

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ Starting from Android 12, the incoming call notification UI will resemble the on
2626
- Full-screen incoming call notifications
2727
- Customizable notification options (icons, colors, sound, etc.)
2828
- Android 12+ call-style UI support
29+
- Expo support with configuration plugin
2930

3031
# Installation
32+
33+
For React Native projects:
3134
```sh
3235
npm install react-native-full-screen-notification-incoming-call
3336

3437
```
38+
39+
For Expo projects, this library includes a configuration plugin. See the [Expo section](#expo) below for setup instructions.
3540
### Compatibility
3641
Ensure you are using the appropriate version of this library for your React Native version:
3742

@@ -97,6 +102,32 @@ In `AndroidManifest.xml`:
97102
</application>
98103
```
99104

105+
# Expo
106+
107+
Add the plugin in your app.json
108+
109+
```
110+
{
111+
"expo": {
112+
"plugins": [
113+
[
114+
"react-native-full-screen-notification-incoming-call",
115+
{
116+
"statusBarColor": "#000000"
117+
}
118+
]
119+
]
120+
}
121+
}
122+
```
123+
124+
Available plugin options :
125+
126+
```ts
127+
type PluginOptions = {
128+
statusBarColor?: string; // optional, default is "#000000"
129+
};
130+
```
100131
# Usage
101132

102133
````js

app.plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/commonjs/expo');

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

0 commit comments

Comments
 (0)