Android client integration

Updated at:

This guide describes how to implement integrated authentication in an Android client, including interface examples.

Integration workflow

This section guides you through the SDK integration workflow, from project configuration to feature implementation.

Step 1: Download the SDK

  1. Log in to the Phone Number Verification console. On the Overview page, in the API & SDK section on the right, click Download Now to go to the API & SDK page.

  2. In the form, select Fusion Authentication and Android, and click the SDK Download (with demo) button.

    In the form, set Client to APP and Version to Standard.

Step 2: Import the project

  1. In the build.gradle file in the project root directory, add the Kotlin Gradle plugin dependency (classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") to the buildscript dependencies block, and configure allprojects repositories:

    }
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.3'
            classpath 'com.kezong:fat-aar:1.3.3'
            classpath 'com.tomgoddy:merge-manifest:1.0.0-SNAPSHOT'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0"
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    def  ROOT_LIBS = rootProject.getProjectDir().getPath()+'/libs'
    allprojects {
        repositories {
            maven {
                allowInsecureProtocol=true
                url "http://mvnrepo.alibaba-inc.com/nexus/content/repositories/snapshots"
            }
            jcenter()
            mavenLocal()
            maven{
                url 'https://maven.aliyun.com/repository/google'
            }
        }
    
  2. Set the minSdkVersion.

    Note

    The Fusion Authentication SDK requires API level 21 or higher. Ensure your project's minSdkVersion is set accordingly.

    In the build.gradle(:demo) file, confirm that minSdkVersion is set to 21 or higher. Example configuration:

    plugins {
        id 'com.android.application'
    }
    
    android {
        signingConfigs {
            debug {
                storeFile file('./sign/debug/debug.keystore')
                storePassword 'android'
                keyAlias 'fusionauth'
                keyPassword 'android'
            }
            release {
                storeFile file('./sign/debug/debug.keystore')
                storePassword 'android'
                keyAlias 'fusionauth'
                keyPassword 'android'
            }
        }
        compileSdk 33
    
        defaultConfig {
            applicationId "com.alicom.fusion.auth.demo"
            minSdkVersion 21
            targetSdkVersion 33
            versionCode 1
            versionName "1.0"
            buildConfigField "String", "NETURL", '"https://dypns.aliyuncs.com"'
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            debug {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
            release {
    
  3. Import the AAR file and add a dependency: In the module that uses the Fusion Authentication feature, import the relevant AAR file into the libs folder.

    • If your project requires the phone number risk score or endpoint risk setting features, you must also import the UMeng components. For more information, see Configure UMeng component dependencies.

      Place umeng-asms-v1.8.0.aar and umeng-common-9.5.6.aar in the libs directory of the demo module. The complete project directory structure is:

      Demo ~/Downloads/fusionAuthSDK_APP_Android_v1.2
        .gradle
        .idea
        demo
          build
          libs
            fusionauth-1.2.7-online-release.aar
            umeng-asms-v1.8.0.aar
            umeng-common-9.5.6.aar
          sign
          src
            main
              assets
              java
                com.alicom.fusion.demo
              res
              AndroidManifest.xml
          build.gradle
          proguard-rules.pro
        gradle
      
    • If your project does not use the phone number risk score or endpoint risk setting features, import only the Fusion Authentication AAR file.

  4. In the module (usually app/build.gradle, or demo/build.gradle), find dependencies in the build.gradle file and add the following dependency:

    implementation fileTree(dir: "libs", include: ["*.aar"])
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.0"

Step 3: Configure the project

  1. Add permissions: Add the necessary permissions to the AndroidManifest.xml manifest file.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  2. Declare the activities.

    Add the Activity declaration to the AndroidManifest.xml manifest file.

    // Phone Number Verification activity
    <activity
        android:name="com.alicom.fusion.auth.numberauth.FusionNumberAuthActivity"
        android:exported="false"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="behind"
        android:theme="@style/NumberAuthTheme" />
    // SMS activity
    <activity
        android:name="com.alicom.fusion.auth.smsauth.FusionSmsActivity"
        android:exported="false"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="behind" />
    // CAPTCHA activity
    <activity android:name="com.alicom.fusion.auth.graphauth.FusionGraphAuthActivity"
        android:exported="false"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="behind"/>
    // Uplink SMS activity
    <activity
        android:name="com.alicom.fusion.auth.upsms.AlicomFusionUpSmsActivity"
        android:exported="false"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="behind" />
    // Phone Number Verification authorization page activity
    <activity
        android:name="com.mobile.auth.gatewayauth.LoginAuthActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:exported="false"
        android:launchMode="singleTop"
        android:screenOrientation="behind"
        android:theme="@style/authsdk_activity_dialog" />
    // Phone Number Verification secondary dialog authorization activity
    <activity
        android:name="com.mobile.auth.gatewayauth.PrivacyDialogActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:exported="false"
        android:launchMode="singleTop"
        android:screenOrientation="behind"
        android:theme="@style/authsdk_activity_dialog" />
    // Activity for displaying agreements for Phone Number Verification, login, and registration. This requires custom implementation.
    <activity
    	android:name="com.alicom.fusion.demo.CustomWebViewActivity"
    	android:configChanges="orientation|keyboardHidden|screenSize|uiMode|fontScale"
    	android:screenOrientation="sensorPortrait">
    	<intent-filter>
    		// The action value is fixed and cannot be changed.
    		<action android:name="com.fusion.auth"/>
    		<category android:name="android.intent.category.DEFAULT"/>
    	</intent-filter>
    </activity>
    Note

    Custom views cannot be added to the CAPTCHA interface. If you do not need this feature, you can disable the CAPTCHA node in the authentication policy settings.

  3. Configure obfuscation.

    If you need to obfuscate your code, add the following obfuscation rules to the proguard-rules.pro file:

    -keep class com.alicom.fusion.auth.**{*;}

Step 4: Get package name and signature

  1. Create a signature file:

    1. Follow the instructions in Sign your app to create a signature file. You will use this file when you create a Scheme Code. Place the signature file in your module. The file name and path are not restricted.

    2. For example, if you place the signature file in the app/sig-adaptation/debug/ directory, you must reference it in the module's build.gradle file.

      signingConfigs {
            debug {
                keyAlias 'androiddebugkey'
                keyPassword 'android'
                storeFile file('sig-adaptation/debug/debug.keystore')
                storePassword 'android'
            }
        }
  2. View the package signature:

    In the right-hand panel of Android Studio, navigate to Gradle > {Your Project Name} > {Your Module Name} > Tasks > android > signingReport. Double-click signingReport to view the MD5 signature value.

    Demo
     ├── Tasks
     ├── app
     │ └── Tasks
     │ ├── android
     │ │ ├── androidDependencies
     │ │ ├── signingReport ← Highlighted
     │ │ └── sourceSets
     │ ├── build
     │ ├── cleanup
     │ ├── help
     │ ├── install
     │ ├── other
     │ └── verification
    Note

    You can obtain the package signature in one of the following ways:

    • Method 1: From the MD5 value in the console output, remove the colons (:) and convert all uppercase letters to lowercase to obtain the package signature.

    • Method 2: Download and install the Android App Signature Generation Tool on your mobile device to get the package signature for your app.

    The following example shows the MD5 value from the console output:

    MD5: 47:FC:C6:61:54:85:E8:3B:41:00:43:3E:C9:A1:D2:78
  3. View the package name:

    You can find the package name in the android.defaultConfig.applicationId property of your app/build.gradle file.

Step 5: Create an authentication scheme and obtain the Scheme Code

When you integrate the SDK or call APIs, you need parameters such as the scheme code. Follow these steps to create a solution and get these parameters.

  1. Sign in to the Phone Number Verification Service console.

  2. In the left-side navigation pane, select Fusion Authentication Solution > Authentication Scheme Management.

  3. Click Add Fusion Authentication Scheme.

  4. Enter the package name and package signature that you obtained in the previous step.

    Complete the following fields in the form:

    • Scheme Name: Enter 1–10 characters.

    • Client: Select Android or iOS.

    • App Name: Enter the app name (maximum 20 characters).

    Click OK.

Scenarios

The Integrated Authentication SDK supports five scenarios. To invoke a scenario, use its corresponding scenario ID.

Scenario

Scenario ID

One-click logon/registration

100001

Change phone number

100002

Reset password

100003

Bind new phone number

100004

Verify bound phone number

100005

To configure policies for these scenarios, see global policy.

Interaction flow

Fusion Authentication

  1. The client initializes the Alibaba Cloud Fusion Authentication SDK.

  2. The server calls the GetFusionAuthToken API to obtain an authentication token. It then sends this token to the client, which provides it to the SDK.

  3. The client displays the scenario authorization page. Some scenarios require user consent, such as accepting the Privacy Policy or requesting an SMS verification code.

  4. After the user grants consent, the client obtains a unified authentication token from the SDK's callback API and uploads it to the server.

  5. The server calls the VerifyWithFusionAuthToken API to exchange the token for the user's mobile number.

SDK methods

Create an instance

// Creates a new instance. This constructor performs initial SDK setup.
AlicomFusionBusiness mAlicomFusionBusiness = new AlicomFusionBusiness();

Initialize the authentication token

Authentication.png

The SDK requires an authentication token at startup to validate requests.

  • The authentication token must be obtained from your server. For more information, see the GetFusionAuthToken API.

  • You can get the scene code after creating an authentication scheme in the console. For instructions, see Create an authentication scheme.

/**
 * @param mContext  The application context.
 * @param sceneCode The scene code.
 * @param token     The authentication token.
 */
public void initWithToken(Context mContext, String sceneCode, AlicomFusionAuthToken token)

Usage example

AlicomFusionAuthToken token = new AlicomFusionAuthToken();
token.setAuthToken("<YOUR_TOKEN>");
mAlicomFusionBusiness.initWithToken(<YOUR_CONTEXT>, "<YOUR_SCENE_CODE>, token);

Successful, failed, or expired authentication triggers the main process callback (AlicomFusionAuthCallBack). You must implement the following callbacks:

  • Successful authentication: Triggers the onSDKTokenAuthSuccess() callback. You can perform scene operations only after this callback is called.

  • Failed authentication: Triggers the onSDKTokenAuthFailure() callback.

  • Token update: Triggers the onSDKTokenUpdate() callback five minutes before the token expires. You must implement this callback to get a new token.

Set callbacks

The SDK uses callbacks to notify you of the status of each node in the process. You must implement the main process callback, AlicomFusionAuthCallBack.

Main process callback AlicomFusionAuthCallBack

/**
 * Called when the token needs to be updated.
 *
 * @return A token object. Your app must obtain the latest token, package it into a token object, and return it.
 * Your implementation must return the token synchronously. The SDK attempts to retrieve it twice, with a 30-second timeout for each attempt. If the SDK does not receive a token within 60 seconds, a timeout error occurs.
 * @note This is a required callback. The SDK calls this callback during handler initialization and five minutes before the token expires to manage the token lifecycle.
 */
AlicomFusionAuthToken onSDKTokenUpdate();

/**
 * Called when the initial token authentication succeeds.
 *
 * @note This is a required callback. You can call the `startScene` API to start a scene only after token authentication is successful.
 * @note We recommend that you do not call the `startScene` API directly in this callback. This callback is triggered by the token authentication event and may be invoked multiple times. Call the `startSceneWithTemplateId` method after this callback returns. For a detailed example, see the demo.
 */
void onSDKTokenAuthSuccess();

/**
 * Called when token authentication fails.
 *
 * @param failToken The incorrect token.
 * @param error     The error definition.
 * @note This is a required callback. It is triggered when initial token authentication fails and when authentication fails after a token update.
 * @note After token authentication fails, you cannot continue to use SDK features. You must destroy and re-initialize the SDK.
 */
void onSDKTokenAuthFailure(AlicomFusionAuthToken failToken, AlicomFusionEvent error);

/**
 * Called when authentication for a node in a scene succeeds.
 *
 * @param token    The unified authentication token.
 * @param nodeName The name of the node that obtained the token.
 * @param event    The event for a successful verification.
 *                 This indicates that the node has obtained its token. You can use this token for operations like changing a phone number or logging in. Based on the operation's result, you can choose to continue or interrupt the process. For a detailed example, see the demo.
 * @note This is a required callback.
 * @note You can use the token for final server-side validation to exchange it for the real phone number. If exchanging the token for the phone number fails, you can use the SDK's `continue` API to proceed with the scene.
 */
void onVerifySuccess(String token, String nodeName, AlicomFusionEvent event);


/**
 * Called when a mid-process node requires validation to continue.
 *
 * @param nodeName     The name of the node that obtained the token.
 * @param maskToken    The unified authentication token.
 * @param event        The event.
 * @param verifyResult The callback.
 *                     This callback is used in the "change phone number" scene to validate the token obtained for the currently logged-in account. Based on the validation result, call the `verifyResult` method of the `HalfWayVerifyResult` callback to determine the next step in the process. For a detailed example, see the demo.
 * @note This is a required callback.
 * @note You can use the `maskToken` for final server-side validation to exchange it for the real phone number. Inform the SDK of the validation result through the `verifyResult` callback. If validation fails, the SDK takes no action. If it succeeds, the process moves to the next node.
 */
void onHalfWayVerifySuccess(String nodeName, String maskToken, AlicomFusionEvent event, HalfWayVerifyResult verifyResult);

/**
 * Called when authentication for a node fails.
 *
 * @param error    The event indicating a token acquisition failure.
 * @param nodeName The name of the node where the token acquisition failed.
 *                 This callback is triggered when authentication fails. Examples include: failing to open the authorization page during phone number verification, failing to get a token, failing to get an SMS message, or an input phone number mismatch when phone number validation is enabled. It is also triggered if an invalid phone number (less than 11 digits) is passed when auto-fill is enabled, or if uplink information cannot be obtained from the uplink SMS interface. After an authentication failure, you can choose to continue or interrupt the process. For a detailed example, see the demo.
 * @note This is a required callback.
 * @note When you receive this callback, it means a token acquisition has failed in the current scene. You can control whether to continue the process.
 */
void onVerifyFailed(AlicomFusionEvent error, String nodeName);

/**
 * The scene process has ended, either normally or due to an error.
 *
 * @param event The error definition.
 *              The internal flow of the Fusion Authentication SDK has ended. You must call `stopSceneWithTemplateId` to stop the flow.
 * @note This is a required callback. The authentication process has ended. If it failed, the failure is irreversible.
 */
void onTemplateFinish(AlicomFusionEvent event);

/**
 * Scene event callback.
 *
 * @param event A click event or user action record.
 *              This callback reports the status of key internal SDK nodes to help with development and quick problem diagnosis.
 * @note This is an optional callback. It handles UI-related events within the SDK scene, such as clicks on various interfaces and page navigations.
 * @note This callback is for event notification only. Do not handle business logic within it.
 */
void onAuthEvent(AlicomFusionEvent event);

/**
 * Called to get the phone number for verification. This can be used to check if the phone number matches user input, or to auto-fill the phone number in a "bind new phone number" scene.
 *
 * @param nodeId The node ID.
 * @param event  The event.
 * @return Returns the phone number currently in use for the next operation.
 * If auto-fill or auto-verification is enabled, you must return a phone number to continue the flow. For a detailed example, see the demo.
 * @note This is a required callback for phone number fields in the SDK's built-in UI.
 */
String onGetPhoneNumberForVerification(String nodeId, AlicomFusionEvent event);

/**
 * Called when the authentication process is interrupted.
 *
 * @param event The reason for the interruption.
 *              The process cannot proceed and is paused on the current screen. While in this state, the SDK ignores calls to start, continue, or stop methods.
 * @note This is a required callback.
 * @note The authentication process is temporarily interrupted. Your app can display corresponding prompts based on different events.
 * @note Trigger conditions: 1. Attempting to authenticate without checking the privacy policy checkbox. 2. Entering an invalid phone number format. 3. The SDK starting or finishing loading a node. 4. Related API availability checks.
 */
void onVerifyInterrupt(AlicomFusionEvent event);

After you implement the main process callback (AlicomFusionAuthCallBack), you must use the following method to set the callback.

/**
 * @param callback The main process callback.
 */
public void setAlicomFusionAuthCallBack(AlicomFusionAuthCallBack callback)

Usage example

mAlicomFusionAuthCallBack = new AlicomFusionAuthCallBack() {
    @Override
    public AlicomFusionAuthToken onSDKTokenUpdate() {
        Log.d(TAG, "AlicomFusionAuthCallBack---onSDKTokenUpdate");
        AlicomFusionAuthToken token = new AlicomFusionAuthToken();
        final CountDownLatch latch = new CountDownLatch(1);
        // Simulate a network request to get a new token.
        new Thread(new Runnable() {
            @Override
            public void run() {
                GlobalInfoManager.getInstance().setToken(HttpRequestUtil.getAuthToken(GlobalInfoManager.getInstance().getContext()));
                latch.countDown();
            }
        }).start();
        try {
            latch.await();
            token.setAuthToken(GlobalInfoManager.getInstance().getToken());
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return token;
   }

    @Override
    public void onSDKTokenAuthSuccess() {
        Log.d(TAG, "AlicomFusionAuthCallBack---onSDKTokenAuthSuccess");
        verifySuccess = true;
    }

    @Override
    public void onSDKTokenAuthFailure(AlicomFusionAuthToken token, AlicomFusionEvent alicomFusionEvent) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onSDKTokenAuthFailure " + alicomFusionEvent.toString());
        // If authentication fails, try to get a new token and update the SDK.
        new Thread(new Runnable() {
            @Override
            public void run() {
                Looper.prepare();
                String token = HttpRequestUtil.getAuthToken(GlobalInfoManager.getInstance().getContext());
                GlobalInfoManager.getInstance().setToken(token);
                AlicomFusionAuthToken authToken = new AlicomFusionAuthToken();
                authToken.setAuthToken(GlobalInfoManager.getInstance().getToken());
                mAlicomFusionBusiness.updateToken(authToken);
                Looper.loop();
            }
        }).start();
    }

    @Override
    public void onVerifySuccess(String token, String s1, AlicomFusionEvent alicomFusionEvent) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onVerifySuccess  " + token);
        // Exchange the token for a mobile number on your server.
        new Thread(new Runnable() {
            @Override
            public void run() {
                String mobilNum = HttpRequestUtil.verifyToken(GlobalInfoManager.getInstance().getContext(), token);
                updateBusiness(mobilNum,s1);
            }
        }).start();
    }

    @Override
    public void onHalfWayVerifySuccess(String nodeName, String maskToken, AlicomFusionEvent alicomFusionEvent, HalfWayVerifyResult halfWayVerifyResult) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onHalfWayVerifySuccess  " + maskToken);
        // Perform mid-process validation on your server.
        new Thread(new Runnable() {
            @Override
            public void run() {
                String result = HttpRequestUtil.verifyToken(GlobalInfoManager.getInstance().getContext(), maskToken);
                updateBusinessHalfWay(result,halfWayVerifyResult,nodeName);
            }
        }).start();
    }

    @Override
    public void onVerifyFailed(AlicomFusionEvent alicomFusionEvent, String s) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onVerifyFailed " + alicomFusionEvent.toString());
        // If verification fails, decide whether to continue the scene.
        mAlicomFusionBusiness.continueSceneWithTemplateId("100001",false);
    }



    @Override
    public void onTemplateFinish(AlicomFusionEvent alicomFusionEvent) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onTemplateFinish  " + alicomFusionEvent.toString());
        sum=0;
        // Stop the scene when the process is finished.
        mAlicomFusionBusiness.stopSceneWithTemplateId("100001");
    }

    @Override
    public void onAuthEvent(AlicomFusionEvent alicomFusionEvent) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onAuthEvent" + alicomFusionEvent.toString());
    }

    @Override
    public String onGetPhoneNumberForVerification(String s, AlicomFusionEvent alicomFusionEvent) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onGetPhoneNumberForVerification");
        // Return the user's phone number for validation.
        return GlobalInfoManager.getInstance().getUserInfo();
    }

    @Override
    public void onVerifyInterrupt(AlicomFusionEvent alicomFusionEvent) {
        Log.d(TAG, "AlicomFusionAuthCallBack---onVerifyInterrupt" + alicomFusionEvent.toString());
    }
};

