ステップ 1: ログイン エクスペリエンスを実装する
概要: iOS 広告コンバージョンを測定する |
ステップ 1: ログイン エクスペリエンスを実装する |
ステップ 2: Google Analytics を統合する |
ステップ 3: Google Analytics を使用してオンデバイス コンバージョン測定を開始する |
ステップ 4: 一般的な問題のトラブルシューティングと対処 |
最初のステップは、ユーザーがメールアドレスまたは電話番号を提供できるようにログイン プロセスを実装することです。
使用する認証システムは、ユーザーに関連付けられたメールアドレスまたは電話番号を提供する必要があります。次の手順では、Firebase Authentication を使用してログイン情報を安全に収集するプロセスの概要を説明します。ユーザーのメールアドレスや電話番号を収集する認証システムがすでにある場合は、この手順をスキップして ステップ 2: Google アナリティクスを統合するに進んでください。
認証システムを設定する
Firebase Authentication ログイン方法を使用する
Firebase Authentication を使用すると、ユーザーがアプリにログインする際に、メールアドレス、電話番号、パスワードによるログイン、フェデレーション ID プロバイダ(Google、Facebook、Twitter など)などの 1 つ以上の方法を使用できるようになります。Firebase Authentication を使ってみるをご確認ください。
Firebase Authentication をカスタム認証システムと統合する
または、ユーザーがログインに成功したときに署名済みのカスタム トークンが生成されるように認証サーバーを変更することで、Firebase Authentication をカスタム認証システムと統合できます。アプリはこのトークンを受信して、Firebase での認証に使用します。カスタム認証システムの使用を開始するをご覧ください。
認証されたユーザーのメールアドレスまたは電話番号を取得する
Firebase Authentication で認証システムを設定したら、現在ログインしているユーザーを取得できます。
現在ログインしているユーザーを取得するには、Auth
オブジェクトでリスナーを設定することをおすすめします。
Swift
handle = Auth.auth().addStateDidChangeListener { auth, user in // Get the user's email address let email = user.email // or get their phone number let phoneNumber = user.phoneNumber // ... }
Objective-C
self.handle = [[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth *_Nonnull auth, FIRUser *_Nullable user) { // Get the user's email address NSString *email = user.email; // or get their phone number NSString *phoneNumber = user.phoneNumber; // ... }];
Unity
Firebase.Auth.FirebaseAuth auth; Firebase.Auth.FirebaseUser user; // Handle initialization of the necessary firebase modules: void InitializeFirebase() { auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.StateChanged += AuthStateChanged; AuthStateChanged(this, null); } // Track state changes of the auth object. void AuthStateChanged(object sender, System.EventArgs eventArgs) { if (auth.CurrentUser != user) { bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null; user = auth.CurrentUser; if (signedIn) { // Get the user's email address string email = user.Email; // or get their phone number string phoneNumber = user.PhoneNumber; // ... } } } // Handle removing subscription and reference to the Auth instance. // Automatically called by a Monobehaviour after Destroy is called on it. void OnDestroy() { auth.StateChanged -= AuthStateChanged; auth = null; }
概要ステップ 2: Google Analytics を統合する