メールテンプレートのローカライズ
ユーザー作成時にロケールを設定することで、認証に使用するメールのテンプレートをこのロケール用のものに切り替えることができます。
ユーザーデバイスのロケールは Locale#getDefault()
メソッドで取得できます。実際に KiiUser
に設定する際には、次のサンプルコードのように LocaleContainer
クラスのインスタンスを利用します。LocaleContainer
クラスは、各プラットフォームごとに異なるロケールの表現形式をサーバーが認識できる共通のフォーマットに変換するクラスです。
-
String password = "123456"; // Create a user. KiiUser user = KiiUser.builderWithName("user_123456").build(); // Set the browser locale. user.setLocale(new LocaleContainer(Locale.getDefault())); try { // Register the user. user.register(password); } catch (AppException e) { // Handle the error. } catch (IOException e) { // Handle the error. }
-
String password = "123456"; // Create a user. KiiUser user = KiiUser.builderWithName("user_123456").build(); // Set the browser locale. user.setLocale(new LocaleContainer(Locale.getDefault())); // Register the user. user.register(new KiiUserCallBack() { @Override public void onRegisterCompleted(int token, KiiUser user, Exception exception) { if (exception != null) { // Handle the error. return; } } }, password);