mAlicomFusionBusiness.setAlicomFusionAuthCallBack(mAlicomFusionAuthCallBack);
Note

While a node is running and awaiting a callback, the SDK ignores calls to Start Scene (startSceneWithTemplateId), Continue Scene (continueSceneWithTemplateId), and Stop Scene (stopSceneWithTemplateId).

Start a scene

  • Call this API only when no other scene is running. Otherwise, the SDK returns error 100003.

  • Call this API only after token authentication succeeds.

  • For scene IDs (templateId), see Use cases.

/**
 * @param mContext   The application context.
 * @param templateId The scene ID.
 * @param callback   (Optional) The callback for custom UI implementations. Omit this parameter to use the default UI.
 */
public void startSceneWithTemplateId(Context mContext, String templateId, AlicomFusionAuthUICallBack callback)

Default UI

If you use the default UI, you cannot modify it. The following code shows an example:

mAlicomFusionBusiness.startSceneWithTemplateId(<YOUR_CONTEXT>, "100001");

Custom UI

You can modify the UI by using the UI process callback (AlicomFusionAuthUICallBack). For more information, see UI process callback. The following code shows an example:

mAlicomFusionBusiness.startSceneWithTemplateId(<YOUR_CONTEXT>, "100001", new AlicomFusionAuthUICallBack() {
    @Override
    public void onPhoneNumberVerifyUICustomView(String templateId, String nodeId, FusionNumberAuthModel authConfig) {
    // Customize one-click logon UI parameters.
    }

    /**
     * Provides the root view of the SMS logon page, allowing for full customization. You must implement the specific appearance and code yourself.
     */
    @Override
    public void onSMSCodeVerifyUICustomView(String templateId, String nodeId, boolean isAutoInput, AlicomFusionVerifyCodeView view) {
      // Remove all default built-in components from the SDK's SMS logon page.
      view.getRootRl().removeAllViews();
      
      // The SDK's built-in API to get a verification code.
      view.verifyCodeBtnClick("");
      // The SDK's built-in API to submit a verification code.
      view.submitVerifyCodeBtnClick("","");
      
      // Get the privacy policy TextView object.
      TextView privacyTV = view.getInputView().getPrivacyTV();
      
      // Customize SMS authentication UI parameters.

    }

    @Override
    public void onSMSSendVerifyUICustomView(String templateId, String nodeId, AlicomFusionUpSMSView view, String receivePhoneNumber, String verifyCode) {
    // Customize uplink SMS authentication UI parameters.
    }
});

