# Troubleshooting

This document compiles common issues you might encounter when integrating AIHelp Web SDK, helping you troubleshoot during the integration process.

# Why doesn't the image upload function work on Android devices?

When implementing image upload functionality in the Web version on Android devices, you need to handle two key aspects:

  1. Permission Management

Declare necessary permissions in AndroidManifest.xml and implement runtime permission request logic:

// Declare permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

// Implement runtime permission request logic
private static final int PERMISSION_REQUEST_CODE = 1001;
String[] permissions = {
    Manifest.permission.READ_EXTERNAL_STORAGE,
    Manifest.permission.WRITE_EXTERNAL_STORAGE
};
ActivityCompat.requestPermissions(activity, permissions, PERMISSION_REQUEST_CODE);
  1. WebView File Choose Implementation

Configure WebView settings and override file selection methods in WebChromeClient:

// Configure WebView settings for file selection
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(true);

// Override file selection methods in WebChromeClient
webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public boolean onShowFileChooser(WebView webView, 
        ValueCallback<Uri[]> filePathCallback,
        FileChooserParams fileChooserParams) {
        // TODO: Implement file selection logic
        return true;
    }
});

# Why do camera options appear when uploading images on iOS devices?

On iOS devices, when triggering file selection in a web page, the system automatically displays a menu with options for taking photos, recording videos, and selecting files.

The app may crash if camera permissions aren't declared when accessing the camera option, or if microphone permissions aren't declared when switching to video mode.

To address this, declare the following permissions in Info.plist:

<!-- Camera Permission -->
<key>NSCameraUsageDescription</key>
<string>Camera access is required for taking photos</string>

<!-- Microphone Permission (if video recording is allowed) -->
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for recording videos</string>

<!-- Photo Library Permission -->
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library access is required for selecting images</string>

This is system-level behavior in iOS and cannot be modified. We recommend implementing proper permission management and error handling to ensure a good user experience.

# Why does the SDK display a different language than specified?

Normally, you can specify the SDK's display language through the last parameter of the init method. If not set, the SDK will initialize using the device language.

To ensure optimal user experience, AIHelp implements a language correction logic:

  1. We standardize different language codes. For example, zh / zh-cn / zh-CN / zh_CN / zh-hans are all converted to zh-CN for processing
  2. If the corrected language isn't enabled in the backend, it will be corrected to the default language set in the AIHelp backend

The AIHelp backend typically defaults to English, making it the fallback language. This default can be adjusted based on specific requirements.

Note that AIHelp API currently accepts ISO 639-1 language codes. Country codes should not be used during initialization, as some country codes might conflict with language codes. For example, 'KR' represents South Korea in country codes but refers to the Kanuri language in language codes.

If your project currently uses country codes, we recommend mapping ISO-3166 country codes to ISO 639-1 language codes before passing them to AIHelp.


# Why does player information appear as 'anonymous' with random characters in the customer service backend?

By default, before calling the updateUserInfo API, AIHelp uses 'anonymous' as the username and 'deviceId' as the user ID.

Additionally, UID information isn't synchronized with the backend until the AIHelp page is opened. Since UID is stored in memory, user sessions will work correctly as long as the UID is available before opening the page.

If the information isn't showing in the customer service backend, it's likely that the API wasn't called effectively.

This might be due to the timing of the updateUserInfo API call - this API must be called after initialization.

AIHelpSupport.init(/* your code here */);
AIHelpSupport.updateUserInfo(/* your code here */);

The updateUserInfo call only needs to occur after init; it doesn't depend on successful initialization.

If user information is updated before initialization, it might be returned without being set successfully. Consider updating user information just before opening the page to resolve this issue.


Last Updated: 11/30/2024, 11:18:33 AM