skip to Main Content

I was trying to enable Advertiser Tracking using capacitor-community
facebook-login plugin.i found a method for enabling ( i guess ) in documentation of facebook-login plugin but there is no documentation for how to use it and demo project given also not mentioning about apis present in given plugin.

method defined in documentation:

setAdvertiserTrackingEnabled(...)

but when I try to use it I am getting the error

property ‘setAdvertiserTrackingEnabled’ does not exist on type ‘FacebookLoginPlugin’.ts(2339)

my code so far

async enableAdvertiserTracking(){
    await FacebookLogin.setAdvertiserTrackingEnabled({ enabled: true; })
}

2

Answers


  1. you can use cordova facebook-connect plugin although it bit old.it has a method to enable advertiser tracking.
    https://www.npmjs.com/package/cordova-plugin-facebook-connect#facebook-sdk

    Login or Signup to reply.
  2. The method is available in latest version ( starting from 5.0.0 ) of @capacitor-community/facebook-login.

    may be you are using older version of the same plugin.you should call this method after requesting tracking permission from user in ios.

    for that purpose you can use capacitor-plugin-app-tracking-transparency.as mentioned below

    let response = await AppTrackingTransparency.getStatus();
    if (response.status === 'notDetermined') {
      // Ask user consent to track
      response = await AppTrackingTransparency.requestPermission();
    }
    
    // set based on user consent
    
    if(response.status === 'authorized'){
      await FacebookLogin.setAdvertiserTrackingEnabled({ enabled: true; })
    } else {
      await FacebookLogin.setAdvertiserTrackingEnabled({ enabled: false; })
    }
    

    if you are using capacitor version below 5 you won’t be able to use setAdvertiserTrackingEnabled from @cacpacitor-community/facebook-login.

    if your are on capacitor 4 or less you can use @captive/capacitor-facebook-analytics version 1.0.0 to acheive same.in that case you have to change last few lines as below

    if(response.status === 'authorized'){
      FacebookAnalytics.enableAdvertiserTracking()
    } else {
      FacebookAnalytics.disableAdvertiserTracking()
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search