Giter VIP home page Giter VIP logo

react-native-call-detection's Introduction

React Native Call Detection πŸŽ‰ 🎊

npm version

This package helps to detect different call states like Incoming, Disconnected, Dialing and Connected for iOS. For android, this package will give following states, Offhook, Incoming, Disconnected and Missed. In the case of Incoming for android, the package will also provide with the incoming phone number.

Installation

Add the package to your react-native project in the following way

yarn add react-native-call-detection

Integrate into an Expo managed project

  1. Install expo-dev-client:
expo install expo-dev-client
  1. Add react-native-call-detection into the plugins array inside the app.json file of your app:
"plugins": [
  ["react-native-call-detection"],
],

For Android:-

Autolinking should work without manual changes

Usage

There are different hooks that you may get depending on the platform. Since for android you could also request the package to provide you with phone number of the caller, you will have to provide the necessary request message and the corresponding error callback. The package will request for READ_PHONE_STATE permission in android.

Its really easy to setup the package. Have a look at the following code snippet

import CallDetectorManager from 'react-native-call-detection'

startListenerTapped() {
	this.callDetector = new CallDetectorManager((event, phoneNumber)=> {
	// For iOS event will be either "Connected",
	// "Disconnected","Dialing" and "Incoming"

	// For Android event will be either "Offhook",
	// "Disconnected", "Incoming" or "Missed"
	// phoneNumber should store caller/called number


	if (event === 'Disconnected') {
	// Do something call got disconnected
	}
	else if (event === 'Connected') {
	// Do something call got connected
	// This clause will only be executed for iOS
	}
	else if (event === 'Incoming') {
	// Do something call got incoming
	}
	else if (event === 'Dialing') {
	// Do something call got dialing
	// This clause will only be executed for iOS
	}
	else if (event === 'Offhook') {
	//Device call state: Off-hook.
	// At least one call exists that is dialing,
	// active, or on hold,
	// and no calls are ringing or waiting.
	// This clause will only be executed for Android
	}
	else if (event === 'Missed') {
    	// Do something call got missed
    	// This clause will only be executed for Android
  }
},
false, // if you want to read the phone number of the incoming call [ANDROID], otherwise false
()=>{}, // callback if your permission got denied [ANDROID] [only if you want to read incoming number] default: console.error
{
title: 'Phone State Permission',
message: 'This app needs access to your phone state in order to react and/or to adapt to incoming calls.'
} // a custom permission request message to explain to your user, why you need the permission [recommended] - this is the default one
)
}

stopListenerTapped() {
	this.callDetector && this.callDetector.dispose();
}

Dont forget to call dispose when you don't intend to use call detection, as it will avoid memory leakages.

Example project can be used to test out the package. In the example project update the HomeComponent.js with the phone number to call

  callFriendTapped() {
  // Add the telephone num to call
    Linking.openURL('tel:5555555555')
      .catch(err => {
        console.log(err)
      });
  }

How to run an example

  1. Install node and watchman

    brew install node
    brew install watchman
    
    
  2. yarn

    Install yarn from npm.

     npm i -g yarn
    
  3. Xcode

    Install it from the App Store.

  4. React Native Debugger

    This is an electron app that bundles react devtools, redux devtools and chrome devtools configured for use with react-native.

     brew cask install react-native-debugger
    
  5. Once you have done all the above steps, navigate to CallDetectionExample folder and run yarn or npm install, it will fetch all the dependencies in the node_modules folder.

  6. Run the packager npm start

  7. Update the mobile number of your friend in HomeComponent.js

     callFriendTapped() {
     // Add the telephone number
    	Linking.openURL('tel:5555555555')
      .catch(err => {
        console.log(err)
      });
     }
  8. To run the example on iOS from terminal type react-native run-ios (This will open the simulator, since simulator doesnt have the support for calling I will advice you to connect your iOS device and the follow the below procedure for running the app through xcode)

    or you can also run the app from xcode, for that, open /CallDectionExample/ios/CallDetectionExample.xcodeproj in xcode and run on the device.

  9. To run the example on android, connect any android device to your mac then follow the below steps

    1. Navigate to android folder(./CallDectionExample/android/) folder and then run adb reverse tcp:8081 tcp:8081
    2. Navigate back to example directory(CallDectionExample) and then run react-native run-android

