Posts tagged with firebase-authentication

I have the following code executing when a user logs in to facebook:

FB.Event.subscribe('auth.authResponseChange', checkLoginState); 

Here is the code to analayse:

    function checkLoginState(response) {         if (response.authResponse) {             // User is signed-in Facebook.             const unsubscribe = onAuthStateChanged(auth, (firebaseUser) => {                 unsubscribe();                 // Check if we are already signed-in Firebase with the correct user.                 if (!isUserEqual(response.authResponse, firebaseUser)) {                     // Build Firebase credential with the Facebook auth token.                     const credential = FacebookAuthProvider.credential(                         response.authResponse.accessToken);                     // Sign in with the credential from the Facebook user.                     let x = signInWithCredential(auth, credential)                         .catch((error) => {                             // Handle Errors here.                             const errorCode = error.code;                             const errorMessage = error.message;                             // The email of the user's account used.                             const email = error.customData.email;                             // The AuthCredential type that was used.                             const credential = FacebookAuthProvider.credentialFromError(error);                             alert("Login failed. Please try again.");                         });                     x.then((userCredential) => {                         // Signed in                         const user = userCredential.user;                         // login(response.authResponse.accessToken, firebasetoken???);                     });                 } else {                     // User is already signed-in Firebase with the correct user.                     console.log(response);                     // login(response.authResponse.accessToken, firebasetoken???);                 }             });         } else {             // User is signed-out of Facebook.             signOut(auth);         }     } 

I'm unsure how to pass the FIREBASE login token to verify in the backend (with kreait):

        $auth = (new Factory)             ->withServiceAccount($_ENV["PATH"].$_ENV['config']['storage']['firebase']['firebase']['file'] ?? 'firebase-service-account.json')             ->createAuth();         // verify token         $verifiedIdToken = $auth->verifyIdToken($token);         $uid = $verifiedIdToken->getClaim('sub'); // throws an InvalidToken when invalid 

Kreait docs: https://github.com/kreait/firebase-php

Any help is appreciated.

We are using Google Ads as a source for new users of our app. We have it linked to Firebase and can see the install (first_open) events in Google Ad words.

We would like to record the Google Ad campaign information against our authenticated Firebase users in our back-end database so we can better track value of campaigns over time.

Is there some way to hook into the Firebase SDK in the Flutter app to listen for/retrieve this information as it is sent to Google Ads when the app is first installed? Or is there another way we can use for source attribution tracking across both iOS and Android installs?

Thanks!