'How to set FacebookAutoLogAppEventsEnabled to TRUE in a cordova-ios project using cordova-plugin-facebook4?
This is my last resort.
I have a cordova 8 project and I need to integrate Facebook App Event to both Android and Ios. Currently I am using https://www.npmjs.com/package/cordova-plugin-facebook4 (Im actually using version 5 instead of 6 as its compatible with cordova 8) to add Facebook Analytics. I went to build and compiled my cordova project (cordova-ios5) in xCode, everything runs fine and no error except for warnings as below in xCode console log:
: Please set a value for FacebookAutoLogAppEventsEnabled. Set the flag to TRUE if you want to collect app install, app launch and in-app purchase events automatically. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#disable-auto-events.
: You haven't set a value for FacebookAdvertiserIDCollectionEnabled. Set the flag to TRUE if you want to collect Advertiser ID for better advertising and analytics results. To request user consent before collecting data, set the flag value to FALSE, then change to TRUE once user consent is received. Learn more: https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#disable-auto-events.
What I like to know is how do you set this settings in cordova , particulary can it be set in the project config.xml file?
Reading the plugin doc, that this should be already defaulted to TRUE but it doesnt look like its being set at all.
With this warning , this might be the reason why iOS users is not showing up in Facebook analytics.
I am a front-end developer who has no clue how cordova is setting this in the background and making a call to native functions.I already spent countless hours searching for this on web, with no luck. Hopefully anyone can shed a light. Thank you.
Solution 1:[1]
You can set FacebookAutoLogAppEventsEnabled to false in the config.xml file, add it under the platform tag. This will add the value to the plist-file in XCode.
<platform name="ios">
<config-file parent="FacebookAutoLogAppEventsEnabled" target="*-Info.plist">
<false />
</config-file>
</platform>
Solution 2:[2]
<config-file parent="FacebookAutoLogAppEventsEnabled" target="*-Info.plist">
<false />
</config-file>
<config-file parent="FacebookAdvertiserIDCollectionEnabled" target="*-Info.plist">
<false />
</config-file>
<custom-config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="false" />
<meta-data android:name="firebase_crash_collection_enabled" android:value="false" />
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false" />
</custom-config-file>
Solution 3:[3]
The cordova-plugin-facebook-4 plugin is deprecated. Check out cordova-plugin-facebook-connect at https://www.npmjs.com/package/cordova-plugin-facebook-connect. That plugin now supports setting FacebookAutoLogAppEventsEnabled with a new preference, and exposes a new setAutoLogAppEventsEnabled method.
(Disclosure: I am the maintainer of that plugin.)
Solution 4:[4]
[[FBSDKSettings sharedSettings]setAdvertiserTrackingEnabled:NO];
or
[[FBSDKSettings sharedSettings]setAdvertiserTrackingEnabled:YES];
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steven Delrue |
| Solution 2 | Mattias |
| Solution 3 | Noah Cooper |
| Solution 4 | Ofir Malachi |