For any problems and doubt raise an issue.

react-native-call-detection's People

Contributors

arraintxo avatar dependabot[bot] avatar dgilbert avatar drzigman avatar enniel avatar gongdao123 avatar ikendoit avatar marcesengel avatar prashantk1220 avatar priteshrnandgaonkar avatar renancavalcanti avatar riawolf avatar whidrubeld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-call-detection's Issues

stop calling

Can the library stop (block) an incoming call?

CallDetectionManager requires main queue setup since it overrides `constantsToExport` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

Hello,
After upgrading react-native with the react-native-call-detection we get the following warning:

Problem:
CallDetectionManager requires main queue setup since it overrides constantsToExport but doesn't implement requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

Resolution:
can you add the following to CallDetectionManager.m :

"+" (BOOL)requiresMainQueueSetup {
return YES;
}

Versions:
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-call-detection": "1.6.3",

link error

react-native link react-native-call-detection

crete only: new CallDetectionManager() MainApplication.this has to be added manualy.

Disconnected state while bringing application to foreground eventhough call in progress

Hi Pritesh,

How can i handle the call end state the problem is here because of when am returning to my application when the call is intact callback state is then disconnected eventhough my call is going in background .I figured it this happens because of this code right.So can u please let me know why u have written this.

@Override
public void onActivityResumed(Activity activity) {
    if (wasAppInOffHook && jsModule != null) {
        wasAppInOffHook = false;
        jsModule.callStateUpdated("Disconnected", null);
    }
}

Phone number is empty

When I have an incoming call on a closed application and start the application. I get the number, but when I have an incoming call and answered a call on the closed application and I open the application and I get an empty string.

How manage calls on my app

Hi guys.. noob question, for android:

When I receive a call, even with my app as default phone app, it switch to the Phone call of Android. How can I achieve that my app doesn't switch to another app, so I can do whatever I want when a call is incoming?

I tried to create an own InCallService class empty but when I receive a call, my app crashes

Thanks for the help!

How to get incoming number ?

Hi There,

I just want to know that is there any method or something through which I can get the incoming number.

Thanks

Invariant violation: Native module cannot be null

While use the react-native-call-detection with existing project (Project contain the pod file) got the "Invariant violation: Native module cannot be null" in iOS platform.
=> Without pod file working file.
Call_Detection

Versions:
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-call-detection": "^1.6.4",

Attached the screen for reference:

Error:(102) error: unknown element <uses-permission> found. (Android)

In the manifest file, the line <uses-permission android:name="android.permission.READ_PHONE_STATE"/> is in the wrong place. It is nested under the Application tag and should be nested directly under the Manifest tag (see Manifest)

Previous versions of AAPT have silently ignored this error but AAPT2 generates the build error Error:(102) error: unknown element <uses-permission> found. Android plugin 3.0.0 enables AAPT2 by default.

Moving the uses-permission line to outside the Application tag fixes this error. Until this is fixed a work around is to add android.enableAapt2=false to the project grade.properties file

Fixed in PR 6

"Suggestion: add 'tools:replace="android:allowBackup"' to <application> element"

i am using react native 0.61.5
react-native-cli: 1.0.0

I get this unexpected error when build app

Roys-MBP:app roysabah$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1642 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

Task :react-native-call-detection:compileDebugJavaWithJavac

Task :app:processDebugManifest FAILED

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
21 actionable tasks: 12 executed, 9 up-to-date
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
/Users/roysabah/www/msgto/app/android/app/src/debug/AndroidManifest.xml:11:7-34 Error:
Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:7:5-117 to override.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:7:5-117 to override.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
/Users/roysabah/www/msgto/app/android/app/src/debug/AndroidManifest.xml:11:7-34 Error:
Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:7:5-117 to override.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:7:5-117 to override.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3s

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (/Users/roysabah/www/msgto/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)

build error for junit

