How to opt out from Facebook SDK event logging? - android

I'm using Facebook App Events tracking for Android, but I have no idea how to disable tracking when a user wants to opt out! Does anyone know how to do that?
The documentation says:
We recommend that you use our SDK tools to offer the opt-out.
But they don't actually describe it anywhere. Classic Facebook move.
EDIT:
Now with the GDPR being in effect for so long, they still don't have any way to disable all tracking until the user consents, do they?

After the documentation was updated it seems the new way to go is a combination of disabling
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
android:value="false"/>
<meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled"
android:value="false"/>
<meta-data android:name="com.facebook.sdk.AutoInitEnabled"
android:value="false"/> <!--OPTIONAL-->
And at runtime to opt in call:
FacebookSdk.setAutoLogAppEventsEnabled(true)
FacebookSdk.setAdvertiserIDCollectionEnabled(true)
// OPTIONALLY the following line if AutoInitEnabled is set to false in manifest:
FacebookSdk.setAutoInitEnabled(true) // automatically calls FacebookSdk.fullyInitialize() under the hood
Right now I don't see when it would be good to disable (and later enable) auto init, maybe someone else might have an idea here.

Don't know about per User, but you can opt put from Facebook SDK event logging:
Add this int your Android.Manifest.xml:
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
android:value="false"/>

The opt-out they are talking about is described in the heading below: https://developers.facebook.com/docs/app-events/android#setlimiteventusage
You can call AppEventsLogger.setLimitEventUsage(this, true); to "opt-out" (at least limit) how the events logged are used.

Related

Prevent network requests from Facebook Android SDK

The Android Facebook SDK is always making a network request to graph.facebook.com when calling FacebookSdk.sdkInitialize(context) even if nothing of the SDK has been used yet.
So if we're initializing it in the Application.onCreate() there will always be at least one network request. Even if the setting is as follows:
<meta-data
android:name="com.facebook.sdk.AutoLogAppEventsEnabled"
android:value="false" />
We've took a closer look at this because a user complained that he is not using the Facebook Login (which is why we have the Facebook SDK in the first place) and still there is "user data" transferred to Facebook. In times of GDPR and suspicious users, this is a very unfavourable behaviour!
What we're doing now is calling FacebookSdk.sdkInitialize(context) only when the user wants to use the Facebook Login (at the time when the user clicks on the button). Additionally, we removed the meta-data for android:name="com.facebook.sdk.ApplicationId" from the AndroidManifest. This prevents the initial network request but then there is the following crash appearing in the CurrentAccessTokenExpirationBroadcastReceiver:
java.lang.RuntimeException: Unable to start receiver com.facebook.CurrentAccessTokenExpirationBroadcastReceiver: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
at com.facebook.internal.Validate.sdkInitialized(Validate.java:143)
at com.facebook.FacebookSdk.getApplicationContext(FacebookSdk.java:518)
at com.facebook.AccessTokenManager.getInstance(AccessTokenManager.java:86)
at com.facebook.CurrentAccessTokenExpirationBroadcastReceiver.onReceive(CurrentAccessTokenExpirationBroadcastReceiver.java:34)
Now there are several questions:
Why is Facebook still making a request at start? If they want to validate the auth token, they can do it as soon as the SDK is really used...
Does Facebook know and tolerate crashes when sdkInitialize() is not called? Because I fear when this NullPointerException is removed there will be other crashes...
Most important: Are there any other ways to prevent network requests from the Facebook SDK when its features are not used?
I have noticed that the Facebook SDK (at least in version 4.33) adds a provider (com.facebook.internal.FacebookInitProvider) in the manifest of your app, which automatically calls FacebookSdk.sdkInitialize with the application context.
Even if you have added:
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false" />
in your manifest, at least 2 requests will be made to Facebook:
a graph request to get app settings
an Events request "fb_sdk_initialize" which logs all the Facebook frameworks that are included into your app
So to prevent these requests (that we don't want as long as the user didn't allow them (GDPR)), I think you did everything we need to do:
Do not add <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/> in the manifest
Add <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/> in the manifest
Only initialize Facebook SDK when you need it.
Like this for example:
FacebookSdk.setApplicationId(<context>.getString(R.string.facebook_app_id));
FacebookSdk.sdkInitialize(<context>);
AppEventsLogger logger = AppEventsLogger.newLogger(<context>); // I don't use FB Login for my project but app events.
But regarding your crash, I don't know why it happens since it seems that the broadcast "com.facebook.sdk.ACTION_CURRENT_ACCESS_TOKEN_CHANGED" is sent locally.
Nevertheless, I think you can prevent it by adding this to your manifest:
<provider
android:name="com.facebook.internal.FacebookInitProvider"
tools:node="remove" />
<receiver
android:name="com.facebook.CurrentAccessTokenExpirationBroadcastReceiver"
tools:node="remove" />
However, doing this may have bad consequences with the use of Facebook SDK and I think you will have to provide (and register in your manifest) your own BroadcastReceiver:
public class CustomCurrentAccessTokenExpirationBroadcastReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (AccessTokenManager.ACTION_CURRENT_ACCESS_TOKEN_CHANGED.equals(intent.getAction())) {
new CurrentAccessTokenExpirationBroadcastReceiver().onReceive(context, intent); // Call it only if you have initialized the Facebook SDK!
}
}
}
According to Facebook Support,
If you would like to temporarily disable automatic events collection, such as to get end-user consent before collecting data, you can set the value of AutoLogAppEventsEnabled to false in the app's AndroidManifest.xml in the application tag.
For example:
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
To re-enable collection, such as after an end-user provides consent, call the setAutoLogAppEventsEnabled() method of the FacebookSDK class.
For example: setAutoLogAppEventsEnabled(true);
If you need to suspend collection again for any reason, you can call setAutoLogAppEventsEnabled(false); and collection will be suspended until re-enabling it.