Scene process

Number change.png

Executing a scene triggers the main process callback (AlicomFusionAuthCallBack). You must implement the following callbacks:

  • Successful token acquisition: Triggers the onVerifySuccess() callback, which returns the unified authentication token for the current node. After you obtain this token, you can exchange it for a phone number by using the VerifyWithFusionAuthToken API.

  • Failed token acquisition: Triggers the onVerifyFailed() callback. After receiving this callback, you can either continue the scene to proceed to the next verification node or stop the scene.

  • Successful mid-process token acquisition: Triggered for scene ID 100002 when verifying the current phone number node. This triggers the onHalfWayVerifySuccess() callback. After you validate the current phone number, inform the SDK of the result by using verifyResult. The SDK then proceeds based on this result.

  • Scene process finished: Triggers the onTemplateFinish() callback. You must call the method to stop the scene.

Continue a scene

  • Use this API to resume an interrupted scene. For example, if server-side validation of the unified authentication token fails, call this API to resume the scene.

  • Call this API only after a scene has started.

/**
 * @param templateId The scene ID.
 * @param isSuccess  Whether the current scene validation was successful. This determines the subsequent process flow. For example, if a number retrieval operation fails and you need to proceed to the next authentication step, you can use this parameter to control the flow.
 */
public void continueSceneWithTemplateId(String templateId, boolean isSuccess)

