rn-inc-call
v1.0.4
Published
Android full screen notification incoming call for React Native
Downloads
3
Maintainers
Readme
React Native Full Screen Notification Incoming Call This library works based on android display time-sensitive notifications For more information about Display time-sensitive notifications (https://developer.android.com/training/notify-user/time-sensitive)
Screenshot
rn-inc-call
Android full screen notification incoming call for React Native
Installation
npm install rn-inc-call
Manual installation
In
android/app/build.gradle
Add a linecompile project(':rn-inc-call')
independencies {}
section.In
android/settings.gradle
Add:
include ':rn-inc-call'
project(':rn-inc-call').projectDir = new File(rootProject.projectDir, '../node_modules/rn-inc-call/android')
- In
android/app/src/main/java/.../MainApplication.java
:
import com.reactnativefullscreennotificationincomingcall.FullScreenNotificationIncomingCallPackage; // Add this import line
//...
private static List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new FullScreenNotificationIncomingCallModule() // Add this line
);
}
Addition installation step
In styles.xml
:
<style name="incomingCall" parent="Theme.AppCompat.Light.NoActionBar">color
<!-- Customize status bar color -->
<item name="colorPrimaryDark">#000000</item>
</style>
In AndroidManifest.xml
:
// ...
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application ....>
<activity android:name="com.reactnativefullscreennotificationincomingcall.IncomingCallActivity"
android:exported="true"
android:theme="@style/incomingCall"
android:showOnLockScreen="true"
android:taskAffinity=""
android:launchMode="singleTask"
android:excludeFromRecents="true"
/>
<service
android:name="com.reactnativefullscreennotificationincomingcall.IncomingCallService"
android:enabled="true"
android:stopWithTask="false"
android:exported="true" />
.....
</application>
Usage
import RNNotificationCall from "rn-inc-call";
display notification
RNNotificationCall.displayNotification(
uid,
avatar,
timeout,
foregroundOptions
)
//example
RNNotificationCall.displayNotification(
"22221a97-8eb4-4ac2-b2cf-0a3c0b9100ad",
null,
30000,
{
channelId: "com.abc.incomingcall",
channelName: "Incoming video call",
notificationIcon: "ic_launcher",//mipmap
notificationTitle: "Tanveer Ul Haq",
notificationBody: "Incoming video call",
answerText: "Answer",
declineText: "Decline",
notificationColor:"colorAccent"
}
)
uid
: String required- Call UUID v4.
avatar
: String optinal- Avatar URL.
timeout
: Number optinal ex 20000- Timeout for end call after 20s.
foregroundOptions
: Object requiredchannelId
: string (required) channel id of notificationchannelName
: string (required) channel name of notificationnotificationIcon
: string (required) channel icon of notificationnotificationTitle
: string (required) tile of notificationnotificationBody
: string (required) body of notificationanswerText
: string (required) answer button labeldeclineText
: string (required) decline button labelnotificationColor
: string (optinal) color of notification
hide notification
RNNotificationCall.hideNotification()
answer event
RNNotificationCall.addEventListener("answer", (payload) => {
const {callUUID}=payload
console.log('press answer',callUUID)
})
endCall event
RNNotificationCall.addEventListener("endCall", (payload) => {
const {callUUID}=payload
console.log('press endCall',callUUID)
})
remove event
RNNotificationCall.removeEventListener("answer")
RNNotificationCall.removeEventListener("endCall")
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT