# Frequently Asked Questions

## 🔆 Forcing Light/Dark UI

By default the iAdvize Mobile SDK displays its UI following the user settings choice on light/dark mode. It is however possible to force the light/dark mode to a given value.

{% tabs %}
{% tab title="Android" %}
Using [setDefaultNightMode](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode\(int\)) inside the `Application` object will force the app, and thus the SDK Chatbox, to be displayed in the chosen mode:

```kotlin
class App : Application() {
  override fun onCreate() {
    super.onCreate()
    AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO)
  }
}
```

{% endtab %}

{% tab title="iOS" %}
Using [overrideUserInterfaceStyle](https://developer.apple.com/documentation/uikit/uiview/3238086-overrideuserinterfacestyle) on the highest hierarchy view (Window) will force the app, and thus the SDK Chatbox, to be displayed in the chosen mode:

```swift
override func viewDidAppear(_ animated: Bool) {
  super.viewDidAppear(animated)
  view.window?.overrideUserInterfaceStyle = .light
}
```

You can also directly set the value inside your `Info.plist` file:

```swift
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    ...
    <key>UIUserInterfaceStyle</key>
    <string>Light</string>
</dict>
</plist>
```

{% endtab %}
{% endtabs %}

## 📣 Updating targeting language

The iAdvize Mobile SDK has a navigation process that is language dependent. That means that when the targeting language is updated inside the client application (for instance in apps offering multiple languages support) the targeting process must be updated in order for the engagement process to be functional again. This can be easily done by calling `activateTargetingRule` right after updating the targeting language:

{% tabs %}
{% tab title="Android" %}

```kotlin
IAdvizeSDK.targetingController.language = LanguageOption.Custom(Language.fr)
IAdvizeSDK.targetingController.activateTargetingRule(rule)
```

{% endtab %}

{% tab title="iOS" %}

```swift
IAdvizeSDK.shared.targetingController.language = .custom(value: .fr)
IAdvizeSDK.shared.targetingController.activateTargetingRule(targetingRule: rule)
```

{% endtab %}

{% tab title="React Native" %}

```javascript
IAdvizeSDK.setLanguage('fr');
IAdvizeSDK.activateTargetingRule(rule);
```

{% endtab %}

{% tab title="Flutter" %}

```dart
IAdvizeSdk.setLanguage('fr');
IAdvizeSdk.registerUserNavigation(rule);
```

{% endtab %}
{% endtabs %}

This only concerns the targeting language. For information about the SDK localization, check [#interface-localization](#interface-localization "mention").

## 🌍 Interface localization

The iAdvize Mobile SDK supports the localization of its interface in 14 languages:

* Czech
* Danish
* Dutch
* English
* French
* German
* Italian
* Lithuanian
* Portuguese
* Spanish
* Polish
* Romanian
* Slovak
* Swedish

The localization is automatic but you may need to check that your project meets the requirements, depending on the platform.

{% tabs %}
{% tab title="Android" %}
The localization is automatic, there are no further steps required.
{% endtab %}

{% tab title="iOS" %}
The localization is automatic, providing the fact that your project already supports the language.

**Check your project settings**

1\. **Select your Xcode project** in the Project Navigator (left pane).

2\. Click on the **Project** or **Target** in the center pane.

3\. Go to the **Info** tab.

4\. Ensure that the language you want to support appears under **Localizations**.

**Ensure there is at least one localization file**

1\. **Create the file** (if you don’t already have one) by choosing **File** → **New** → **File…** in the menu bar.

2\. Select **Strings File**, name it Localizable.strings, and add it to your project.

3\. In the **File Inspector** (right pane), under **Localizations**, check the languages that you want to include (e.g., English, French, German, etc.).
{% endtab %}
{% endtabs %}

If your app runs in a language that does not belong to the supported languages, the iAdvize Mobile SDK will be localized in English.

This only concerns the interface language. For information about the **targeting language**, check [#updating-targeting-language](#updating-targeting-language "mention").

## 🚦 Testing the SDK on Android <a href="#testing-the-sdk-android" id="testing-the-sdk-android"></a>

If you are running unit tests that implies the SDK, some additional steps may be needed.

The Android SDK uses two device system constants that are not instantiated inside the unit test flow, you will have to register them inside your unit tests initiation:

```
ReflectionHelpers.setStaticField(android.os.Build::class.java, "MODEL", "whatever")
ReflectionHelpers.setStaticField(android.os.Build::class.java, "MANUFACTURER", "whatever")
```

{% hint style="warning" %}
*Please also be sure to initialize the SDK during the unit tests setup (see the* [*Setting up the SDK*](https://github.com/iadvize/public-developers-documentation/blob/master/technologies/web-and-mobile-sdk/mobile-sdk/broken-reference/README.md) *section).*
{% endhint %}

## 🔀 Threading on iOS

The iAdvize iOS SDK offers several callbacks through delegate methods and completion handlers.

In most cases, these callbacks are used to perform UI-related tasks. To ensure thread safety, the majority of the SDK's delegates and completion handlers are annotated with the `@MainActor` keyword. This guarantees that the callbacks are always executed on the main thread.

An important exception is the `JWEProvider` protocol and its `willRequestJWE(completion:)` method. Neither the protocol nor the method's completion handler are annotated with `@MainActor`. This design choice allows your `JWEProvider` implementation to operate independently of the main thread. You are free to invoke the completion handler from any thread, based on your implementation's requirements.

More broadly, the iAdvize iOS SDK is fully compatible with apps using Swift Concurrency and Swift 6 Language Mode. It is important **not** to use `@preconcurrency` when importing the iAdvize iOS SDK, as it is designed to integrate seamlessly without additional annotations.