please add below to build.gradle so I no longer need to do that manually:
testCompile "junit:junit:4.12"

Does this lib helps to deal with Dialer app ?

I need to now if this lib helps to deal with a dialer app,

I am working with an app lkike TrueCaller, so does this lib help to detect calls and use my app as default dialer ?

Thanks

[BUG] error during build process

Hello,

I receive following errors when trying to run the app after linking the library:

[...]\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppe
arance.Material.Widget.Button.Borderless.Colored'.

[...]\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppe
arance.Material.Widget.Button.Colored'.

[...]\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextApp
earance.Material.Widget.Button.Borderless.Colored'.

[...]\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextApp
earance.Material.Widget.Button.Colored'.

More info:
"react-native": "0.48.3",
"react-native-call-detection": "^1.6.1",

from build.gradle:
compileSdkVersion 23
buildToolsVersion '23.0.1'

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 22
}

I would appreciate any suggestions, thanks

Error using library react-native-call-detection

I am trying to use the react-native-call-detection library to get the incoming call number.

But when I start the android emulator this low error appears.

I have already run react-native unlink react-native-call-detection, but the error continues. Having identify the other mistakes but to no avail!

If I completely remove react-native-call-detection then the emulator opens without any error.

Can someone help me please?

Thanks.

Microsoft Windows [versΓ£o 10.0.18363.535]
(c) 2019 Microsoft Corporation. Todos os direitos reservados.

L:\wAPP\reactCall>react-native run-android
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - react-native-call-detection (to unlink run: "react-native unlink react-native-call-detection")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1645 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...

