Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biometric Login doesn't work (Biometric Authentication Manager) #2507

Open
johnjeremih opened this issue Jan 22, 2024 · 8 comments
Open

Biometric Login doesn't work (Biometric Authentication Manager) #2507

johnjeremih opened this issue Jan 22, 2024 · 8 comments

Comments

@johnjeremih
Copy link

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

@brandonpage
Copy link
Contributor

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

@johnjeremih
Copy link
Author

@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)

@johnjeremih
Copy link
Author

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

@johnjeremih
Copy link
Author

Any thoughts on this?

1 similar comment
@johnjeremih
Copy link
Author

Any thoughts on this?

@Harikjr
Copy link

Harikjr commented Jun 6, 2024

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>

@johnjeremih
Copy link
Author

@Harikjr Now shows up, but it doesn't prompt the biometric

@brandonpage
Copy link
Contributor

@johnjeremih Are you still having problems with this? I don't think you are understanding how the feature works. Here is the doc. The feature needs to be enabled in your connected app on the server. You can prompt the use to opt in (or opt them in without prompting) any time after initial login. When the app locks and displays the login screen the user will be prompted to login with Biometrics or they can login with username / password to unlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants