Cordova ionic 3 android app 在没有 Captcha/ReCaptcha 的情况下实现 Phone 身份验证

Cordova ionic 3 android app Implement Phone auth without Captcha/ReCaptcha

我已经安装/cordova-plugin-firebase 发送验证电话号码 我的问题是在收到带有 OTP 代码的短信之前,我的应用程序进入后台并打开一个 chrome 页面并链接到我的 firebase 帐户并验证“我不是机器人”......在 ~5 秒后它关闭并且我的应用程序重新出现再次进入前台,我收到一条包含 OTP 代码的短信。 那么,是否可以在后台打开网页时将我的 android 应用程序 运行 保留在前台。 我不想在等待短信时受到任何打扰。 请帮忙! 这是我的代码

window.FirebasePlugin.verifyPhoneNumber("my phone number", timeOutDuration, function(credential) {
    console.log(credential);


    firebase.auth().signInWithCredential(signInCredential);
}, function(error) {
    console.error(error);
});

这是我的 android 日志 D/CordovaActivity:暂停 activity。

V/FA: Recording user engagement, ms: 41634 V/FA: Connecting to remote service W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@cbf1c1a D/libMEOW: applied 1 plugins for [com.ess.ess]: plugin 1: [libMEOW_gift.so]: V/FA: Activity paused, time: 610839869 V/FA: Connection attempt already in progress V/FA: onActivityCreated V/FA: Activity resumed, time: 610839913 V/FA: Connection attempt already in progress V/FA: Connection attempt already in progress W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Llibcore/io/Memory;->pokeByte(JB)V (greylist, reflection, allowed) Accessing hidden method Llibcore/io/Memory;->peekByte(J)B (greylist, reflection, allowed) Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed) Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, reflection, allowed) Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, reflection, allowed) Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed) Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, reflection, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, reflection, allowed) Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, reflection, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) I/zzdu: keyset not found, will generate a new one java.io.FileNotFoundException: can't read keyset; the pref value GenericIdpKeyset does not exist at com.google.android.gms.internal.firebase-auth-api.zzdy.zzc(com.google.firebase:firebase-auth@@21.0.1:10) at com.google.android.gms.internal.firebase-auth-api.zzdy.zza(com.google.firebase:firebase-auth@@21.0.1:1) at com.google.android.gms.internal.firebase-auth-api.zzaw.zzi(com.google.firebase:firebase-auth@@21.0.1:1) at com.google.android.gms.internal.firebase-auth-api.zzdt.zzi(com.google.firebase:firebase-auth@@21.0.1:1) at com.google.android.gms.internal.firebase-auth-api.zzdt.zzg(com.google.firebase:firebase-auth@@21.0.1:2) at com.google.firebase.auth.internal.zzk.(com.google.firebase:firebase-auth@@21.0.1:7) at com.google.firebase.auth.internal.zzk.zza(com.google.firebase:firebase-auth@@21.0.1:3) at com.google.firebase.auth.internal.RecaptchaActivity.zzb(com.google.firebase:firebase-auth@@21.0.1:9) at com.google.android.gms.internal.firebase-auth-api.zztr.(com.google.firebase:firebase-auth@@21.0.1:13) at com.google.firebase.auth.internal.RecaptchaActivity.onResume(com.google.firebase:firebase-auth@@21.0.1:43) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1453) at android.app.Activity.performResume(Activity.java:7942) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4384) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4429) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:181) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2126) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:264) at android.app.ActivityThread.main(ActivityThread.java:7684) 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:980) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) I/zzkp: Provider GmsCore_OpenSSL not available W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) W/syndic.essyndi: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed) Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@b238ff6[] D/ViewRootImpl[RecaptchaActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false I/InputTransport: Create ARC handle: 0x72a0bb2d20 V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@fff98cd, this = DecorView@b238ff6[RecaptchaActivity] W/System: Ignoring header X-Firebase-Locale because its value was null. I/System.out: [okhttp]:check permission begin! [okhttp]:not MMS! [okhttp]:not Email! I/System.out: [OkHttp] sendRequest>> [OkHttp] sendRequest<< D/Surface: Surface::connect(this=0x720a8df000,api=1) D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 D/Surface: Surface::setBufferCount(this=0x720a8df000,bufferCount=3) Surface::allocateBuffers(this=0x720a8df000) D/FA: Connected to remote service V/FA: Processing queued up service tasks: 4 V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 460 V/FA: Activity paused, time: 610840374 D/Surface: Surface::disconnect(this=0x720a8df000,api=1) D/Surface: Surface::disconnect(this=0x71b1b7b000,api=1) D/CordovaActivity: Stopped the activity. V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@1d672fd, this = DecorView@c063bf2[MainActivity] V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@fff98cd, this = DecorView@b238ff6[RecaptchaActivity] I/GED: ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 24, oppidx_max 24, oppidx_min 0 D/FA: Application going to the background I/BufferQueue: SurfaceTexture-0-11798-0 ~BufferQueueCore W/System: A resource failed to call end. V/FA: Inactivity, disconnecting from the service D/CordovaActivity: Started the activity. V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@1d672fd, this = DecorView@c063bf2[MainActivity] V/FA: Activity resumed, time: 610848380 V/FA: Connecting to remote service D/Surface: Surface::connect(this=0x71b1b7b000,api=1) D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 D/Surface: Surface::setBufferCount(this=0x71b1b7b000,bufferCount=3) Surface::allocateBuffers(this=0x71b1b7b000) V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 39 Connection attempt already in progress Activity paused, time: 610848420 D/FA: Connected to remote service D/CordovaActivity: Resumed the activity. V/FA: Processing queued up service tasks: 2 V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@1d672fd, this = DecorView@c063bf2[MainActivity] D/LaunchNavigatorPlugin: Plugin action=discoverSupportedApps V/FA: Activity resumed, time: 610848474 D/NetworkManager: toLower : wifi wifi : wifi Connection Type: wifi Connection Extra Info: null D/PluginManager: postMessage: networkconnection D/View: [Warning] assignParent to null: this = DecorView@b238ff6[RecaptchaActivity] I/InputTransport: Destroy ARC handle: 0x72a0bb2d20 W/System: Ignoring header X-Firebase-Locale because its value was null. I/System.out: [okhttp]:check permission begin! [okhttp]:not MMS! [okhttp]:not Email! I/System.out: [OkHttp] sendRequest<< D/FirebasePlugin: success: verifyPhoneNumber.onCodeSent V/FA: Inactivity, disconnecting from the service D/CordovaActivity: Paused the activity. V/FA: Recording user engagement, ms: 15452 V/FA: Connecting to remote service D/CordovaActivity: Stopped the activity. V/FA: Activity paused, time: 610863928 I/GED: ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 24, oppidx_max 24, oppidx_min 0 V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 2 D/FA: Application going to the background D/Surface: Surface::disconnect(this=0x71b1b7b000,api=1) V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@1d672fd, this = DecorView@c063bf2[MainActivity] V/FA: Inactivity, disconnecting from the service W/FirebaseAuth: [SmsRetrieverHelper] Timed out waiting for SMS.

对于遇到相同问题的任何人。解决方案是为您的项目启用 Android DeviceCheck API 并在您的 Firebase settings.firebase

中添加 SHA 256