> Task :app:processDebugManifest FAILED

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
21 actionable tasks: 3 executed, 18 up-to-date
L:\wAPP\reactCall\android\app\src\debug\AndroidManifest.xml:11:7-34 Error:
        Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.      
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
L:\wAPP\reactCall\android\app\src\debug\AndroidManifest.xml:11:7-34 Error:
        Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:11:7-34
        is also present at [:react-native-call-detection] AndroidManifest.xml:14:9-35 value=(true).
        Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:7:5-117 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

    at checkExecSyncError (child_process.js:610:11)
    at execFileSync (child_process.js:628:15)
    at runOnAllDevices (L:\wAPP\reactCall\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at buildAndRun (L:\wAPP\reactCall\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at L:\wAPP\reactCall\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Command.handleAction (L:\wAPP\reactCall\node_modules\@react-native-community\cli\build\index.js:164:9)        

L:\wAPP\reactCall>  

CallDetectorManager not working on iOS RN 0.5.10

callDetector = new CallDetectorManager((event, number) => {
console.log("-- ios event");
console.log(event);
}

I have put this inside componentDidMount and the log is not printed on iOS, only For Android.
Any idea? I have to enable some permissions in info.plist?

In the example code it is working fine.

compileReleaseJavaWithJavac

getting this error
Execution failed for task ':react-native-call-detection:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

Facing the issue while running with Android rror: constructor CallDetectionManager in class CallDetectionManager cannot be applied to given types; new CallDetectionManager()^

Hey Hi,
I am facing issue while running the app on Android. Below are error logs. Is there any one who have the idea how to deal with it?

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:

  • react-native-call-detection (to unlink run: "react-native unlink react-native-call-detection")
    This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
    Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    Jetifier found 1638 file(s) to forward-jetify. Using 4 workers...
    info JS server already running.
    info Installing the app...

Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
23 actionable tasks: 3 executed, 20 up-to-date
/Users/kepi/Desktop/RNWorkSapce/Sandesh/RNCallDetection/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:51: error: constructor CallDetectionManager in class CallDetectionManager cannot be applied to given types;
new CallDetectionManager()
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 16s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/kepi/Desktop/RNWorkSapce/Sandesh/RNCallDetection/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:51: error: constructor CallDetectionManager in class CallDetectionManager cannot be applied to given types;
new CallDetectionManager()
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 16s

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (/Users/kepi/Desktop/RNWorkSapce/Sandesh/RNCallDetection/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/Users/kepi/Desktop/RNWorkSapce/Sandesh/RNCallDetection/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/Users/kepi/Desktop/RNWorkSapce/Sandesh/RNCallDetection/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)

background state support

Hello,

Can this package run even if the app is in the background?

I need a service that can send an event to the server each time the phone is calling, even when the user is using a navigation app or something else

CallDetectionManager cannot be applied to given types; new CallDetectionManager(), > FAILURE: Build failed with an exception.

Why is this not working? I have this package as my only package used in the project:

@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  return packages;
}
> Task :app:compileReleaseJavaWithJavac FAILED
/Users/hello/Code/_test/foobar/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:78: error: constructor CallDetectionManager in class CallDetectionManager cannot be applied to given types;
      new CallDetectionManager(),
      ^
  required: Application
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error

Help avoid installation hardship - please release the newest version of this code and update the docs πŸ™

Hi πŸ‘‹,

Just wanted to make a small request to create a tag or release the newest version of this code on master.

I went on a wild goose chase because I downloaded this package through yarn and it doesn't have the most recent changes on master.

Master uses CXCallObserver which is the up-to-date way to detect calls on iOS.

Or can we just add to run this yarn command in the Readme?
yarn add https://github.com/priteshrnandgaonkar/react-native-call-detection\#master

Either way, thanks for the package, it saves me the trouble of maintaining a couple of native modules myself πŸ™.

Cheers!

Android build: org.juint does not exist

When running a react-native run-android --variant=release the build fails when this library is included.

The problem I'm facing is:

...

> Task :react-native-call-detection:compileDebugUnitTestJavaWithJavac FAILED
<PROJECTDIR>/node_modules/react-native-call-detection/android/src/test/java/com/pritesh/calldetection/ExampleUnitTest.java:3: error: package org.junit does not exist
import org.junit.Test;
                ^
<PROJECTDIR>/node_modules/react-native-call-detection/android/src/test/java/com/pritesh/calldetection/ExampleUnitTest.java:5: error: package org.junit does not exist
import static org.junit.Assert.*;
                       ^
<PROJECTDIR>/node_modules/react-native-call-detection/android/src/test/java/com/pritesh/calldetection/ExampleUnitTest.java:13: error: cannot find symbol
    @Test
     ^
  symbol:   class Test
  location: class ExampleUnitTest
<PROJECTDIR>/node_modules/react-native-call-detection/android/src/test/java/com/pritesh/calldetection/ExampleUnitTest.java:15: error: cannot find symbol
        assertEquals(4, 2 + 2);
        ^
  symbol:   method assertEquals(int,int)
  location: class ExampleUnitTest
4 errors

...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-call-detection:compileDebugUnitTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

...

using version 1.9.0:

react-native-call-detection@^1.9.0:
  version "1.9.0"
  resolved "https://registry.yarnpkg.com/react-native-call-detection/-/react-native-call-detection-1.9.0.tgz#2477690158768e01842f0bd5c2544e4a3247e616"
  integrity sha512-UaF/I1cp2UnIbdCh3UmrFIA4an8El1gIBM6uIbM+OYCrfe5btIj7DYtjqtNoeKOtF7fap32m37v6lafQ9SZHpg==

Bridge is flasky on iOS

I set up the CallDetector in componentDidMount on one of my screens, pretty much in the same way that it was set on the example:

callDetector = new CallDetectorManager((event, number) => {

However, from time to time I receive the following error (it doesn't happens every time, but frequently) after ending a call:

bridge is not set. 
This is probably because you've explicitly synthesized the bridge in RCTCallDetection, 
even though it's inherited from RCTEventEmitter.

Could this be related to memory leak? Has anyone had this problem?

Background working on Android?

Hello,
I got it to work, but it only works when the App is in the Foreground.
How can I make it to work that the App will open when there is a Call detected on an Android device?

v1.8.2 Android auto linking not working with RN 61.5

V 1.8.2 doesn't seem to be working correctly on RN 61.5. It builds fine with no errors/crashes, but the listener is never triggered.

I am not sure if I have everything installed correctly. I am very confused because on here https://www.npmjs.com/package/react-native-call-detection the install instructions say to edit the MainApplication.java, settings.gradle and build.gradle files, but on github, it says Autolinking should work without manual changes. Also, the example app seems like it needs to be updated to use autolinking.

The reason I think it is not working is because I am putting a debugger just inside the listener and it is never triggered. Here is the file I am using this in:

import { useState, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import CallDetectorManager from 'react-native-call-detection';
import { DialerActionsConst } from 'reducers/dialer';

export default function CallDetectionSetup() {
  const dispatch = useDispatch();

  const [callDetector, setCallDetector] = useState();

  useEffect(() => {
    setupCallDetector();

    return () => {
      if (callDetector) {
        callDetector.dispose();
      }
    };
  }, []);

  function setupCallDetector() {
    debugger // this is being tripped
    setCallDetector(new CallDetectorManager((event) => {
      debugger // this is never being tripped
      switch (event) {
        case 'Offhook':
          dispatch({ type: DialerActionsConst.CALL_CONNECTED });
          break;
        case 'Connected':
          dispatch({ type: DialerActionsConst.CALL_CONNECTED });
          break;
        case 'Dialing':
          dispatch({ type: DialerActionsConst.CALL_CONNECTED });
          break;
        case 'Disconnected':
          dispatch({ type: DialerActionsConst.CALL_DISCONNECTED });
          break;
        default:
          break;
      }
    }));
  }

  return null;
}

Phone Number missing

I can't seem to capture the outgoing number, all th events are capturing fine.

this.callDetector = new CallDetectorManager((event, phoneNumber)=> {

  alert(event);
  alert(phoneNumber);

phoneNumber is undefined

is it possible to capture the number your calling in iOS?

"Disconnect" event when switching back to app while phone call still in progress

Hello,

I am having an issue on Android relating to getting a "Disconnect" event when I switch back to my app, while a phone call is still in progress.

Specifically, this line in the if statement.

Steps to reproduce:

  1. Run your app and set up handler with CallDetectionManager
  2. Receive a phone call and answer
  3. Switch back to your app without hanging up the phone call
  4. Disconnect event occurs, even though phone call is still in progress

Is this intentional, or a leftover artifact? Ideally I would only receive a "Disconnect" when the phone call has ended, or am I misinterpreting this event?

Thanks.

react-native-call-detection is not working with react-native 0.60.5

/react-native-60/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:90: error: constructor CallDetectionManager in class CallDetectionManager cannot be applied to given types;
new CallDetectionManager(),
^
required: Application
found: no arguments
reason: actual and formal argument lists differ in length
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details

Error on android build

When i try to run the 'react-native run-android' command it shows the following error:

:react-native-call-detection:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/duvanvargas/Documents/proyectos/EpoConstructoras/Android/PruebaPush/node_modules/react-native-call-detection/android/src/main/java/com/pritesh/calldetection/CallDetectionManager.java:35: error: method does not override or implement a method from a supertype
@OverRide
^
1 error
:react-native-call-detection:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-call-detection:compileReleaseJavaWithJavac'.

my RN version is: "react-native": "0.48.2" and the installed one of the 'react-native-call-detection' is: "react-native-call-detection": "^1.4.1"

Error with specific gradle settings

I have to use next settings in android/gradle.properties

android.useAndroidX=true
android.enableJetifier=true

And with this module, code have an error:

> Task :react-native-call-detection:compileDebugJavaWithJavac FAILED
/Users/alder/Work/gf/SalesforceMobileSDK-Templates/SmartSyncExplorerReactNative/node_modules/react-native-call-detection/android/src/main/java/com/pritesh/calldetection/CallDetectionManagerModule.java:7: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
/Users/alder/Work/gf/SalesforceMobileSDK-Templates/SmartSyncExplorerReactNative/node_modules/react-native-call-detection/android/src/main/java/com/pritesh/calldetection/CallDetectionManagerModule.java:63: error: cannot find symbol
    @Nullable
     ^
  symbol:   class Nullable
  location: class CallDetectionManagerModule
2 errors


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-call-detection:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

How to deal with this issue? Can I replace Nullable with something else?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.