Disable Firebase crash reporting

I have decided to include the Firebase Crash API 9.0.1 into my Android app.
At the moment everything is working fine. Now I want to give my users the opportunity to disable, that Firebase is sending the Crash reports automatically.
Firebase Analytics can be disabled with this code snippet
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false);
Does anyone of you know a similar way to disable crash reporting?
Many thanks
Sorry for short answer but currently there is no official support for this.
EDIT: 30/10/2017
Now it is possible to enable/disable at build time adding in the AndroidManifest.xml:
<meta-data android:name="firebase_crash_collection_enabled" android:value="false" />
or runtime using:
FirebaseCrash.enableCrash(true|false);
More info here.
Yes it is possible now. Check this,
Disable Crash Reporting
Simply add the below line to your code in the first activity or even better in the Application class.
FirebaseCrash.setCrashCollectionEnabled(false);
To enable,
FirebaseCrash.setCrashCollectionEnabled(true);
This is really helpful when we have multiple build types such as Debug, Release etc.
You can find the instructions on the page:
https://firebase.google.com/support/guides/disable-analytics
Disable Analytics collection on Android
Temporarily disable collection
If you wish to temporarily disable Analytics collection, such as to get end-user consent before collecting data, you can set the value of firebase_analytics_collection_enabled to false in your app's AndroidManifest.xml in the application tag. For example:
<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
To re-enable collection, such as after an end-user provides consent, call the setAnalyticsCollectionEnabled() method of the FirebaseAnalytics class. For example:
setAnalyticsCollectionEnabled(true);
If you need to suspend collection again for any reason, you can call
setAnalyticsCollectionEnabled(false);
and collection is suspended until you re-enable it.
Permanently deactivate collection
If you need to deactivate Analytics collection permanently in a version of your app, set firebase_analytics_collection_deactivated to true in your app's AndroidManifest.xml in the application tag. For example:
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />

AndroidTV TvInputService Implementation

I am having problems with implementing TvInputService.
I have all information from the server concerning channels(end/start times, Uri addresses, id, name, etc..)
My objective is to create an app to setup streaming channels from this information gotten from the server.
I tried this http://developer.android.com/training/tv/tif/tvinput.html ... even thou I understand the theory (mostly), I am still new to this and because the website does not provide coding examples and thorough explanation of it, it is really frustrating.
I also tried the Sample provided by android, but that is too complex for what I am trying to do, and it just confuses me even more.
Can someone help me out by explaining(simple way, if possible) with some examples all about TvInputService implementation? Thank you!
You may want to use my library, ChannelSurfer, which greatly simplifies the development of TV input services.
There are a few main steps that you need to do to create an input service.
Declare what channels are accessible.
Declare what programs will be played on each channel
When a user tunes to your channel, how will the video be displayed
This is done normally through SyncAdapters and services, although this library boils everything down to a single class that you create based on your own specifications.
There's an example app as well if you need more help.
Based from this documentation, those implementing TV input services should normally do so by deriving from this class and providing their own session implementation based on TvInputService.Session.
Your app manifest must declare your TvInputService then specify the BIND_TV_INPUT permission to allow the service to connect the TV input to the system.
<service android:name="com.example.sampletvinput.SampleTvInput"
android:label="#string/sample_tv_input_label"
android:permission="android.permission.BIND_TV_INPUT">
<intent-filter>
<action android:name="android.media.tv.TvInputService" />
</intent-filter>
<meta-data android:name="android.media.tv.input"
android:resource="#xml/sample_tv_input" />
</service>
You can check this example on GitHub.
I am getting "Unable to start auto-scan for 'Authorization' " after I try to install the channels. I am using files from ChannelSurfer, managed to make the provider and HOPEFULY the setup(still confused about it), but I'm stuck on this part... The console does not throw a single error but the TV says the above statement. Why does this happen and what are the possible fixes?

Fiksu SDK Integration