Usage example

mAlicomFusionBusiness.continueSceneWithTemplateId("100001", true);

Stop a scene

  • Call this API to stop the current scene.

  • Call this API only after a scene has started. After you stop a scene, you can start the next scene. The SDK does not support running multiple scenes concurrently.

/**
 * @param templateId The scene ID.
 */
public void stopSceneWithTemplateId(String templateId)

Destroy the service

Destroying the service synchronously destroys all internal SDK modules. You must re-initialize the SDK to use it again.

public void destroy()

Usage example

mAlicomFusionBusiness.destroy();

Additional methods

UMeng component dependencies

To use the endpoint risk detection and phone number risk score features, configure the AAR for the UMeng component and call the following method to control its initialization.

Note

This is an optional dependency. You must import the AAR for this setting to take effect.

/**
 * Sets whether the SDK initializes the UMeng analytics component.
 * @note The SDK manages the UMeng component by default. You can ignore this method if your app does not use the UMeng component.
 * However, if your app already integrates a UMeng component, set isUseSupply to false to prevent duplicate initialization.
 * In this case, ensure you initialize your app's UMeng component before using this SDK.
 * @param isUseSupply true to use the UMeng component supplied by the SDK; false to use your app's existing UMeng component. Defaults to true.
 * @param channel The channel name.
 */
public static void useSDKSupplyUMSDK(boolean isUseSupply,String channel)

Example usage

mAlicomFusionBusiness.useSDKSupplyUMSDK(true, "fusionauth");

Authentication token update

Note

This is an optional method. The SDK automatically monitors the token's lifetime and notifies your app through the AlicomFusionAuthCallBack callback before the token expires.

The authentication token has a limited lifetime. You can call this method to proactively update the token before it expires. For details on token updates, see initWithToken.

/**
 * @param token The authentication token.
 */
public void updateToken(AlicomFusionAuthToken token)

Example usage

AlicomFusionAuthToken token = new AlicomFusionAuthToken();
token.setAuthToken("<YOUR_TOKEN>");
mAlicomFusionBusiness.updateToken(token);

SDK version

/**
 * @return The SDK version.
 */
public static String getSDKVersion()

Example usage

String version = mAlicomFusionBusiness.getSDKVersion();

Scene ID

/**
 * @return The ID of the currently running scene.
 */
public String getCurrentTemplateId()

Example usage

String currentTemplateId = mAlicomFusionBusiness.getCurrentTemplateId();

Logging

/** 
 * @param logEnable true to enable logging; false to disable it. Logging is enabled by default.
 */
public static void setLogEnable(boolean logEnable)

Example usage

AlicomFusionLog.setLogEnable(true);

Notched screen adaptation

/**
 * @param adapterPageShape true to adapt the UI for notched screens; false to disable adaptation. Defaults to false.
 */
public void adapterPageShape(boolean adapterPageShape)

Example usage

mAlicomFusionBusiness.adapterPageShape(true)

Screen orientation

You must call this method after initWithToken. Otherwise, this setting has no effect.

// 1: portrait; 2: landscape. Default: 1 (portrait).
private volatile int screenOretation = 2;

Example usage

AlicomFusionAuthToken token = new AlicomFusionAuthToken();
token.setAuthToken("<YOUR_TOKEN>");
mAlicomFusionBusiness.initWithToken(<YOUR_CONTEXT>, "<YOUR_SCENE_CODE>", token);
mAlicomFusionBusiness.setAllPageOrientation(screenOretation);

Built-in CAPTCHA module

/**
 * Sets whether to use the SDK's built-in CAPTCHA module.
 * @note By default, the SDK uses its built-in CAPTCHA module. If your app does not have a CAPTCHA component, you can ignore this method.
 * If your app already includes a CAPTCHA component, set `isUseCaptcha` to `false` to use your existing component.
 * Ensure you initialize your component before using this SDK.
 * @param isUseCaptcha true to use the SDK's built-in CAPTCHA module; false to use your app's existing CAPTCHA component. Defaults to true.
 */
public static void useSDKSupplyCaptchaModule(boolean isUseCaptcha)

Example usage

mAlicomFusionBusiness.useSDKSupplyCaptchaModule(false);

Console API

UI callback AlicomFusionAuthUICallBack

/**
 * Customizes the UI for one-click login.
 * @note The one-click login UI supports limited customization through the FusionNumberAuthModel parameter. * Important: Do not modify any view ID attributes, as this may cause some features to malfunction. * @param templateId The template ID. * @param nodeId The node ID. * @param authConfig The configuration for custom UI properties. */ void onPhoneNumberVerifyUICustomView(String templateId, String nodeId, FusionNumberAuthModel authConfig); /** * Customizes the UI for SMS verification code authentication. * @note The entire AlicomFusionVerifyCodeView object is fully customizable. * Important: Do not modify any view ID attributes, as this may cause some features to malfunction. * @param templateId The template ID. * @param nodeId The node ID. * @param isAutoInput Specifies whether to autofill the phone number field. * If true, the SDK autofills the field with the phone number from the onGetPhoneNumberForVerification callback. * @param view The view for the SMS verification code UI. You are responsible for its implementation. */ void onSMSCodeVerifyUICustomView(String templateId, String nodeId, boolean isAutoInput, AlicomFusionVerifyCodeView view); /** * Customizes the UI for uplink SMS authentication. * @note Important: Do not modify any view ID attributes, as this may cause some features to malfunction. * @param templateId The template ID. * @param nodeId The node ID. * @param view The view for the uplink SMS authentication UI. * @param receivePhoneNumber The receiving phone number. * @param verifyCode The SMS content. */ void onSMSSendVerifyUICustomView(String templateId, String nodeId, AlicomFusionUpSMSView view, String receivePhoneNumber, String verifyCode);

FusionNumberAuthModel: Custom UI parameters for one-click login

public class FusionNumberAuthModel {
    // Enables an alternative phone number login.
    public void otherPhoneLogin()

    // Adds a custom XML layout.
    @AuthNumber
    public void addAuthRegisterXmlConfig(AuthRegisterXmlConfig xmlConfig)

    // Adds a custom View.
    public void addAuthRegistViewConfig(String viewID, AuthRegisterViewConfig viewConfig)

    // Removes the custom XML layout.
    public void removeAuthRegisterXmlConfig()

    // Removes the custom View.
    public void removeAuthRegisterViewConfig()

    /**
     * Sets a listener for UI control click events.
     *
     * @param uiClickListener The listener that handles click events.
     */
    public void setUiClickListener(AuthUIControlClickListener uiClickListener)

    /**
     * Sets the callback for a click on the switch component.
     *
     * @param callBack The callback to invoke when the switch component is clicked.
     */
    public void setSwitchLoginBack(AlicomFusionSwitchLogin callBack)

    // Returns the builder instance. For its methods, see the following table.
    public Builder getBuilder()
}

Authorization navigation bar

Method

Type

Description

setStatusBarColor

int

Sets the status bar color. Effective on Android 5.0 (API level 21) and later.

setLightColor

boolean

Sets the color for text and icons in the status bar. Effective on Android 6.0 (API level 23) and later. Valid values:

  • true: Black. This is the default value.

  • false: White.

setNavColor

int

Sets the background color of the navigation bar.

setNavText

String

Sets the navigation bar title.

setNavTextColor

int

Sets the navigation bar's title color.

setNavTypeface

Typeface

Sets the typeface for the navigation bar title.

Valid parameters include Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setNavReturnImgPath

String

Set the image path for the back button on the navigation bar. The path does not require a file extension. For example, if an image is located in the drawable folder at res/drawable-xxhdpi/return.png, pass return as the parameter, as in setNavReturnImgPath("return").

setNavReturnImgWidth

int

Sets the width of the back button image in the navigation bar, in dp.

setNavReturnImgHeight

int

Sets the height of the back button image in the navigation bar, in dp.

setNavReturnHidden

boolean

Hides or shows the back button in the navigation bar. Valid values:

  • true: Hides the button.

  • false: Shows the button. This is the default value.

setNavReturnScaleType

ImageView.ScaleType

Sets the image scale type for the back button in the navigation bar.

setNavHidden

boolean

Hides or shows the default navigation bar. Valid values:

  • true: Hides the navigation bar.

  • false: Shows the navigation bar. This is the default value.

setStatusBarHidden

boolean

Hides or shows the status bar. Valid values:

  • true: Hides the status bar.

  • false: Shows the status bar. This is the default value.

setStatusBarUIFlag

int

Sets the UI flags for the status bar. Only the following flags are supported:

  • View.SYSTEM_UI_FLAG_LOW_PROFILE: In non-fullscreen scenarios, the status bar enters a low-profile mode.

  • View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN: Puts the status bar into immersive mode in fullscreen scenarios.

setWebViewStatusBarColor

int

Sets the status bar color on the agreement page. Effective on Android 5.0 (API level 21) and later. Defaults to the status bar color of the authorization page.

setWebNavColor

int

Sets the background color of the navigation bar on the agreement page. Defaults to the navigation bar color of the authorization page.

setWebNavTextColor

int

Sets the title color of the navigation bar on the agreement page. Defaults to the navigation bar title color of the authorization page.

setWebNavTextSizeDP

int

Sets the title font size (in dp) for the navigation bar on the agreement page. Defaults to the font size of the navigation bar title on the authorization page.

setWebNavReturnImgPath

String

Set the image path for the back button in the agreement page navigation bar, If not set, it will be consistent with the authorization page settings. The path does not require a suffix, For example, if the image is indrawable directory asres/drawable-xxhdpi/return.png, , then the input parameter isreturn, , that issetWebNavReturnImgPath("return").

setBottomNavColor

int

Sets the color of the bottom navigation bar. Effective on Android 5.0 (API level 21) and later.

setNavTextSizeDp

int

Sets the navigation bar's title font size in dp. The font size does not scale with the system's font settings.

setNavReturnImgDrawable

Drawable

Sets the drawable resource for the back button in the navigation bar.

Authorization logo

Method

Type

Description

setLogoHidden

boolean

Specifies whether to hide the logo. Valid values:

  • true: Hides the logo.

  • false: Shows the logo.

setLogoImgPath

String

Set the path to the logo image. Only drawable resource files are supported. The path must not include a file extension. For example, if an image is stored at res/drawable-xxhdpi/Logo.png, pass Logo as the parameter, as in setLogoImgPath("Logo").

setLogoImgDrawable

Drawable

Sets the drawable resource for the logo.

setLogoWidth

int

Sets the width of the logo control (in dp).

setLogoHeight

int

Sets the height of the logo control (in dp).

setLogoOffsetY

int

Sets the distance of the logo control from the top of the navigation bar, in dp. If this property is set, setLogoOffsetY_B has no effect.

setLogoOffsetY_B

int

Sets the vertical offset of the logo control from the bottom of the parent View (in dp).

setLogoScaleType

ImageView.ScaleType

Sets the scaling mode for the logo image. Valid modes:

  • center: Keeps the original image size and centers it in the ImageView. If the image is larger than the ImageView, the parts of the image that extend beyond the view are cropped.

  • centerCrop: Centers the image and scales it uniformly to fill the entire ImageView. Parts of the image that extend beyond the view are cropped.

  • centerInside: Centers the image and scales it down uniformly to fit within the ImageView. If the image is already smaller than the ImageView, it is centered without being scaled.

  • matrix: Displays the image at its original size from the top-left corner of the ImageView. Parts of the image that extend beyond the view are cropped.

  • fitCenter: Scales the image uniformly to fit within the ImageView and centers it.

  • fitEnd: Scales the image uniformly to fit within the ImageView and aligns it to the bottom-right corner.

  • fitStart: Scales the image uniformly to fit within the ImageView and aligns it to the top-left corner.

  • fitXY: Stretches the image to fill the entire ImageView, without maintaining its original aspect ratio.

Slogan

Method

Type

Description

setSloganHidden

boolean

Specifies whether to hide the slogan. Valid values:

  • true: Hides the slogan.

  • false: Shows the slogan.

setSloganText

String

Sets the slogan text.

setSloganTextColor

int

Sets the slogan text color.

setSloganOffsetY

int

Sets the vertical offset of the slogan from the top of the navigation bar in dp. This method overrides setSloganOffsetY_B.

setSloganOffsetY_B

int

Sets the vertical offset of the slogan from the bottom of the parent view in dp.

setSloganTextSizeDp

int

Sets the slogan font size, in dp. This font size is independent of system font settings.

setSloganTypeface

Typeface

Sets the slogan's typeface.

Valid values include Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setSloganHidden

boolean

Hides or shows the slogan.

Number field

Parameter

Type

Description

setNumberColor

int

Sets the color of the number mask.

setNumberSize

int

Sets the font size of the phone number.

setNumFieldOffsetY

int

Sets the vertical offset of the number field control from the top of the navigation bar (in dp). If this property is set, setNumFieldOffsetY_B is ignored.

setNumFieldOffsetY_B

int

Sets the vertical offset of the number field control from the bottom of the parent View (in dp).

setNumberFieldOffsetX

int

Sets the X-axis offset for the number field (in dp).

setNumberLayoutGravity

int

Sets the layout alignment of the number mask. The following options are supported:

  • Gravity.CENTER_HORIZONTAL: Horizontally centered.

  • Gravity.LEFT: Left-aligned.

  • Gravity.RIGHT: Right-aligned.

setNumberTypeface

Typeface

Sets the typeface for the phone number.

Valid values include Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setNumberSizeDp

int

Sets the font size of the phone number (in dp). This font size does not scale with the system font settings.

Login button

Method

Type

Description

setLogBtnText

String

Sets the login button text.

setLogBtnTextColor

int

Sets the text color of the login button.

setLogBtnTypeface

Typeface

Sets the font for the login button text.

Supported values: Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setLogBtnWidth

int

Sets the width of the login button (in dp).

setLogBtnHeight

int

Sets the height of the login button (in dp).

setLogBtnMarginLeftAndRight

int

Sets the left and right margins of the login button (in dp).

setLogBtnBackgroundPath

String

Set the path for the login button background image. The path does not require a suffix, For example, if the image is indrawable directory asres/drawable-xxhdpi/logBtn.png, , then the input parameter islogBtn, , that issetLogBtnBackgroundPath("logBtn").

