導入: Cordova¶
Cordova Plugin のインストール¶
最新版のcordova pluginをインストールする場合、Cordova CLI (もしくはPhoneGap CLI) 6.5以上及びCordova Android 6.4以上が必要です。バージョンをご確認の上、以下のコマンドを実行してください。
# cordova
$ cordova plugin add cordova-plugin-repro
# phonegap
$ phonegap plugin add cordova-plugin-repro
FCMを設定する¶
FCMの設定 (Android) を参照し、設定してください。
config.xml
ファイルを編集する¶
プロジェクト直下のconfig.xmlを開き、 widget
タグに xmlns:android="http://schemas.android.com/apk/res/android"
を追加してください。また、config.xmlの中に <platform name="android">
タグが存在しない場合、 widget
タグの下に追加してください。
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="..." version="1.0.0">
...
<platform name="android">
...
</platform>
google-services.json
ファイルを追加する¶
FCMの設定 (Android) でダウンロードした google-services.json
をプロジェクトのディレクトリにコピーし、
下記のXMLをconfig.xmlの <platform name="android">
タグの中に追加してください。
cordova-android 7.0未満¶
<resource-file src="google-services.json" target="google-services.json" />
cordova-android 7.0以上¶
<resource-file src="google-services.json" target="app/google-services.json" />
オプション:Firebaseの依存バージョンを変更する¶
firebase-core
及び firebase-messaging
の依存バージョンを変更する場合は、引数でバージョン指定した上でインストールしてください。例えば、 firebase-core
のバージョン16.0.0、 firebase-messaging
のバージョン17.1.0を指定する場合は、下記のコマンドを実行してください。
# cordova
$ cordova plugin add cordova-plugin-repro \
--variable FIREBASE_CORE_VERSION=16.0.0 \
--variable FIREBASE_MESSAGING_VERSION=17.1.0
注釈
FIREBASE_MESSAGING_VERSION
は17.1.0以上を指定してください。- Cordova 7.1未満をご利用する場合、
platforms/android/project.properties
を開き、以下のように修正してください。platforms/android/project.properties
に対する修正はCordova CLIの操作により戻される場合があるため、 ビルドする際は常にその内容をもう一度ご確認ください。com.google.firebase:firebase-core:$FIREBASE_CORE_VERSION
となっている箇所をcom.google.firebase:firebase-core:16.0.4
に修正com.google.firebase:firebase-messaging:$FIREBASE_MESSAGING_VERSION
となっている箇所をcom.google.firebase:firebase-messaging:17.3.4
に修正
セットアップ¶
index.js
の onDeviceReady
で セッション を開始してください。
YOUR_APP_TOKEN
には管理画面の 設定 > プロジェクト設定 に記載されている SDK トークン を設定してください。
onDeviceReady: function() {
app.receivedEvent('deviceready');
...
// Setup Repro
Repro.setup("YOUR_APP_TOKEN");
...
},
ある程度操作した後、 「ホームボタン」を押下 します。SDKが収集した情報は アプリがバックグラウンドに移行 した時点でサーバーにアップロードされます。
イベントをトラックする¶
意味のある分析や、マーケティング施策を実施するためには、適切なユーザーグループを絞り込むことが重要です。イベントをトラックしてユーザーの行動を記録することにより、管理画面上で目的に応じた適切なユーザーグループを選択することができるようになります。
イベントを用いたユーザーグループ指定の例:
どういうイベントをとるべきかわからない場合は、まず各画面の表示時にイベントをとってみることをおすすめします。
例:
@implementation MainViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[Repro track:@"MainViewController" properties:nil];
...
}
class MainViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Repro.track("MainViewController", properties: nil)
...
}
class MainViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Repro.track(event: "MainViewController", properties: [:])
...
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
Repro.track("MainActivity");
...
}
}
#include "ReproCpp.h"
...
ReproCpp::track("Initialized");
Repro.Track ("Initialized");
// Will be written later
class MainScreen extends React.Component {
componentDidMount() {
Repro.track("MainScreen", {});
}
...
}
import 'package:repro_flutter/repro.dart';
...
await Repro.track("Initialized");
Repro の分析チームによるイベントの設定支援サービスも提供しておりますので、ご希望の方は、ぜひ お問い合わせ からお問い合わせください。
ユーザーIDをセットする¶
Repro では分析結果はユーザー単位で集計しています。ユーザーIDをセットすることにより、下記のメリットがあります:
- 複数のデバイスを使っているユーザーを同一視できる
- キャンペーン機能の テスター管理 において、アプリで管理しているユーザーを識別できる
- キャンペーンの配信対象の抽出がより精緻になる
詳しくは こちら をご覧ください。
Next...¶
その他の機能についての詳細は、以下をご覧ください。