Amr*_*taB 5 android firebase firebase-authentication firebaseui
我正在尝试从数字转移到 firebase 身份验证,并且我已使用 Android studio firebase 工具在我的应用程序中配置 firebase 设置。我正在尝试使用 firebase auth ui 进行电话验证。
我的代码是:
authButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(
Arrays.asList(
new AuthUI.IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build()
))
.build(),
RC_SIGN_IN);
}
});
Run Code Online (Sandbox Code Playgroud)
现在,当我单击“身份验证”按钮时,我会收到电话号码输入 ui 并输入我的电话号码,但是当我单击“验证我的电话号码”时...我会收到一个弹出窗口,显示发生了内部错误 [MISSING_CLIENT_IDENTIFIER] 。
根据要求,我的 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.app.id"
minSdkVersion 16
targetSdkVersion 25
versionCode 258
versionName "1.2.40"
}
buildTypes {
staging {
applicationIdSuffix ".staging"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "IS_STAGING", "true"
signingConfig signingConfigs.configstaging
debuggable true
}
release {
signingConfig signingConfigs.releaseConfig
}
}
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
repositories {
mavenCentral()
maven { url "https://urbanairship.bintray.com/android" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Urban Airship SDK
// Recommended for in-app messaging
// compile 'com.google.android.gms:play-services-analytics:9.2.0'
// compile('com.digits.sdk.android:digits:1.11.1@aar') {
// transitive = true;
// }
compile('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
transitive = true;
}
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.urbanairship.android:urbanairship-sdk:8.6.+'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.code.gson:gson:2.4'
compile 'net.danlew:android.joda:2.9.9'
compile 'com.android.support:support-v13:25.3.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.rollbar:rollbar-android:0.2.0'
compile 'com.google.firebase:firebase-auth:10.0.1'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.4.2'
compile 'com.firebaseui:firebase-ui-auth:2.0.1'
compile 'com.appsee:appsee-android:+'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
我的 onActivityResult 从未被命中。我尝试对此进行调试。我使用的是实际设备而不是模拟器。我也在我的 firebase 项目中添加了 SHA1。还有其他人遇到过这个吗?
我终于解决了这个问题,令人非常沮丧的是 firebase 没有记录这样一个常见的问题。
很可能您正在测试并且一切正常,然后您开始使用白名单电话号码进行测试,同时您会看到验证码,这很烦人,因此您找到了用于禁用验证码的记录代码。现在,经过几周的测试后,您返回到生产电话号码,却发现此错误,但没有找到导致该错误的原因的信息。;)
[FIRAuth auth].settings.appVerificationDisabledForTesting = YES;
^将其设置回“否”,您就可以开始了!