Giter Club home page Giter Club logo

react-native-sms-user-consent's Introduction

React Native SMS User Consent

React Native wrapper for Android's SMS User Consent API, ready to use in React Native apps with minimum effort. The purpose of SMS User Consent API is to provide one-tap auto-filling of SMS verification codes.

iOS

SMS User Consent API exists only on Android, so this package is Android-only. Calling this package's APIs on iOS is no-op.

If you want auto-filling on iOS, textContentType="oneTimeCode" for TextInput is the way to go. Basically, this is the only way for iOS.

Getting started

Install the package:

yarn add @eabdullazyanov/react-native-sms-user-consent

or

npm install @eabdullazyanov/react-native-sms-user-consent

Basic usage

import React, { useEffect, useState } from 'react';
import { TextInput } from 'react-native';

import { useSmsUserConsent } from '@eabdullazyanov/react-native-sms-user-consent';

const Example = () => {
  const [code, setCode] = useState();

  const retrievedCode = useSmsUserConsent();

  useEffect(() => {
    if (retrievedCode) setCode(retrievedCode);
  }, [retrievedCode]);

  return <TextInput value={code} onChangeText={setCode} />;
};

In the example we use a controlled TextInput for the code entry. retrievedCode equals to the empty string initially, and whenever an SMS is handled retrievedCode receives the code from it. We use the useEffect to update the input value when an SMS is handled.

Customise verification code parser

Set the length of the validation code:

const retrievedCode = useSmsUserConsent(4);
// e.g. code = 1234

Provide a custom regular expression:

const retrievedCode = useSmsUserConsent('[A-Z0-9]{5}');
// e.g. code = A12B3

API

useSmsUserConsent()

useSmsUserConsent(config: number | string): string

React hook that starts SMS handling and provides the received code as its return value, which is the empty string initially. Stops handling SMS messages on unmount. Uses startSmsHandling and retrieveVerificationCode internally.

This hook is the way to go in most cases. Alternatively, you can use startSmsHandling and retrieveVerificationCode directly if dealing with something that is not a functional component or you need some more flexibility.

On iOS it just returns the empty string, so no additional code to handle iOS is needed.

Accepts an optional config parameter. In case if it's a number, it defines the length of the code. In case if it is a string, it defines a custom RegExp to parse the code.

startSmsHandling()

startSmsHandling(onSmsReceived: (event: {sms?: string}) => void): (
  stopSmsHandling(): void
)

Starts the native SMS listener that will show the SMS User Consent system prompt. If the user allowed reading the SMS, then the onSmsReceived callback is called. onSmsReceived receives the event object containing the SMS.

Returns stopSmsHandling function that stops showing the system prompt and stops SMS handling.

retrieveVerificationCode()

retrieveVerificationCode(sms: string, config: number | string): string | null

Retrieves the verification code from an SMS if there is any.

Accepts an optional config parameter. In case if it's a number, it defines the length of the code. In case if it is a string, it defines a custom RegExp to parse the code.


You can import the whole API as one object if you prefer

import SmsUserConsent from 'react-native-sms-user-consent';

// ...
SmsUserConsent.useSmsUserConsent();
// ...

Help

If you have any ideas about the project or found a bug or have a question, feel free to create an issue with all the relevant information. We are engaged to response ASAP. The following info will make it faster to resolve issues:

  1. Device or emulator model
  2. Android version
  3. Your environment info - output of the npx react-native info command

Contribution

PRs are always welcome. If you're feeling like contributing to the project, please do. It would be great to have all the relevant information with the PR.

To make changes, you'll need to follow these steps:

  1. clone the repo
  2. make changes
  3. test the changes
  4. create a PR
  5. 🥳

react-native-sms-user-consent's People

Contributors

dmitrypetukhovakvelon avatar eabdullazyanov avatar lightknight3r avatar mrshakirov avatar oleksiismirnov 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-sms-user-consent's Issues

Fatal Exception: java.lang.IllegalStateException

Hi, having this issue after deploying the app to store.
Working well on local devices.
Any thoughts or suggestions?

Firebase Crashlytics

ReactNativeSmsUserConsentModule.java line 44

SmsRetriever.getClient(getCurrentActivity()).startSmsUserConsent(null);

image

Fatal Exception: java.lang.IllegalStateException: Method addObserver must be called on the main thread at androidx.lifecycle.LifecycleRegistry.enforceMainThreadIfNeeded(LifecycleRegistry.java:317) at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:172) at androidx.fragment.app.Fragment.initLifecycle(Fragment.java:496) at androidx.fragment.app.Fragment.<init>(Fragment.java:476) at com.google.android.gms.common.api.internal.zzc.<init>(com.google.android.gms:play-services-basement@@17.2.1:1) at com.google.android.gms.common.api.internal.zzc.zza(com.google.android.gms:play-services-basement@@17.2.1:14) at com.google.android.gms.common.api.internal.LifecycleCallback.getFragment(com.google.android.gms:play-services-basement@@17.2.1:3) at com.google.android.gms.common.api.internal.LifecycleCallback.getFragment(com.google.android.gms:play-services-basement@@17.2.1:7) at com.google.android.gms.common.api.internal.zaac.zaa(com.google.android.gms:play-services-base@@17.2.1:1) at com.google.android.gms.common.api.GoogleApi.<init>(com.google.android.gms:play-services-base@@17.2.1:33) at com.google.android.gms.auth.api.phone.SmsRetrieverClient.<init>(com.google.android.gms:play-services-auth-api-phone@@17.4.0:3) at com.google.android.gms.internal.auth-api-phone.zzu.<init>(com.google.android.gms:play-services-auth-api-phone@@17.4.0:3) at com.google.android.gms.auth.api.phone.SmsRetriever.getClient(com.google.android.gms:play-services-auth-api-phone@@17.4.0:2) at com.akvelon.reactnativesmsuserconsent.ReactNativeSmsUserConsentModule.subscribe(ReactNativeSmsUserConsentModule.java:44) at com.akvelon.reactnativesmsuserconsent.ReactNativeSmsUserConsentModule.startNativeSmsListener(ReactNativeSmsUserConsentModule.java:124) at java.lang.reflect.Method.invoke(Method.java) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:246) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:923)

Basically using package like this

import {useSmsUserConsent} from '@eabdullazyanov/react-native-sms-user-consent'
...
const androidOTP = useSmsUserConsent()
...
useEffect(() => {
if (androidOTP) {
setCode(androidOTP)
}
}, [androidOTP])

stopSmsHandling function is not calling when I call startSmsHandling

const message: SMSMessage = startSmsHandling((event: { sms?: string }) => {
console.log(event);
var otp = retrieveVerificationCode(event?.sms,4)
this.setState({ code: otp.toString() })
})

stopSmsHandling() should call automatically when we call startSmsHandling() function but it's not happing. NativeSmsListener is not stopping after allow or deny operation.

Please correct me I'm wrong ? I want to stop NativeSmsListener, how can I do that ?
Please try to reply as soon as you can.

black screen when the native dialogue opens

Hi

thanks for making this library. I installed your lib on my app (RN 0.64.1, on a pixel 1 android 10), (also had to do manual linking to make it work)
when i receive an sms, then whole screen turns black when the consent dialogue tries to come up..
meanwhile, i also get a warning firebase.crashlytics().recordError(*) expects an instance of Error. Non Errors will be ignored. just before it goes blank.

edited: also, one funny thing i noticed is that, when i added the hook on the first screen of the app, the consent screen works fine, but once i navigate (using react navigation) to another page, the above mentioned problem comes up

any clue why this would be happening?

Thanks in advance

edit:

i tried to log the error. got this:
java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.myapp (has extras) } in com.google.android.gms.internal.firebase-auth-api.zzvl@6cc189e at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1560) at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference at java.util.regex.Matcher.reset(Matcher.java:280) at java.util.regex.Matcher.<init>(Matcher.java:186) at java.util.regex.Pattern.matcher(Pattern.java:1034) at com.google.android.gms.internal.firebase-auth-api.zzvn.zzb(com.google.firebase:firebase-auth@@21.0.1:1) at com.google.android.gms.internal.firebase-auth-api.zzvl.onReceive(com.google.firebase:firebase-auth@@21.0.1:8) at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1550) ... 8 more

Breaks with Gradle 7 (maven), RN 0.68

Hi,

I just upgraded to RN68 and the plugin is breaking unfortunately due to the usage of maven.
Here are the required patches. Is this library still maintained @akvelon ?

If not, I would fork it and re-release.

Here is the diff that solved my problem:

diff --git a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle
index 70807f5..2577a40 100644
--- a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle
+++ b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/build.gradle
@@ -20,7 +20,6 @@ def safeExtGet(prop, fallback) {
 }
 
 apply plugin: 'com.android.library'
-apply plugin: 'maven'
 
 buildscript {
     // The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -39,7 +38,6 @@ buildscript {
 }
 
 apply plugin: 'com.android.library'
-apply plugin: 'maven'
 
 android {
     compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
@@ -56,16 +54,6 @@ android {
 }
 
 repositories {
-    // ref: https://www.baeldung.com/maven-local-repository
-    mavenLocal()
-    maven {
-        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
-        url "$rootDir/../node_modules/react-native/android"
-    }
-    maven {
-        // Android JSC is installed from npm
-        url "$rootDir/../node_modules/jsc-android/dist"
-    }
     google()
     jcenter()
 }
@@ -111,7 +99,7 @@ afterEvaluate { project ->
     task androidJavadoc(type: Javadoc) {
         source = android.sourceSets.main.java.srcDirs
         classpath += files(android.bootClasspath)
-        classpath += files(project.getConfigurations().getByName('compile').asList())
+        //classpath += files(project.getConfigurations().getByName('compile').asList())
         include '**/*.java'
     }
 
@@ -142,10 +130,5 @@ afterEvaluate { project ->
 
     task installArchives(type: Upload) {
         configuration = configurations.archives
-        repositories.mavenDeployer {
-            // Deploy to react-native-event-bridge/maven, ready to publish to npm
-            repository url: "file://${projectDir}/../android/maven"
-            configureReactNativePom pom
-        }
     }
 }
diff --git a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java
index c8d829a..6a668ca 100644
--- a/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java
+++ b/node_modules/@eabdullazyanov/react-native-sms-user-consent/android/src/main/java/com/akvelon/reactnativesmsuserconsent/ReactNativeSmsUserConsentModule.java
@@ -118,6 +118,17 @@ public class ReactNativeSmsUserConsentModule extends ReactContextBaseJavaModule
             .emit(AKV_SMS_RETRIEVE_ERROR, params);
     }
 
+    // Required for rn built in EventEmitter Calls.
+    @ReactMethod
+    public void addListener(String eventName) {
+
+    }
+
+    @ReactMethod
+    public void removeListeners(Integer count) {
+
+    }
+
     @ReactMethod
     public void startNativeSmsListener(Promise promise) {
         try {

This issue body was partially generated by patch-package.

Android 11 not working

I tried to use this library on android 11 but it's not working. There isn't any error.

Autofill not working

Hi,
I am trying to integrate this library to my project but I could not retrieve the code from the message.
I am using the exact same code as in Readme but retrievedCode from const retrievedCode = useSmsUserConsent(); does not return anything when I received the message.

I am testing on android emulator.

System:
OS: macOS 10.15.7
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 19.01 MB / 16.00 GB
Shell: 5.0.17 - /usr/local/bin/bash
Binaries:
Node: 14.15.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.8 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /Users/ahmadbaharan/.rvm/gems/ruby-2.7.2/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 23, 26, 27, 28, 29
Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.0
System Images: android-27 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google X86_ARM Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_251 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
npmGlobalPackages:
react-native: Not Found

one-time password popup does appear, but no code is being filled into the OTP field

My Project React/React-native Version "react": "18.1.0", "react-native": "0.70.4",

i am using this library with legacy deep peer

npm install @eabdullazyanov/react-native-sms-user-consent
"node_modules/@eabdullazyanov/react-native-sms-user-consent": { "version": "1.0.11", "resolved": ""xyz, "integrity": "xyz", "peerDependencies": { **"react": "^16.8.1",** **"react-native": ">=0.60.0-rc.0 <1.0.x"** }
Attempting: I’m attempting to automatically fetch and fill the OTP using the react-native-sms-user-consent API, as I don’t have control over the OTP.

Expect: I expect it to auto-fill the OTP that arrives from the third-party service.

Result: the result is not as expected. The OTP from the third-party service does arrive, and the one-time password popup does appear, but no code is being filled into the OTP field.

Debugging: For debugging: I’m attempting to directly print the OTP on the screen to verify whether it’s arriving or not.But no value is being set in my** TextInput**

import React, { useEffect, useState } from 'react';
import { TextInput } from 'react-native';

import { useSmsUserConsent } from '@eabdullazyanov/react-native-sms-user-consent';

const Example = () => {
  const [code, setCode] = useState();

  const retrievedCode = useSmsUserConsent();

  useEffect(() => {
    if (retrievedCode) setCode(retrievedCode);
  }, [retrievedCode]);`

  return <TextInput value={code} onChangeText={setCode}/>;
};

///images for Reference///
WhatsApp Image 2024-01-03 at 11 53 04 AM

My Orginal Code :

 import { useSmsUserConsent } from '@eabdullazyanov/react-native-sms-user-consent';
      const webviewRef = useRef(null);
 const [autoReadOTP, setAutoReadOTP] = useState('');

  const injectJavaScript = `
    window.addEventListener('beforeunload', (event) => 
    {
      window.ReactNativeWebView.postMessage('pagefade()');
    });
  `;
 
  
 useEffect(() => {
    const stopSmsHandling = SmsUserConsent.startSmsHandling((event) => {
      if (event.sms) {
        const otpMatch = event.sms.match(/Your OTP is ([a-zA-Z0-9]{10})/);
        if (otpMatch) {
          setAutoReadOTP(otpMatch[1]);
        }
      }
    });
  
    return () => {
      stopSmsHandling();
    };
  }, []);
  useEffect(() => 
  {
    if (!FUNCTION.IsEmptyString(autoReadOTP))
    {
      const jsCode = `
        window.addEventListener('beforeunload', (event) => 
        {
          window.ReactNativeWebView.postMessage('pagefade()');
        });

        document.getElementById('otp').value = '${autoReadOTP}';
      `;

      webviewRef.current.injectJavaScript(jsCode);
    }

  }, [autoReadOTP]);
 function HandleMessage(event)
  {
    if (event?.nativeEvent?.data == 'pagefade()')
    {
      OnClose();
    }
  }
 return (
      <View style={localStyleSheet.container}>

 <WebView
            ref={webviewRef}
            onLoad={() => setIsLoading(false)}
            onMessage={event => HandleMessage(event)}
            injectedJavaScript={injectJavaScript}
            scalesPageToFit={false}
            source= xyz
/>
..........

Can't install with latest React Native version

Hi,

I'm new in React-native. I started a project from scratch (with npx react-native@latest init AwesomeProject), which setup a project with [email protected] and [email protected].

When I try to install your module with NPM, the react version is in conflict with the restriction you have (react@^16.8.1).

Do you plan to make it compatible with the latest version ?

Regards,
Valentin

Full stack error :

npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.1" from @eabdullazyanov/[email protected]
npm ERR! node_modules/@eabdullazyanov/react-native-sms-user-consent
npm ERR!   @eabdullazyanov/react-native-sms-user-consent@"*" from the root project

Crashes the app fully

System:
OS: macOS 13.6.4
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 34.34 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
Yarn: 1.22.21 - /usr/local/bin/yarn
npm: 10.4.0 - ~/.nvm/versions/node/v18.17.1/bin/npm
Watchman: 2024.01.22.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.15.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 15.2/15C500b - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.6 => 0.71.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

"expo": "^48.0.0",

when adding the package to my app it crashes the whole app even if I don't use the package in my application. what could be the issue? I get the same errors over and over again until I delete the package fully from my project.

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
ERROR TypeError: Cannot read property 'useContext of null, js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and AppRegistry. registerComponent wasn't called., js engine: hermes

App crashing once read sms is approved

System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Memory: 161.77 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.11.0
path: ~/.nvm/versions/node/v20.11.0/bin/node
Yarn:
version: 1.22.21
path: /opt/homebrew/bin/yarn
npm:
version: 10.2.4
path: ~/.nvm/versions/node/v20.11.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.4
- iOS 17.4
- macOS 14.4
- tvOS 17.4
- visionOS 1.1
- watchOS 10.4
Android SDK:
API Levels:
- "31"
- "33"
- "34"
Build Tools:
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 34.0.0
- 35.0.0
System Images:
- android-33 | Google APIs ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode:
version: 15.3/15E204a
path: /usr/bin/xcodebuild
Languages:
Java:
version: javac 19
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.10
wanted: 0.72.10
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false

FATAL EXCEPTION: main Process: com.weatherapp, PID: 24127 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { (has extras) }} to activity {com.weatherapp/com.weatherapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.bridge.Promise.reject(java.lang.String, java.lang.String)' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:6153) at android.app.ActivityThread.handleSendResult(ActivityThread.java:6192) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2853) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:328) at android.app.ActivityThread.main(ActivityThread.java:9220) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.bridge.Promise.reject(java.lang.String, java.lang.String)' on a null object reference at com.weatherappCustomImagePicker$1.onActivityResult(CustomImagePicker.java:142) at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:375) at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:822) at com.facebook.react.ReactDelegate.onActivityResult(ReactDelegate.java:107) at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:136) at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:70) at android.app.Activity.dispatchActivityResult(Activity.java:9338) at android.app.ActivityThread.deliverResults(ActivityThread.java:6146) at android.app.ActivityThread.handleSendResult(ActivityThread.java:6192)  at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67)  at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2853)  at android.os.Handler.dispatchMessage(Handler.java:108)  at android.os.Looper.loopOnce(Looper.java:226)  at android.os.Looper.loop(Looper.java:328)  at android.app.ActivityThread.main(ActivityThread.java:9220)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 

Update to Android 10+

Gradle sync failed: No variants found for ':eabdullazyanov_react-native-sms-user-consent'. Check build files to ensure at least one variant exists. at:
			com.android.tools.idea.gradle.project.sync.idea.svs.AndroidModule.deliverModels(AndroidModule.kt:191)
			com.android.tools.idea.gradle.project.sync.idea.svs.AndroidExtraModelProvider$Worker.populateBuildModels(AndroidExtraModelProvider.kt:121)
			com.android.tools.idea.gradle.project.sync.idea.svs.AndroidExtraModelProvider.populateBuildModels(AndroidExtraModelProvider.kt:81)
			org.jetbrains.plugins.gradle.model.ProjectImportAction.addBuildModels(ProjectImportAction.java:247)
			org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:117)
			org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)
			org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter.execute(InternalBuildActionAdapter.java:77)

Plugin with id 'maven' not found

I upgraded all packages plus the sdk/build tools in order to support Android 12, and I now get this:

A problem occurred evaluating project ':eabdullazyanov_react-native-sms-user-consent'.
> Plugin with id 'maven' not found.

Here is the build env:

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 23
        compileSdkVersion = 31
        targetSdkVersion = 31
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.0.3')
        classpath 'com.google.gms:google-services:4.3.10'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Could not find a declaration file for module '@eabdullazyanov/react-native-sms-user-consent'.

Greetings. I am installing the package with yarn. However, I am facing such a problem while importing.

Could not find a declaration file for module '@eabdullazyanov/react-native-sms-user-consent'. '/Users/dogan.kablan/Documents/hangikredi.mobile.rn/node_modules/@eabdullazyanov/react-native-sms-user-consent/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/eabdullazyanov__react-native-sms-user-consent if it exists or add a new declaration (.d.ts) file containing declare module '@eabdullazyanov/react-native-sms-user-consent';

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.