forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Biometric Login doesn't work (Biometric Authentication Manager)

johnjeremih opened this issue · comments

I'm having problems trying to set up the Biometric login. I extended the LoginActivity() view in a new class and set up the Biometric Login. I tap on Enable and it doesn't do anything else.
SalesforceSDKManager .getInstance() .biometricAuthenticationManager .presentOptInDialog(this.supportFragmentManager)

image

@johnjeremih It looks like you are calling that API before the user has logged in but it needs to be called after.

@brandonpage Do you guys have a sample app for it? I'm having this error when I add it to the mainActivity

FATAL EXCEPTION: main Process: com.sample.nativeandroid.qa, PID: 19216 android.view.InflateException: Binary XML file line #2 in com.sample.nativeandroid.qa:layout/sf__biometric_enrollment_prompt: Binary XML file line #2 in com.sample.nativeandroid.qa:layout/sf__biometric_enrollment_prompt: Error inflating class <unknown> Caused by: android.view.InflateException: Binary XML file line #2 in com.sample.nativeandroid.qa:layout/sf__biometric_enrollment_prompt: Error inflating class <unknown> Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:866) at android.view.LayoutInflater.createView(LayoutInflater.java:788) at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:942) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:962) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:973) at android.view.LayoutInflater.inflate(LayoutInflater.java:667) at android.view.LayoutInflater.inflate(LayoutInflater.java:538) at android.view.LayoutInflater.inflate(LayoutInflater.java:485) at com.salesforce.androidsdk.ui.BiometricAuthOptInPrompt.onCreateView(BiometricAuthOptInPrompt.kt:44) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104) at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:510) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1823) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760) at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2985) at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2895) at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263) at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:351) at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:248) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1582) at android.app.Activity.performStart(Activity.java:8654) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3827) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:225) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:205) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:177) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2448) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8194) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 2024-01-23 10:41:40.012 19216-19216 AndroidRuntime com...sample.nativeandroid.qa E Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f040436 a=-1}, theme={InheritanceMap=[id=0x10302d6android:style/ThemeOverlay.Material.Dialog, id=0x1030443android:style/ThemeOverlay.Material.BaseDialog, id=0x1030248android:style/ThemeOverlay.Material, id=0x1030247android:style/ThemeOverlay], Themes=[android:style/ThemeOverlay.Material.Dialog, forced, com.sample.nativeandroid.qa:style/ProCrewzTheme.DayNight, forced, com.sample.nativeandroid.qa:style/Theme.AppCompat.Empty, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]} at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:1007) at android.content.res.TypedArray.getDrawable(TypedArray.java:991) at android.view.View.<init>(View.java:5705) at android.view.ViewGroup.<init>(ViewGroup.java:704) at android.widget.LinearLayout.<init>(LinearLayout.java:254) at android.widget.LinearLayout.<init>(LinearLayout.java:250) at android.widget.LinearLayout.<init>(LinearLayout.java:246)

Here is an example app of the problem. https://github.com/johnjeremih/SalesforceTest

Any thoughts on this?

Any thoughts on this?

use this below layout file in sf__biometric_enrollment_prompt.xml file.
``
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sf__layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"

android:filterTouchesWhenObscured="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginEnd="10dp"
    android:layout_marginBottom="10dp"
    android:textColor="?android:attr/textColorPrimary"
    android:text="@string/sf__biometric_opt_in_message" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:orientation="horizontal"
    >

    <Button
        android:id="@+id/sf__use_password_button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginStart="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginBottom="10dp"
        android:layout_weight="1"

        android:text="@string/sf__biometric_opt_in_deny"
        android:textAllCaps="false"

        android:textSize="14sp"
        android:textStyle="bold"
        tools:ignore="ButtonStyle" />

    <Button
        android:id="@+id/sf__enable_biometric_button"
        android:layout_width="0dp"
        android:layout_height="48dp"
        android:layout_gravity="center"
        android:layout_marginStart="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="10dp"
        android:layout_weight="1"

        android:text="@string/sf__biometric_opt_in_approve"
        android:textAllCaps="false"

        android:textSize="14sp"
        android:textStyle="bold"
        tools:ignore="ButtonStyle" />
</LinearLayout>