You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, when using the function signInWithPhoneNumber, Firebase Console reports the error: INVALID_APP_CREDENTIAL and our users can not sign in.
I am not sure yet if they receive the OTP code as I am unable to reproduce it at all on my phones.
This issue happens for around 5-10 users per day. I would say that's around 10% of our users that sign up. Other ones are fine.
We haven't had this issue on Android, but we have very very few users on Android, so that might be just pure luck.
Project Files
Javascript
import{AppText}from'@design/AppText';import{colors}from'@design/colors';import{LoginStackScreenProps}from'@misc/navigation';import{Onboarding}from'@screens/Onboarding/components/Onboarding';importReact,{useEffect,useState}from'react';import{Keyboard,Pressable,StyleSheet,View}from'react-native';import{TextInput}from'react-native-gesture-handler';import{useSafeAreaInsets}from'react-native-safe-area-context';importmessagingfrom'@react-native-firebase/messaging';importauthfrom'@react-native-firebase/auth';import{AnalyticsClient}from'@clients/AnalyticsClient/AnalyticsClient';import{useMutation}from'convex/react';import{api}from'convex/_generated/api';import{DEFAULT_USER_DATA}from'@misc/const';import{AppToast}from'@design/AppToast';import{FirebaseAuthError}from'node_modules/firebase-admin/lib/utils/error';importcrashlyticsfrom'@react-native-firebase/crashlytics';exportconstOnboardingVerifyPhoneNumberScreen=(props: LoginStackScreenProps<'VerifyPhoneNumber'>,)=>{constinsets=useSafeAreaInsets();constcreateUserIfDoesNotExist=useMutation(api.users.create);const[textInputValue,setTextInputValue]=useState('');const[status,setStatus]=useState<'timer'|'resend'|'processing'|'finished'|'error'>('timer');const[confirmation,setConfirmation]=useState(props.route.params.confirmation,);const[timer,setTimer]=useState(30);useEffect(()=>{if(textInputValue.length===6){confirmCode();}asyncfunctionconfirmCode(){Keyboard.dismiss();setStatus('processing');try{constauthUser=awaitconfirmation.confirm(textInputValue);AnalyticsClient.trackEvent('Verified Phone Number');if(authUser!=null){constmessagingToken=awaitmessaging().getToken();awaitcreateUserIfDoesNotExist({authId: authUser.user.uid,
messagingToken,
...DEFAULT_USER_DATA,});}setStatus('finished');}catch(_error){consterror=_errorasFirebaseAuthError;crashlytics().log(error?.code);crashlytics().log(error?.message);crashlytics().recordError(newError('AUTH_SMS_VERIFICATION_ISSUE'));switch(error?.code){case'auth/invalid-verification-code':
AppToast.showError('Invalid code.');break;case'auth/session_expired':
AppToast.showError('Too much time ocurred to use the code. Go back and try again.',);break;default:
AppToast.showError('An error occurred.');break;}setStatus('error');console.log(error);}}},[textInputValue,props.route.params.phoneNumber,confirmation,createUserIfDoesNotExist,]);useEffect(()=>{letinterval: NodeJS.Timeout;if(timer>0){interval=setInterval(()=>{setTimer(Math.max(timer-1,0));},1000);}elseif(timer===0){setStatus(old=>(old==='timer' ? 'resend' : old));}return()=>clearInterval(interval);},[timer]);consthandleResend=async()=>{constresult=awaitauth().signInWithPhoneNumber(props.route.params.phoneNumber,);setConfirmation(result);setTimer(60);// Reset timersetStatus('timer');};return(<Viewstyle={{flex: 1,gap: 8,paddingTop: insets.top+36,paddingHorizontal: 24,backgroundColor: 'white',}}><Onboarding.HeaderTexttitle={'Enter your code'}subtitle={`A text message was sent to ${props.route.params.phoneNumber}`}/><Viewstyle={{flexDirection: 'row',gap: 8,alignSelf: 'center',marginTop: 32,}}>{[0,1,2,3,4,5].map((el,index)=>(<Viewkey={el}style={{height: 45,width: 35,borderRadius: 4,borderWidth: 1,borderColor:
textInputValue.length===index
? '#229ED9DD'
: colors.grayscale.line,justifyContent: 'center',alignItems: 'center',}}><AppTextstyle={{fontSize: 18,fontWeight: '600',color: colors.grayscale.header,}}>{textInputValue[index]}</AppText></View>))}<TextInputautoFocuskeyboardType="number-pad"
caretHiddenstyle={[StyleSheet.absoluteFillObject,{color: 'transparent'}]}placeholder="Enter code"maxLength={6}placeholderTextColor="transparent"onChangeText={setTextInputValue}/></View><Viewstyle={{alignItems: 'center',marginTop: 32}}>{status==='processing' ? (<AppTextstyle={{fontWeight: '500',color: colors.grayscale.header,}}>ProcessingSMScode...
</AppText>) : status==='resend' ? (<PressableonPress={handleResend}hitSlop={10}><AppTextstyle={{color: colors.primary.default,fontWeight: '500'}}>Resendcode</AppText></Pressable>
) : status==='timer' ? (<AppTextstyle={{color: colors.grayscale.header}}>Pleasewait{timer}secondstoresendthecode.</AppText>) : status==='error' ? (<View><AppTextstyle={{color: colors.grayscale.header}}>Anerrorocurredwhileprocessingthecode...
</AppText><PressableonPress={handleResend}hitSlop={10}><AppTextstyle={{color: colors.primary.default,fontWeight: '500'}}>Resendcode</AppText></Pressable></View>) : null}</View></View>);};
requireFile.join(File.dirname(`node --print "require.resolve('expo/package.json')"`),"scripts/autolinking")# Resolve react_native_pods.rb with node to allow for hoistingrequirePod::Executable.execute_command('node',['-p','require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )',__dir__]).stripplatform:ios,'14.0'prepare_react_native_project!linkage=ENV['USE_FRAMEWORKS']iflinkage != nilPod::UI.puts"Configuring Pod with #{linkage}ally linked Frameworks".greenuse_frameworks!:linkage=>linkage.to_symendtarget'app'douse_expo_modules!post_integratedo |installer|
beginexpo_patch_react_imports!(installer)rescue=>ePod::UI.warneendendconfig=use_native_modules!use_frameworks!:linkage=>:static
$RNFirebaseAsStaticFramework =truern_maps_path='../node_modules/react-native-maps'pod'react-native-google-maps',:path=>rn_maps_pathuse_react_native!(:path=>config[:reactNativePath],# Enables Flipper.## Note that if you have use_frameworks! enabled, Flipper will not work and# you should disable the next line.# :flipper_configuration => flipper_config,# An absolute path to your application root.:app_path=>"#{Pod::Config.instance.installation_root}/..")# --- PATCH FOR REANIMATED ---# See https://github.com/software-mansion/react-native-reanimated/issues/4425# and shared transitions. `use_frameworks! :linkage => :static` is used because of Firebase.
$static_framework =['RNScreens']pre_installdo |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method,:verify_no_static_framework_transitive_dependencies){}installer.pod_targets.eachdo |pod|
if $static_framework.include?(pod.name)defpod.build_type;Pod::BuildType.static_libraryendendendend# --- END PATCH ---post_installdo |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202react_native_post_install(installer,config[:reactNativePath],:mac_catalyst_enabled=>false,# :ccache_enabled => true)# -- PATCH: compile signing errorsinstaller.generated_projects.eachdo |project|
project.targets.eachdo |target|
target.build_configurations.eachdo |config|
config.build_settings["DEVELOPMENT_TEAM"]="XXXXXXXXXX"endendend# --- END PATCH ---endend
AppDelegate.m:
#import"AppDelegate.h"
#import<Firebase.h>
#import<React/RCTBundleURLProvider.h>
#import<GoogleMaps/GoogleMaps.h>
#import"RNCConfig.h"
#import<React/RCTLinkingManager.h>
#import<RiveRuntime/RenderContextManager.h>@implementationAppDelegate
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"main";
// You can add your custom initial props in the dictionary below.// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
[FIRApp configure];
[GMSServices provideAPIKey: [RNCConfig envFor:@"GOOGLE_MAPS_API_KEY"]]; // add this line using the api key obtained from Google Console// Used to fix Skia rendering performance.// This is very visible when the app is first run and Skia needed to warm up.// So we drop Skia and use the custom rive renderer
[[RenderContextManager shared] setDefaultRenderer:riveRenderer];
return [superapplication:application didFinishLaunchingWithOptions:launchOptions];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [selfbundleURL];
}
- (NSURL *)bundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#elsereturn [[NSBundlemainBundle] URLForResource:@"main"withExtension:@"jsbundle"];
#endif
}
// For universal links: https://reactnavigation.org/docs/deep-linking/#setup-on-ios
- (BOOL)application:(UIApplication *)applicationopenURL:(NSURL *)urloptions:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
// For universal links: https://reactnavigation.org/docs/deep-linking/#setup-on-ios
- (BOOL)application:(UIApplication *)applicationcontinueUserActivity:(nonnull NSUserActivity *)userActivityrestorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Reset the badge number to 0
application.applicationIconBadgeNumber = 0;
}
@end
Android
Click To Expand
Have you converted to AndroidX?
my application is an AndroidX application?
I am using android/gradle.settingsjetifier=true for Android compatibility?
I am using the NPM package jetifier for react-native compatibility?
Curious to know if other people face this issue.
Given there is no potential race conditions and this problem happens for a small subset of users on different iPhones and iOS versions, I suspect some "infrastructure" related issue.
We also have this issue. We discussed this with Google support team and they told us that it could be related to "jailbroken devices"... Obviously, I don't think that this is the problem here.
I'm still waiting for Google to provide us with a real explanation
Issue
Sometimes, when using the function
signInWithPhoneNumber
, Firebase Console reports the error:INVALID_APP_CREDENTIAL
and our users can not sign in.I am not sure yet if they receive the OTP code as I am unable to reproduce it at all on my phones.
This issue happens for around 5-10 users per day. I would say that's around 10% of our users that sign up. Other ones are fine.
We haven't had this issue on Android, but we have very very few users on Android, so that might be just pure luck.
Project Files
Javascript
package.json
:iOS
Click To Expand
ios/Podfile
:AppDelegate.m
:Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:Firebase
module(s) you're using that has the issue:TypeScript
?React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: