How to toggle Facebook SDK consent?

243 Views Asked by At

To adhere to GDPR, the user needs to be able to turn off and on Facebook logging.

I've turned it off by default in AndroidManifest.xml following their documentation, and turn it on after consent is given:

ConsentManager.addListener { consented ->
   FacebookSdk.setAutoInitEnabled(consented)
   FacebookSdk.setAutoLogAppEventsEnabled(consented)
   FacebookSdk.setAdvertiserIDCollectionEnabled(consented)
   FacebookSdk.setLimitEventAndDataUsage(this, consented)
   FacebookSdk.fullyInitialize()
}

The user is able to reject consent again, without restarting the app. So to turn Facebook SDK off again, is it correct to just call the same SDK functions again but with false instead?

I'm a bit doubtful because:

  1. FacebookSDK is already initialised, so does calling setAutoInitEnabled() make sense?
  2. Do I have to call fullyInitialize() again every time?
  3. After turning it off and on again without restarting the app, I only get 400s and 403s while sniffing network calls via Charles
0

There are 0 best solutions below