Search code examples
androidfacebookreact-nativefbsdkreact-native-fbsdk

How to integrate App Events for Android on React Native?


I have read the documentation on FBSDK, and for event integration Full code


import { AppEventsLogger } from "react-native-fbsdk";

// Log a $15 purchase.
AppEventsLogger.logPurchase(15, "USD", { param: "value" });

which part it is placed, where it is placed on onPress or how

// Log a $ 15 purchase.
AppEventsLogger.logPurchase (15, "USD", {param: "value"});

Maybe it can provide examples or url links for this solution


Solution

  • i've implemented the exact same thing in my app which gives courses. So on particular pages componentDidMount ive placed the AppEventsLogger event to know which pages are more frequently visted. Also you can add it in any onPress functions to know where user clicks or visits more.

    componentDidMount(){
    
    AppEventsLogger.logEvent('View content', {
        screen: args,
        activity: activity,
        user_email: user_email
      });
    }
    

    And for your case if you are logging a purchase , you can do it after a succesffull transaction , like after the api call,

    let result = await purchaseStatus();
    if(result.success){
    
    AppEventsLogger.logPurchase (15, "USD", {param: "value"});
    }
    

    You can try these.