setLogBtnOffsetY

int

Set the offset of the login button relative to the top of the navigation bar (unit: dp). If this property is set, thensetLogBtnOffsetY_Bwill be invalid.

setLogBtnOffsetY_B

int

Sets the vertical offset of the login button from the bottom of the parent view (in dp).

setLogBtnOffsetX

int

Set the login buttonXX-axis offset.

Note

IfsetLogBtnMarginLeftAndRight, is set and the layout alignment isleft-alignedorright-aligned, the offsetX offset will be added on top of themarginmargin; if it isoffsetXoffset; center-aligned, the offsetXoffsetXoffset will be applied on top of the centering.

setLogBtnLayoutGravity

Gravity

Sets the layout alignment for the login button. The following values are supported:

  • Gravity.CENTER_HORIZONTAL: horizontal center

  • Gravity.LEFT: left

  • Gravity.RIGHT: right

setLogBtnTextSizeDp

int

Sets the font size of the login button text (in dp). The font size does not scale with system font settings.

setLogBtnBackgroundDrawable

Drawable

Sets the background drawable for the one-click login button.

setLoadingImgPath

String

Sets the path of the animated image for the login loading dialog. The path does not require a file extension. For example, if the image is stored in the drawable directory at res/drawable-xxhdpi/loading.png, pass loading as the parameter by calling setLoadingImgPath("loading").

setLoadingImgDrawable

Drawable

Sets the animated image for the login loading dialog from a Drawable resource.

setLoadingBackgroundPath

String

Sets the background image for the one-click login loading dialog from a resource path.

setLoadingBackgroundDrawable

Drawable

Sets the background drawable for the one-click login loading dialog.

setHiddenLoading

boolean

Specifies whether to hide the one-click login loading dialog. Valid values:

  • true: Hides the dialog.

  • false: Shows the dialog.

Authorization page privacy bar

Method

Type

Description

setAppPrivacyOne

String, String

Sets the name and URL for the first developer privacy policy (name, URL).

setAppPrivacyTwo

String, String

Sets the name and URL for the second developer privacy policy (name, URL).

setAppPrivacyThree

String, String

Sets the name and URL for the third developer privacy policy (name, URL).

setAppPrivacyColor

int, int

Sets the text color for the privacy policy. The first parameter sets the color for regular text, and the second sets the color for policy name links. This setting applies to the carrier agreement and all custom agreements.

setPrivacyConectTexts

String[]

Sets the separators between privacy terms. The default value is [" and ", ", ", ", "]. The array elements are the separator characters. For example, if your method parameter is [" and ", ", ", " and "], the result is Agreement 1 and Agreement 2, Agreement 3 and Agreement 4.

To create a line break, add the newline character \n to a specific string in the array. For example: ["and", ",\n", "and"].

setPrivacyOperatorIndex

int

Sets the display order index for the carrier agreement (0 to 3). The default is 0 (first policy), and the maximum is 3 (fourth policy).

setPrivacyOffsetY

int

Sets the offset (in dp) of the privacy policy relative to the top of the navigation bar. If this property is set, setPrivacyOffsetY_B will have no effect.

setPrivacyOffsetY_B

int

Sets the vertical offset (in dp) of the privacy bar from the bottom of the parent view.

setCheckBoxWidth

int

Sets the width of the checkbox (in dp).

setCheckBoxHeight

int

Sets the height of the checkbox (in dp).

setPrivacyState

boolean

Sets the default state of the checkbox. Valid values:

  • true: The checkbox is initially selected.

  • false: The checkbox is initially unselected.

setProtocolShakePath

String

Sets the shake animation for the privacy policy text, which plays if the user taps the login button without selecting the checkbox. You can provide a custom animation resource or use the one provided in the demo.

File path: Demo/demo/src/main/res/anim/protocol_shake.xml,

Example: setProtocolShakePath("protocol_shake").

setProtocolGravity

int

Sets the text alignment for the privacy policy text (e.g., Gravity.CENTER).

setProtocolTypeface

Typeface

Sets the typeface for the privacy policy text.

Valid parameters include Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setPrivacyMargin

int

Sets the horizontal margin for the privacy bar (in dp).

setPrivacyBefore

String

Sets the custom text to display before the developer privacy policy links.

setPrivacyEnd

String

Sets the custom text to display after the developer privacy policy links.

setCheckboxHidden

boolean

Sets whether to hide the checkbox. Valid values:

  • true: Hides the checkbox.

  • false: Shows the checkbox.

setUncheckedImgPath

String

Sets the path of the image that is displayed when the privacy policy checkbox is unchecked. The path does not require a suffix. For example, if the image is stored in the drawable directory at res/drawable-xxhdpi/unchecked.png, pass unchecked as the parameter, as in setUncheckedImgPath("unchecked").

setCheckedImgPath

String

Sets the image for the selected checkbox. Provide the resource name without the file extension.

setCheckBoxMarginTop

int

Sets the top margin of the checkbox (in dp).

setProtocolShakePath

String

The animation effect for the agreement text that is triggered when the login button is clicked while the agreement checkbox is not selected. The value is the path to the anim resource, without the file extension. For example, if the animation is stored in the anim directory as protocol_shake.xml, the parameter to pass is protocol_shake, as in setProtocolShakePath("protocol_shake").

setVendorPrivacyPrefix

String

Sets the prefix character for the carrier agreement link. The value must be one of the following characters: <, (, 《, 【, 『, [, or (.

setVendorPrivacySuffix

String

Sets the suffix character for the carrier agreement link. The value must be one of the following characters: >, ), 》, 】, 』, ], or ).

setProtocolLayoutGravity

int

Set the layout alignment of the privacy bar. Supports the following three alignment methods:

  • Gravity.CENTER_HORIZONTAL:horizontally centered

  • Gravity.LEFT:left-aligned

  • Gravity.RIGHT:right-aligned

Note

This parameter controls the alignment of the entire privacy bar(includingcheckbox)within its parent layout, whilesetProtocolGravitycontrols the alignment of the privacy agreement text content within the text box.

setPrivacyOffsetX

int

Sets the X-axis offset for the privacy bar (in dp).

setLogBtnToastHidden

boolean

Hides or shows the toast notification that appears if the login button is tapped without the checkbox being selected.

setPrivacyTextSize

int

Sets the text size for the privacy terms (in sp).

setPrivacyTextSizeDp

int

Sets the text size for the privacy terms (in dp). This text size does not scale with system font settings.

setUncheckedImgDrawable

Drawable

Sets the drawable resource for the unselected checkbox.

setCheckedImgDrawable

Drawable

Sets the drawable resource for the selected checkbox.

Switch control

Parameter

Type

Description

setSwitchAccHidden

boolean

Sets whether the switch login method control is hidden.

setSwitchAccText

String

Sets the text of the switch login method control.

setSwitchAccTextColor

int

Sets the text color of the switch login method control.

setSwitchOffsetY

int

Sets the vertical offset of the switch login method control from the top of the navigation bar (in dp). If this property is set, setSwitchOffsetY_B is ignored.

setSwitchOffsetY_B

int

Sets the vertical offset of the switch login method control from the bottom of the parent View (in dp).

setSwitchAccTextSizeDp

int

Sets the font size of the switch login method control (in dp). The font size does not scale with system font settings.

useSwitchFontAndPath

boolean,String

Sets whether to use a custom font for the switch button text. The String parameter specifies the name of the custom font file, such as example.ttf. The file must be placed in the assets directory.

  • true: Use a custom font.

  • false: Do not use a custom font.

setSwitchTypeface

Typeface

Sets the typeface for the switch button text.

Valid values: Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

Page configuration

Method

Type

Description

setAuthPageActIn

String,String

