Repro - Mobile Analytics for growth
English
アカウント登録 管理画面に戻る
  • 動作環境
  • 管理画面ガイド
  • 開発ガイド
  • リリースノート
  • FAQ
    • App
      • SDK
        • 端末の広告ID(IDFA, ADID)はどうすれば取得できますか?
        • セッションがアップロードされないケースは何がありますか?
        • アプリ内パラメーターの実装例を教えてください
          • 1. デフォルトパラメーターを設定する
          • 2. アプリ内パラメーターを使用するコードを記述する
          • 3. キャンペーンを作成する
          • アプリ起動直後に表示される画面でアプリ内パラメーターを参照したい場合
      • プッシュ通知
      • イベントトラッキング
      • ユーザープロフィール
      • WebView
      • その他
    • Web
    • 共通
    • Booster

アプリ内パラメーターの実装例を教えてください¶

バナー枠の制御をアプリ内パラメーターで行う場合のサンプルコードを提示します。

../../../_images/remote-config-banner-sample.ja.png

使用するパラメーター

パラメーター名 変数名 パラメーター例
表示フラグ show_flag true/false
バナー遷移先URL banner_url https://example.com/campaign/springYYYYMMDD/
表示バナー画像URL banner_img_url https://example.com/img/XXX.png

1. デフォルトパラメーターを設定する¶

デフォルトのパラメーターを作成する を参考に、デフォルトパラメーターを画像のように設定してください。

../../../_images/remote-config-default-parameter.ja.png

2. アプリ内パラメーターを使用するコードを記述する¶

バナー枠を表示したい場所に、アプリ内パラメーターを使って判定するコードを記述してください。

