Titanium製AndroidアプリのWebViewでCookieをHTTPClientと共有する方法
久々に問題解決でドはまりしたのでメモ。しかしひどいタイトルだ……。
はじめに
TitaniumでAndroidアプリを作成する際、Cookieの扱いには注意が必要です。
On Android, the HTTPClient uses its own cookie store which does not share cookies with the system cookie store used by Titanium.UI.WebView.
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Network.HTTPClient-method-getResponseHeader
Androidでは、HTTPClientは自分自身のCookieを使用します。それはTitanium.UI.WebViewが使用するSystem Cookieとは内容を共有しません。
つまり、HTTPClientとWebViewでのCookieは自動的には共有されないということです。この現象はAndroidでのみ発生します。iOSアプリではこの違いを意識する必要はなく、HTTPClientのCookieはWebViewにも引き継がれます。