Repro - Mobile Analytics for growth
English
アカウント登録 管理画面に戻る
  • 動作環境
  • 管理画面ガイド
  • 開発ガイド
    • アカウント作成
    • iOS/Android SDK
      • 導入
      • セッション・ライフサイクル
      • ユーザーID
      • デバイスID
      • ユーザープロフィール
      • イベントトラッキング
      • プッシュ通知
        • APNs証明書の設定 (iOS)
        • FCMの設定 (Android)
        • iOS
        • Android
        • Unity
        • Cordova
        • Monaca
        • Cocos2d-x
        • React Native
        • React Native (Expo)
        • Flutter
          • プッシュ通知の設定(iOS)
          • プッシュ通知の設定(Android)
          • オプション:ユニバーサルリンク/アプリリンクを使用する
      • ニュースフィード
      • アプリ内メッセージ
      • シルバーエッグレコメンドメッセージ
      • アプリ内パラメーター
      • WebView
      • オプトアウト機能
      • 広告ID取得設定
      • QRコードを用いてオーディエンスにユーザーを登録する
      • Adjustで取得したアトリビューションデータをReproにセットする
      • AppsFlyerで取得したアトリビューションデータをReproにセットする
      • ログレベル
      • 検証方法
    • Web
    • オーディエンスAPI
    • オーディエンスインポート(β)
    • プッシュAPI
    • ユーザープロフィールAPI
    • ユーザープロフィールバルクインポート
    • ニュースフィードAPI
    • 削除ユーザー登録API
    • Booster導入ガイド
    • メール(β)
  • リリースノート
  • FAQ
dart

プッシュ通知 (Flutter)¶

プッシュ通知の設定(iOS)¶

  1. APNs証明書の設定 (iOS) を参照し、設定してください。
  2. プッシュ通知(iOS) を参照し、デバイストークンを Repro に送信するための実装を行ってください。

プッシュ通知の設定(Android)¶

  1. Flutter アプリに Firebase を追加する および FlutterFire Overview | FlutterFire を参照し、FlutterFireの導入および設定を行ってください。(プッシュ通知の利用には firebase_core および firebase_messaging の導入が必要です。)
  2. FCMの設定 (Android) と プッシュ通知(Android) を参照し、設定してください。(サンプルコードの表示言語をDartに切り替えてご確認ください。)
    • プッシュ通知(Android) の build.gradle への implementation の追記は不要です。

注釈

  • 弊社では firebase_core 3.12.1 および firebase_messaging 15.2.4 を導入した状態で動作を確認しております。
  • プッシュ通知受信時の動作をカスタマイズする方法については、 オプション:プッシュ通知受信時の動作をカスタマイズする 内でDartにて実装を行う方法を掲載しております。 ページ内のサンプルコードの言語を切り替えてご確認ください。(FirebaseMessagingService 継承クラスの実装は不要ですが、同様の実装をDartにて行う必要があります。)
  • プッシュ通知の設定方法については、Flutter Package 付属のサンプルアプリケーションおよび以下のサイトに記載の解説もあわせて参考にしてください。
    • https://pub.dev/packages/repro_flutter#how-to-run-the-example-app

オプション:ユニバーサルリンク/アプリリンクを使用する¶

端末に表示されたプッシュ通知およびアプリ内メッセージに設定されたリンクをタップした際に実行されるURLには、ユニバーサルリンク(またはアプリリンクと呼ばれる)を指定することが可能です。 (簡単のため、以下ではこれらをユニバーサルリンクと呼びます)

アプリにてユニバーサルリンクの実行時の処理を追加するには、以下の通り実装を行う必要があります。 (ここで設定された動作は、プッシュ通知およびアプリ内メッセージ対し有効となります。)

ユニバーサルリンクのURLパターンを登録する¶

ユニバーサルリンクを利用するためには、まずユニバーサルリンクのURLのパターン(正規表現)を指定する必要があります。

注釈

パターン(正規表現)に合致すると、プッシュ通知の開封時や、アプリ内メッセージの遷移先に設定されたURLに対して、後述のコールバック処理をキックします。

また、アプリ内メッセージでHTMLコンテンツを表示するとき、そのコンテンツ内で発生したリクエストに対してもユニバーサルリンクの判定が行われます。

この指定は、iOSの場合は AppDelegate または .plist ファイル、Androidの場合は Application 継承クラス または AndroidManifest.xml ファイルのどちらか一方に記述することで行うことができます。

// AppDelegate.m

#import <Repro/Repro.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [Repro addOpenUrlFilterRegEx:@"https://example\\.com/page/"];
    [Repro addOpenUrlFilterRegEx:@"your-domain\\.com/.+\?universal=true"];
    ...
}


// .plist file
/*
<dict>
    <key>RPROpenUrlFilterRegExList</key>
    <array>
        <string>https://example\.com/page/</string>
        <string>your-domain\.com/.+\?universal=true</string>
    </array>
    ...
</dict>
*/
// MyApplication.java

import io.repro.android.Repro;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Repro.addOpenUrlFilterRegEx("https://example\\.com/page/");
        Repro.addOpenUrlFilterRegEx("your-domain\\.com/.+\\?universal=true");
        ...
    }