// Returns a Dictionary with key values
NSDictionary<NSString *, RPRRemoteConfigValue *> *values = [[Repro remoteConfig] allValues];
if (values[@"show_flag"] != nil && [values[@"show_flag"].stringValue isEqual: @"true"]) {
    // Write code using `values[@"banner_url"]` and `values[@"banner_img_url"]`
}
// Returns a Dictionary with key values
let values: Dictionary<String, RPRRemoteConfigValue> = Repro.remoteConfig.allValues()
if let value = values["show_flag"], value.stringValue == "true" {
    // Write code using `values["banner_url"]` and `values["banner_img_url"]`
}
// Returns a Dictionary with key values
Map<String, RemoteConfigValue> values = Repro.getRemoteConfig().getAllValues();
if (values.get("show_flag") != null && values.get("show_flag").equals("true")) {
    // Write code using `values.get("banner_url")` and `values.get("banner_img_url")`
}
// Returns a Dictionary with key values
val values = Repro.getRemoteConfig().allValues
if (values["show_flag"] != null && values["show_flag"].toString() == "true") {
    // Write code using `values["banner_url"]` and `values["banner_img_url"]`
}
// Returns a Map with all values.
std::map<std::string, RemoteConfigValue*> values = ReproCpp::getRemoteConfig().getAllValues();
if (values["show_flag"] != nullptr && values["show_flag"] == "true") {
    // Write code using `values["banner_url"]` and `values["banner_img_url"]`
}
// Returns a Dictionary with all values.
Dictionary<string, RemoteConfigValue> values = Repro.RemoteConfig.GetAllValues();
if (values["show_flag"] != null && values["show_flag"] == "true") {
    // Write code using `values["banner_url"]` and `values["banner_img_url"]`
}
// Returns an associative array with all values.
Repro.remoteConfig.getAllValues(
    function(values) {
        if (values["show_flag"] != null && values["show_flag"] == "true") {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
);
// Returns an associative array with all values.
Repro.remoteConfig.getAllValues((values) => {
    if (values["show_flag"] != null && values["show_flag"] == "true") {
        // Write code using `values["banner_url"]` and `values["banner_img_url"]`
    }
});
// Returns a Map with all values.
var values = await Repro.remoteConfig.getAllValues();
if (values["show_flag"] != null && values["show_flag"].toString() == "true") {
    // Write code using `values["banner_url"]` and `values["banner_img_url"]`
}

3. キャンペーンを作成する¶

キャンペーンを作成する を参考に、バナーを表示したいユーザーに配信されるようキャンペーンを作成してください

../../../_images/remote-config-campaign.ja.png

アプリ起動直後に表示される画面でアプリ内パラメーターを参照したい場合¶

アプリ起動直後に表示される画面で、ユーザーごとに表示を切り替えるためにアプリ内パラメーターを使用したい場合、 Repro の setup が完了するまでアプリ内パラメーターの最新の値は反映されません。 その場合、 fetch をご利用いただくことで、 setup の完了を待ってからアプリ内パラメーターの値を使用することが可能です。 setup より前に fetch のコールバック関数を定義し、その中で値を取得した後の処理を記述してください。

以下にコード例を提示します。

[[Repro remoteConfig] fetchWithTimeout:0 completionHandler:^(RPRRemoteConfigFetchStatus fetchStatus) {
    if (fetchStatus == RPRRemoteConfigFetchStatusSuccess) {
        [[Repro remoteConfig] activateFetched];
        NSDictionary<NSString *, RPRRemoteConfigValue *> *values = [[Repro remoteConfig] allValues];
        if (values["show_flag"] != null && values["show_flag"].toString() == "true") {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
}];

[Repro setup:@"YOUR_APP_TOKEN"];
Repro.remoteConfig.fetch(withTimeout: 0) { status in
    if status == .success {
        Repro.remoteConfig.activateFetched()
        let values: Dictionary<String, RPRRemoteConfigValue> = Repro.remoteConfig.allValues()
        if let value = values["show_flag"], value.stringValue == "true" {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
}

Repro.setup(token: "YOUR_APP_TOKEN")
Repro.getRemoteConfig().fetch(0, new RemoteConfigListener() {
    @Override
    public void onCompletion(FetchStatus status) {
        if (status == FetchStatus.SUCCESS) {
            Repro.getRemoteConfig().activateFetched();
            Map<String, RemoteConfigValue> values = Repro.getRemoteConfig().getAllValues();
            if (values.get("show_flag") != null && values.get("show_flag").equals("true")) {
                // Write code using `values.get("banner_url")` and `values.get("banner_img_url")`
            }
        }
    }
});

Repro.setup(this, YOUR_APP_TOKEN);
Repro.getRemoteConfig().fetch(0) { status ->
    if (status == FetchStatus.SUCCESS) {
        Repro.getRemoteConfig().activateFetched()
        val values = Repro.getRemoteConfig().allValues
        if (values["show_flag"] != null && values["show_flag"].toString() == "true") {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
}

Repro.setup(this, YOUR_APP_TOKEN)
ReproCpp::getRemoteConfig().fetch(0, [](ReproCpp::RemoteConfig::FetchStatus status) {
    if (status == ReproCpp::RemoteConfig::FetchStatusSuccess) {
        ReproCpp::getRemoteConfig().activateFetched();
        std::map<std::string, RemoteConfigValue*> values = ReproCpp::getRemoteConfig().getAllValues();
        if (values["show_flag"] != nullptr && values["show_flag"] == "true") {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
});
Repro.RemoteConfig.Fetch(0, (status) =>
{
    if (status == Repro.FetchStatus.Success)
    {
        Repro.RemoteConfig.ActivateFetched();
        Dictionary<string, RemoteConfigValue> values = Repro.RemoteConfig.GetAllValues();
        if (values["show_flag"] != null && values["show_flag"] == "true")
        {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
});
Repro.remoteConfig.fetch(0, function(status) {
    // success callback
    if (status == Repro.remoteConfig.FetchStatus.Success) {
        Repro.remoteConfig.activateFetched(function(message) {
            // success callback
            Repro.remoteConfig.getAllValues(
                function(values) {
                    if (values["show_flag"] != null && values["show_flag"] == "true") {
                        // Write code using `values["banner_url"]` and `values["banner_img_url"]`
                    }
                }
            );
        }, function(message) {
            // error callback
        });
    }
}, function(status) {
    // error callback
});
Repro.remoteConfig.fetch(0, (status) => {
    if (status == Repro.remoteConfig.FETCH_STATUS.REMOTE_CONFIG_SUCCESS) {
        Repro.remoteConfig.activateFetched();
        Repro.remoteConfig.getAllValues((values) => {
            if (values["show_flag"] != null && values["show_flag"] == "true") {
                // Write code using `values["banner_url"]` and `values["banner_img_url"]`
            }
        });
    } else if (status == Repro.remoteConfig.FETCH_STATUS.REMOTE_CONFIG_TIMEOUT_REACHED) {
    } else if (status == Repro.remoteConfig.FETCH_STATUS.REMOTE_CONFIG_ALREADY_FETCHED) {
    }
});
await Repro.remoteConfig.fetch(0, (result) {
    if (result == FetchStatus.success) {
        await Repro.remoteConfig.activateFetched();
        var values = await Repro.remoteConfig.getAllValues();
        if (values["show_flag"] != null && values["show_flag"].toString() == "true") {
            // Write code using `values["banner_url"]` and `values["banner_img_url"]`
        }
    }
});
  • « セッションがアップロードされないケースは何がありますか?
  • プッシュ通知が受信できないのですが、原因は何かありますか? »

About Us Careers Terms of Service Privacy Policy Cookie Policy

© 2022 Repro Inc.