rn-inc-call
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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

  1. In android/app/build.gradle Add a line compile project(':rn-inc-call') in dependencies {} section.

  2. In android/settings.gradle Add:

include ':rn-inc-call'
project(':rn-inc-call').projectDir = new File(rootProject.projectDir, '../node_modules/rn-inc-call/android')
  1. 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 required
    • channelId: string (required) channel id of notification
    • channelName: string (required) channel name of notification
    • notificationIcon: string (required) channel icon of notification
    • notificationTitle: string (required) tile of notification
    • notificationBody: string (required) body of notification
    • answerText: string (required) answer button label
    • declineText: string (required) decline button label
    • notificationColor: 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

Dependencies (0)

    Dev Dependencies (19)

    Package Sidebar

    Install

    npm i rn-inc-call

    Weekly Downloads

    5

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    828 kB

    Total Files

    184

    Last publish

    Collaborators

    • tanveer-ul-haq