Sets the enter animation for the authorization page and the exit animation for the previous screen. Provide the anim resource path without the file extension. For example, setAuthPageActIn("auth_page_enter", "previous_screen_exit").

Note

The first parameter defines the enter animation for the authorization page. The second parameter defines the exit animation for the previous screen.

setAuthPageActOut

String,String

Sets the exit animation for the authorization page and the enter animation for the new screen. Provide the anim resource path without the file extension.

Note

The first parameter defines the exit animation for the authorization page. The second parameter defines the enter animation for the new screen.

setPageBackgroundPath

String

Set the background image of the authorization page. The value must be a drawable resource path without the file extension. For example, if an image is stored at res/drawable-xxhdpi/loading.png, pass loading as the parameter, as in setPageBackgroundPath("loading").

setDialogWidth

int

Sets the width of the authorization page (in dp).

setDialogHeight

int

Sets the height of the authorization page (in dp).

setDialogAlpha

float

Sets the alpha of the authorization page overlay. The value range is 0.0 (fully transparent) to 1.0 (fully opaque).

  • A value of 0 is completely transparent.

  • A value of 1 is completely opaque.

  • A value between 0 and 1 is semi-transparent.

setDialogOffsetX

int

Sets the X-axis offset of the authorization page (in dp).

setDialogOffsetY

int

Sets the Y-axis offset of the authorization page (in dp).

setDialogBottom

boolean

Specifies whether to align the authorization page to the bottom of the screen.

setPageBackgroundDrawable

Drawable

Sets the background drawable for the authorization page.

setProtocolAction

String

Sets a custom intent action for navigating to the agreement page.

setPackageName

String

To use a custom action for the agreement page, you must set this property to your app's package name.

setWebCacheMode

int

Sets the cache mode for the WebView that displays the built-in agreement page.

setWebSupportedJavaScript

boolean

Specifies whether the WebView for the built-in agreement page can run JavaScript scripts. Valid values:

  • true (default): Enables JavaScript.

  • false: Disables JavaScript.

Parameters

Method

Type

Description

setPrivacyAlertIsNeedShow

boolean

Shows or hides the secondary privacy agreement dialog. Valid values:

  • true: Shows the dialog.

  • false (default): Hides the dialog.

setPrivacyAlertIsNeedAutoLogin

boolean

Enables or disables auto-login after the user taps Agree. Valid values:

  • true (default): Enables auto-login.

  • false: Disables auto-login.

setPrivacyAlertPageBackgroundDrawable

Drawable

Sets the background drawable for the secondary privacy agreement dialog.

setPrivacyAlertPageBackgroundPath

String

Sets the background image for the secondary privacy agreement dialog.

Note

The path to the drawable resource. Do not include the file extension. For example, if the image is at res/drawable-xxhdpi/loading.png, pass "loading", such as setPrivacyAlertPageBackgroundPath("loading").

setPrivacyAlertMaskAlpha

float

Sets the alpha for the mask of the secondary privacy agreement dialog. The value must be from 0.3 to 1.0. The default is 0.3.

setPrivacyAlertAlpha

float

Sets the alpha for the secondary privacy agreement dialog. The value must be from 0.3 to 1.0. The default is 1.0.

setPrivacyAlertBackgroundColor

int

Sets the background color for the button area of the secondary privacy agreement dialog.

setPrivacyAlertEntryAnimation

String

Sets the entry animation for the secondary privacy agreement dialog.

setPrivacyAlertExitAnimation

String

Sets the exit animation for the secondary privacy agreement dialog.

setPrivacyAlertCornerRadiusArray

int[]

Sets the four corner radius values for the secondary privacy agreement dialog. The array must contain exactly four values, corresponding to the top-left, top-right, bottom-right, and bottom-left corners, in that order. A value of 0 or less creates a right-angled corner.

setPrivacyAlertAlignment

int

Sets the alignment of the secondary privacy agreement dialog. Valid values are Center, Top, Bottom, Left, and Right. The default is Center.

setPrivacyAlertWidth

int

Sets the width of the dialog (in dp).

setPrivacyAlertHeight

int

Sets the height of the dialog (in dp).

setPrivacyAlertOffsetX

int

Sets the horizontal offset of the dialog (in dp).

setPrivacyAlertOffsetY

int

Sets the vertical offset of the dialog (in dp).

setPrivacyAlertTitleBackgroundColor

int

Sets the background color of the title area in the secondary privacy agreement dialog.

setPrivacyAlertTitleAlignment

int

Sets the text alignment for the title in the secondary privacy agreement dialog. Valid alignments are Center and Left. The default is Center.

setPrivacyAlertTitleOffsetX

int

Sets the horizontal offset of the title text (in dp).

setPrivacyAlertTitleOffsetY

int

Sets the vertical offset of the title text (in dp).

setPrivacyAlertTitleContent

String

Sets the title text.

setPrivacyAlertTitleTextSize

int

Sets the font size of the title text. The default is 18 sp.

setPrivacyAlertTitleColor

int

Sets the color of the title text.

setPrivacyAlertContentBackgroundColor

int

Sets the background color of the agreement content area.

setPrivacyAlertContentTextSize

int

Sets the font size of the service agreement text. The default is 16 sp.

setPrivacyAlertContentAlignment

int

Sets the text alignment for the agreement content in the secondary privacy agreement dialog. Valid alignments are Center and Left. The default is Left.

setPrivacyAlertContentColor

int

Sets the text color of the service agreement.

setPrivacyAlertContentBaseColor

int

Sets the color for the non-link text within the service agreement.

setPrivacyAlertContentHorizontalMargin

int

Sets the horizontal margin for the service agreement text (in dp).

setPrivacyAlertContentVerticalMargin

int

Sets the vertical margin for the service agreement text (in dp).

setPrivacyAlertBtnBackgroundImgPath

String

Sets the path to the background image for the confirm button.

setPrivacyAlertBtnBackgroundImgDrawable

Drawable

Sets the background drawable for the confirm button.

setPrivacyAlertBtnTextColor

int

Sets the text color of the confirm button.

setPrivacyAlertBtnTextColorPath

String

Sets the resource path for the text color of the confirm button.

setPrivacyAlertBtnTextSize

int

Sets the font size of the confirm button text. The default is 18 sp.

setPrivacyAlertBtnWidth

int

Sets the width of the confirm button (in dp).

setPrivacyAlertBtnHeigth

int

Sets the height of the confirm button (in dp).

setPrivacyAlertCloseBtnShow

boolean

Shows or hides the close button in the top-right corner.

  • true (default): Shows the close button.

  • false: Hides the close button.

setPrivacyAlertCloseImagPath

String

Sets the resource path for the close button image.

setPrivacyAlertCloseScaleType

ImageView.ScaleType

Sets the scale type for the close button image.

setPrivacyAlertCloseImagDrawable

Drawable

Sets the drawable for the close button image.

setPrivacyAlertCloseImgWidth

int

Sets the width of the close button (in dp).

setPrivacyAlertCloseImgHeight

int

Sets the height of the close button (in dp).

setPrivacyAlertBtnGrivaty

int[]

Sets the layout gravity for the confirm button.

setPrivacyAlertBtnContent

String

Sets the text of the confirm button.

setPrivacyAlertBtnHorizontalMargin

int

Sets the horizontal margin for the confirm button (in dp).

setPrivacyAlertBtnVerticalMargin

int

Sets the vertical margin for the confirm button (in dp).

setTapPrivacyAlertMaskCloseAlert

boolean

Set whether clicking the background mask of the secondary privacy agreement popup closes the popup.

  • true (default): close.

  • false: do not close.

setPrivacyAlertTitleTypeface

Typeface

Sets the typeface for the title text in the secondary privacy agreement dialog.

Valid values are: Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