...
}


// AndroidManifest.xml
// To specify multiple URL patterns, enter them separated by commas.
<application>
    ...
    <meta-data
        android:name="io.repro.android.OpenUrlFilterRegExList"
        android:value="https://example\\.com/page/;your-domain\\.com/.+\\?universal=true">
    </meta-data>
</application>
// AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
    Repro.add(openUrlFilterRegEx: "https://example\\.com/page/")
    Repro.add(openUrlFilterRegEx: "your-domain\\.com/.+\\?universal=true")
    ...
}

// .plist file
/*
<dict>
    <key>RPROpenUrlFilterRegExList</key>
    <array>
        <string>https://example\.com/page/</string>
        <string>your-domain\.com/.+\?universal=true</string>
    </array>
    ...
</dict>
*/
Please follow native iOS and Android instructions in order to add the filters
to the plist/AndroidManifest files or the main AppDelegate/Application classes.
Please follow native iOS and Android instructions in order to add the filters
to the plist/AndroidManifest files or the main AppDelegate/Application classes.
// YourAppNameScene.cpp

bool YourAppName::init() {
    ReproCpp::addOpenUrlFilterRegEx("https://example\\.com/page/");
    ReproCpp::addOpenUrlFilterRegEx("your-domain\\.com/.+\\?universal=true");
    ...
}
Please follow native iOS and Android instructions in order to add the filters
to the plist/AndroidManifest files or the main AppDelegate/Application classes.
Please follow native iOS and Android instructions in order to add the filters
to the plist/AndroidManifest files or the main AppDelegate/Application classes.

警告

ユニバーサルリンクとして設定するURLパターンは、可能な限り ドメインとパスまで含めて具体的に指定 し、 全て小文字で指定 してください。

もし、 https のようにスキームのみを指定した場合、アプリ内メッセージで表示された画面内で実行されたスクリプトなどによるリクエストもユニバーサルリンクと誤って判定され、意図しないタイミングでコールバック処理が実行される可能性があります。

また、URLパターンのスキーム/ドメイン部分に大文字を使用した場合、HTMLアプリ内メッセージで表示したボタンからユニバーサルリンクを使って遷移させようとするときに、スキーム/ドメイン部分が自動的に小文字に変換されて処理されます。パターン(正規表現)に一致せず、意図したタイミングでコールバック処理が実行されない可能性があります。

ユニバーサルリンク実行時の処理を登録する¶

次に、ユニバーサルリンクが実行された際に動作するコールバック処理を実装します。 処理内には、例えばURLのパターンに応じて画面遷移を行う動作などを記述します。

#import <Repro/Repro.h>

...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [Repro setOpenUrlCallback:^(NSURL *url) {
        if ([url.host isEqualToString:@"example.com"]) {
            // In case of your universal link perform navigation, present content, ...
            handleUniversalLink(url);
        }
    }];

    ...
    [Repro setup:@"YOUR_APP_TOKEN"];
    ...
}
// Set a callback that is executed everytime an URL is about to be opened
Repro.setOpenUrlCallback { url in
    if url.host == "example.com" {
        // In case of your universal link perform navigation, present content, ...
        handleUniversalLink(url)
    }
}
...
Repro.setup(token: "YOUR_APP_TOKEN")
...
import io.repro.android.Repro;

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        // In order to execute a callback when a push notification is tapped,
        // the callback must be set in Application, not Activity.
        Repro.setOpenUrlCallback(new Repro.OpenUrlCallback() {
            // ** This callback method is executed in the main thread **
            @Override
            public void onOpened(Uri uri) {
                if ("example.com".equals(uri.getHost())) {
                    // In case of your universal link perform navigation, present content, ...
                }
            }
        });

        ...
        Repro.setup(this, YOUR_APP_TOKEN);
        ...
    }
    ...
}
Repro.setOpenUrlCallback((uri) { // uri is of type Uri
   debugPrint("Universal Link Callback Handler received: " + uri.toString());
});
// Somewhere before Repro.Setup(...)
Repro.SetOpenUrlCallback(uri => // uri is of type Uri
{
    Debug.Log("Universal Link Callback Handler received: " + uri.ToString());
});
bool YourAppName::init() {
    ReproCpp::addOpenUrlFilterRegEx(...);

    ReproCpp::setOpenUrlCallback([](const char *url) {
        if (strcmp(url, "example.com") == 0) {
            // In case of your universal link perform navigation, present content, ...
        }
    });

    ReproCpp::setup("YOUR_APP_TOKEN")
    ...
}
Repro.setOpenUrlCallback(function(url) { // url is of type String
    alert('Universal Link Callback Handler received: ' + url);
    if (url.includes("http://example.org")) {
        // In case of your universal link perform navigation, present content, ...
    }
});
Repro.setOpenUrlCallback( (url) => {  // url is of type String
    console.log('Universal Link Callback Handler received: ' + url);
    if (url.includes("http://example.org")) {
        // In case of your universal link perform navigation, present content, ...
    }
});
  • « プッシュ通知 (Expo)
  • ニュースフィード »

About Us Careers Terms of Service Privacy Policy Cookie Policy

© 2022 Repro Inc.