I am trying to implement Fiksu SDK for Android and iOS.
I am able to add code to track registration and purchase :
FiksuTrackingManager.uploadRegistration(Context, FiksuTrackingManager.RegistrationEvent.EVENT1);
FiksuTrackingManager.uploadPurchase(Context, FiksuTrackingManager.PurchaseEvent.EVENT1, 0, "USD");
In iOS i am able to get the logs in the console, but in android i am only getting logs which event is called.How can i check the logs in Android ?
Also how to track the app events in Fiksu dashboard ?
They have also mentioned to add client id , from where will i get the client id ?
if any one has implemented it please guide me how to proceed ?
this might be too late but it may help someone that comes across this post.
I just had to integrate the Fiksu SDK for android for a client and face similar issues when testing.
How can i check the logs in Android ?
If the SDK has been properly installed you should be able to see some logs like below which means the events have been succesfully sent to their server.
11-25 10:04:31.010 21588-23132/ D/FiksuTracking? Event: Resume
11-25 10:04:32.320 21588-23132/ D/FiksuTracking? Successfully uploaded tracking information.
11-25 10:05:40.500 21588-23383/ D/FiksuTracking? Event: Purchase
11-25 10:05:42.180 21588-23383/ D/FiksuTracking? Successfully uploaded tracking information.
how to track the app events in Fiksu dashboard ?
This part is quite annoying as they don't have a way to create Apps in the dashboard and link them to your android app so you can see your events coming through. Instead you have to actually perform the test and send them an email for someone from Fiksu to check their servers and track your events.
These are the test steps as per their documentation:
Download and install your application on an Android device and perform your tests.
Fill a form they have and send it via email to their support team.
Someone will get back to you confirming if they have received your events.
They have also mentioned to add client id , from where will i get the client id ?
The clientId is just an identifier for your users within your app. In other words you can set that to whatever you want (e.i. email address). The suggestion is to set this after a user has registered or logged in in your app.
FiksuTrackingManager.setClientId(Context, "XXX");
Based on their documentation: "Where XXX would be the ID you want to send and can be any alphanumeric string up to 64 characters long. All events sent after this call is made would send the Client ID that has been set. If you call setClientID again it will overwrite whatever was there before. However the first Client ID sent with an event will be the Client ID that is in the export on the Fiksu Client Dashboard and it will not get updated."
if any one has implemented it please guide me how to proceed ?
So to sum up below are the steps to integrate the Fiksu SDK for android.
Downlaod the SDK.
Add the SDK jar to your project.
Set the isntall receiver (Only if you want to track app installs). NOTE that they expect to be the only receiver in the AndroidManifest.xml file. If you are using other third party SDKs to track the same you either:
Use fiksu to forward the intent:
<receiver android:name="com.fiksu.asotracking.InstallTracking"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
<!-- Forward to other receivers -->
<meta-data android:name="forward.1"
android:value="com.google.android.apps.analytics.AnalyticsReceiver" />
<meta-data android:name="forward.2" android:value="com.mypackage.thirdparty.MdotmReceiver" />
</receiver>
Or set the below flag in your AndroidManifest and have another install receiver forward it to the fiksu SDK.
<meta-data android:name="FiksuDisableReceiverCheck" android:value="true" />
Set the permissions in your AndroidManifest.
android.permission.INTERNET
android.permission.READ_PHONE_STATE
Initialize the SDK. Normally on your Application onCreate() method.
FiksuTrackingManager.initialize(this);
Setting up Google Play Services on your project.

Facebook on Android — Debug popup Hashkey keep appear

I'm trying to add the Facebook API in my application. I build it in ActionScript3-AIR to proceed an export on iOS/Android and use the GoViral API to apply the connection with Facebook.
After the creation of the application on Facebook Developer, it works on iOS, but not on Android.
When this line is read GoViral.goViral.initFacebook( XXXXXXX ), on Android, the application show a popup which display the Key Hashes Here, the screenshot:
Then, nothing happen. The connexion don't seem to be done and, if I try an authentication with GoViral.goViral.authenticateWithFacebook( "user_likes,user_photos,publish_actions" ) it does nothing. And by that, I really mean nothing in the way that it don't even return the GVFacebookEvent.FB_LOGIN_FAILED event.
I used the "Mail It" button on this popup. Took the hash key and pasted it in the Android section of my application in the Facebook Developer Here, the screenshot:
But, nothing changes and the popup always appears.
After that and by the results of some google research, I've try to make my own Hash Key, helped by some tutorials. The Key has been generated but didn't correct anything about the popup.
So, actually, I'm a little confuse about this issue.
Especially as I've try to put another fake App ID in the initFacebook method : the popup continues to appear. So I wonder if it can really see it.
For information, I created the application project on the Google Developers Console.
The manifest I use to apply the Facebook API is this one :
<uses-sdk android:targetSdkVersion="12"/>
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application>
<activity android:name="com.facebook.LoginActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="Login"/>
</application>
Thanks a lot to help me to fix this issue.
------ EDIT ------
I found the problem about the Debug Pop-up with the Hash Key. It was relative to the GoViral API which ( I didn't know this ) has two version : One normal and one for the debug which always makes appear the hash key in a pop-up at connection.
The Facebook connection still not working, but it's sound to be another problem so I can say this problem is solved.
I've found the solution which is way simple than I imagined. In the sources of GoViral, there was two ANE, I used the one which was makes for debug. It makes appear the popup to give us the hashkey. After what, we have to put the other ane to make it work.

Categories

Resources