usePrivacyAlertContentFontAndPath

boolean, String

Specifies whether to use a custom typeface for the agreement text. The String parameter specifies the name of the custom font file (e.g., example.ttf) in the assets directory.

  • true: Uses a custom typeface.

  • false: Does not use a custom typeface.

setPrivacyAlertContentTypeface

Typeface

Sets the typeface for the agreement text in the secondary privacy agreement dialog.

Valid values are: Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setPrivacyAlertBtnTypeface

Typeface

Sets the typeface for the confirm button text in the secondary privacy agreement dialog.

Valid values are: Typeface.SANS_SERIF, Typeface.SERIF, and Typeface.MONOSPACE.

setPrivacyAlertBefore

String

Sets the prefix text for the service agreement in the secondary privacy agreement dialog.

setPrivacyAlertEnd

String

Sets the suffix text for the service agreement in the secondary privacy agreement dialog.

setPrivacyAlertOneColor

int

Sets the text color for the first privacy policy link on the authorization page.

setPrivacyAlertTwoColor

int

Sets the text color for the second privacy policy link on the authorization page.

setPrivacyAlertThreeColor

int

Sets the text color for the third privacy policy link on the authorization page.

setPrivacyAlertOperatorColor

int

Sets the text color for the carrier agreement link on the authorization page.

Xml for login screen

/**
 * @param xmlConfig
 */
@AuthNumber
public void addAuthRegisterXmlConfig(AuthRegisterXmlConfig xmlConfig)

Usage example

fusionNumberAuthModel.addAuthRegisterXmlConfig(new AuthRegisterXmlConfig.Builder()
        .setLayout(0, // The layout ID of the custom XML layout.
            new AbstractPnsViewDelegate(){
            @Override
            public void onViewCreated(View view) {
                // Add your logic for the custom layout, such as click events.
            }
        }).build());

View for login screen

/**
 * @param viewID     The ID of the view.
 * @param viewConfig The dynamic configuration for the view.
 */
public void addAuthRegistViewConfig(String viewID, AuthRegisterViewConfig viewConfig)

Usage example

fusionNumberAuthModel.addAuthRegistViewConfig("<VIEW_ID>",new AuthRegisterViewConfig.Builder()
        // Add a custom view.
        .setView(null)
        //.setView(initNumberTextView())
        
        // The `RootViewId` parameter accepts three values:
        // AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY: The area below the navigation bar.
        // AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_TITLE_BAR: The navigation bar section. For this to take effect, ensure the navigation bar is displayed using `setNavHidden` and `setNavReturnHidden`.
        // AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_NUMBER: The mobile number section.
        .setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY)
        .setCustomInterface(new CustomInterface() {
            @Override
            public void onClick(Context context) {
               // A click event for the custom view.
            }
        }).build());

Xml for pop-up screen

/**
 * @param xmlConfig
 */
public void addPrivacyRegisterXmlConfig(AuthRegisterXmlConfig xmlConfig)

Usage example

fusionNumberAuthModel.addPrivacyRegisterXmlConfig(new AuthRegisterXmlConfig.Builder()
        .setLayout(0, // The layout ID of the custom XML layout.
            new AbstractPnsViewDelegate(){
            @Override
            public void onViewCreated(View view) {
                // Add your logic for the custom layout, such as click events.
            }
        }).build());

View for pop-up screen

/**
 * @param viewID The ID of the view.
 * @param viewConfig The dynamic configuration for the view.
 */
public void  addPrivacyAuthRegistViewConfig(String viewID, AuthRegisterViewConfig viewConfig)

Usage example

fusionNumberAuthModel.addPrivacyAuthRegistViewConfig("<VIEW_ID>", new AuthRegisterViewConfig.Builder()
        // Add a custom view.
        .setView(null)
        
        // RootViewId has three parameters:
        // AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY: The agreement text area.
        // AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_TITLE_BAR: The top navigation bar section.
        // AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_NUMBER: The button area.
        .setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_NUMBER)
        .setCustomInterface(new CustomInterface() {
            @Override
            public void onClick(Context context) {
                // The click event for the custom view.
            }
        }).build());

SMS authentication custom UI parameters AlicomFusionVerifyCodeView

public class AlicomFusionVerifyCodeView {
    // Title area.
    private RelativeLayout titleRl;
    // Back button.
    private ImageView returnImg;
    // Title text.
    private TextView titleContentTV;
    // Phone number auto-fill area.
    private AlicomFusionAutoInputView autoInputView;
    // Phone number manual input area.
    private AlicomFusionInputView inputView;
    // Verification code input and sending area.
    private AlicomFusionSendVerifyCodeView sendVerifyCodeView;

    // Sends a verification code.
    public void verifyCodeBtnClick(String phoneNumber)

    // Verifies the verification code.
    public void submitVerifyCodeBtnClick(String phoneNumber, String code)
}

Auto-fill

public class AlicomFusionAutoInputView {
    /** Layout that displays the phone number and hint message in the auto-fill view. */
    private RelativeLayout autoInputMsgRL;
    /** TextView that displays the phone number in the auto-fill view. */
    private TextView autoInputPhoneNumTV;
    /** TextView that displays the hint message in the auto-fill view. */
    private TextView autoInputPhoneHintTV;
     /** A button that requests a verification code in the auto-fill view. */
    private TextView autoInputRequestCodeTV;
}

Manual input

public class AlicomFusionInputView {
    /** Layout that contains the country code and phone number input field. */
    private RelativeLayout inputNumberContentRL;
    /** TextView that displays the country code. */
    private TextView mCountryTV;
    /** The phone number input field. */
    private EditText inputNumberET;
    /** A button that requests a verification code in the manual input view. */
    private TextView inputNumberRequestCodeTV;
    /** Layout for the agreement section. */
    private RelativeLayout privacyRL;
    /** The agreement checkbox. */
    private CheckBox agreePrivacy;
    /** TextView that displays the agreement text. */
    private TextView privacyTV;
}

Verification code

public class AlicomFusionSendVerifyCodeView {
    /** TextView that displays a hint message. */
    private TextView sendSmsHint;
    /** Layout for the verification code input fields. */
    private RelativeLayout sendSmsCodeRL;
    /** Input field for the first digit of the verification code. */
    private EditText firstCode;
    /** Input field for the second digit of the verification code. */
    private EditText secondCode;
    /** Input field for the third digit of the verification code. */
    private EditText thirdCode;
    /** Input field for the fourth digit of the verification code. */
    private EditText fourCode;
    /** Input field for the fifth digit of the verification code. */
    private EditText fifthCode;
    /** Input field for the sixth digit of the verification code. */
    private EditText sixthCode;
    /** A button that submits the verification code. */
    private TextView sendSmsCode;
}

Custom UI parameters AlicomFusionUpSMSView

public class AlicomFusionUpSMSView {
    // Layout for the top navigation area.
    private RelativeLayout titleRl;
    // Back button.
    private ImageView returnImg;
    // Title text view.
    private TextView titleContentTV;
    // Layout for the prompt message area.
    private RelativeLayout remindRl;
    // Displays the prompt message.
    private TextView smsRemindTV;
    // Layout for the SMS content area.
    private RelativeLayout smsContentRl;
    // Displays the SMS content.
    private TextView smsContentTV;
    // Layout for the recipient number area.
    private RelativeLayout receiveSmsNumberRl;
    // Displays the recipient number.
    private TextView receiveSmsNumberTV;
    // Sends the SMS.
    private TextView sendSmsTV;
    // Confirms that the SMS has been sent.
    private TextView HadSenTSmsTV;

    // Sends an uplink SMS.
    public void gotoSendUpSms(String receivePhoneNumber, String verifyCode)

    // Verifies that the SMS has been sent.
    public void upSmsAlreadySend()
}