# \[iOS]アプリ内メッセージの表示の仕組み

アプリ内メッセージの表示にはWebView（WKWebView）を利用しています。\
このため管理画面上で、HTML / CSS / JavaScript をカスタマイズすることでアプリケーションのコードを変更することなく、アクションの見た目を変更することが可能となっています。

![アプリ内メッセージ表示のイメージ（グレーの領域がWebView）](/files/8Wb6boJJTsk0HusZSNlG)

## WebViewのライフサイクル

WebViewは、SDKが初期化されるタイミングで生成されメモリ上に保持されます。

アプリ内メッセージの表示が必要となった場合、以下のステップで表示処理を行います。

1. Windowを生成
2. ViewControllerを生成
3. ViewControllerにWebViewを配置
4. ViewControllerをWindowに配置
5. Windowを表示\
   アプリケーションのView階層上に配置される。

WebView上のアクションが非表示になった場合は、以下のステップで非表示処理を行います。

1. WindowおよびViewControllerを破棄
2. WebViewのみメモリ上に保持

## Windowの表示レベル

SDKが生成する Window の WindowLevel は `UIWindowLevelNormal + 10` としています。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://app.developers.karte.io/ios-sdk-appendix/appendix-iam-spec-ios-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
