튜토리얼: iOS 광고 전환 측정

1단계: 로그인 환경 구현



첫 번째 단계는 사용자가 이메일 주소나 전화번호를 제공할 수 있는 로그인 환경을 구현하는 것입니다.

사용 중인 인증 시스템은 사용자와 연결된 이메일 주소 또는 전화번호를 제공해야 합니다. 다음 단계에서는 Firebase Authentication를 사용하여 로그인 정보를 안전하게 수집하는 프로세스를 간략히 설명합니다. 하지만 사용자 이메일 또는 전화번호를 수집하는 인증 시스템이 이미 있는 경우 이 단계를 건너뛰고 2단계: Google 애널리틱스 통합으로 진행할 수 있습니다.

  • iOS 12 이상에서 실행할 수 있는 자체 앱

  • Google 애널리틱스 및 Google Ads에 연결된 Firebase 앱으로 등록된 앱

  • 선호 IDE

인증 시스템 설정

Firebase Authentication 로그인 방법 사용

Firebase Authentication을 사용하면 사용자가 이메일 주소, 전화번호, 비밀번호 로그인, 제휴 ID 공급업체 (예: Google, Facebook, 트위터)를 비롯한 1개 이상의 로그인 방법을 사용하여 앱에 로그인할 수 있습니다. Firebase Authentication 시작하기를 검토하세요.

Firebase Authentication를 맞춤 인증 시스템과 통합

또는 사용자가 정상적으로 로그인할 때 커스텀 서명 토큰을 발행하도록 인증 서버를 수정하여 Firebase Authentication를 커스텀 인증 시스템과 통합할 수 있습니다. 앱에서 이 토큰을 받아 Firebase 인증에 사용합니다. 맞춤 인증 시스템 시작하기를 검토하세요.

인증된 사용자의 이메일 주소 또는 전화번호 가져오기

Firebase Authentication로 인증 시스템을 설정한 후에는 현재 로그인한 사용자를 가져올 수 있습니다.

현재 사용자를 가져올 때 권장하는 방법은 다음과 같이 Auth 객체에 리스너를 설정하는 것입니다.

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
  // ...
}
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;
    // ...
  }];
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 통합