Initial SDK setup

Install using gradle

If you use gradle as your build system, you can fetch the library from our private nexus repository.

Add the FollowAnalytics repository to your build.gradle repositories.

repositories {
    ...
    maven {
        url 'http://nexus.follow-apps.com/nexus/content/repositories/releases/'
    }
}

Add the FollowAnalytics SDK to your module's build.gradle dependencies.

dependencies {
    ...
    compile 'com.google.android.gms:play-services-gcm:9.6.0'
    compile 'com.google.android.gms:play-services-location:9.6.0'
    compile 'com.followapps.android:sdk:4.3.+@aar'
}

However, if you're already using the google play service in your project, you can setup as following :

dependencies {
    ...
    compile 'com.google.android.gms:play-services:9.6.0'
    compile 'com.followapps.android:sdk:4.3.+@aar'
}

If you use Google Play Services with a version lower than 9.6.x, you have to update to 9.6.0 or newer.

Initialize with your API key

Prepare your API key

Be sure to have your API key for this step of the configuration. If you are not sure where to find it, please reach out to your Customer Success Manager or message support@followanalytics.com

To add your API key to your app project, add the following line in your Manifest file, within the application tag:

<application>
    [...]
   <meta-data android:name="FAID" android:value="YOUR_API_KEY"/>
    [...]
 </application>

The FollowAnalytics SDK must be initialized in the onCreate() method of an Application class. This allows the SDK to be constantly initialized, whether the user launches the app himself, or if the Android system wakes any receiver or service of the application (for example for a push notification).

Open your Application subclass, or create a new one, and add the following lines to override the onCreate method:

public class MyAwesomeApplication extends Application {
    [...]
    @Override
    public void onCreate() {
        super.onCreate();
        FollowApps.init(this);
        FollowApps.registerGcm();
        [...]
    }
    [...]
}

If you just created an Application subclass, do not forget to declare it in your AndroidManifest.xml file:

<application
    android:name=".MyAwesomeApplication"
    [...] />

Define the URL scheme

To allow users to retrieve their device ID for campaign testing and tagging plan debugging, declare a URL Scheme in your AndroidManifest.xml file:

<activity android:name="com.followapps.android.internal.activities.DeviceIdActivity" >
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="followanalytics.com"
            android:path="/deviceId"
            android:scheme="%YOUR_APP_PACKAGE_NAME%" />
    </intent-filter>
</activity>

Make sure that the package name of your app appears instead of the %YOUR_APP_PACKAGE_NAME% placeholder.

Once configured, your FA device ID can be obtained by opening the following URI in any mobile browser but Chrome: %YOUR_APP_PACKAGE_NAME%://followanalytics.com/deviceId.

FA users can request, from the product interface, that an e-mail message containing this link be sent to their device to facilitate the operation.

App Links don't work from Chrome

Chrome will search on Google instead of opening the URL. If you have no other browser installed, you can install Firefox from Google Play.

Register for notifications

The FollowAnalytics SDK supports push notifications based on Google Cloud Messaging. To ensure notifications can be sent from FollowAnalytics, please follow the steps below.

  1. Add the following permissions to your manifest:

    <permission android:name="%YOUR_APP_PACKAGE_NAME%.permission.C2D_MESSAGE"
                    android:protectionLevel="signature" />
     <uses-permission android:name="%YOUR_APP_PACKAGE_NAME%.permission.C2D_MESSAGE" />
  2. Add the GCM Receiver to your manifest

    <receiver
                android:name="com.google.android.gms.gcm.GcmReceiver"
                android:exported="true"
                android:permission="com.google.android.c2dm.permission.SEND"
                >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <!-- for Gingerbread GSF backward compat -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
                <category android:name="%YOUR_APP_PACKAGE_NAME%"/>
            </intent-filter>
     </receiver>
  3. In your Application subclass, ensure you've added the registerGCM() call

    public class MyAwesomeApplication extends Application {
          [...]
          @Override
          public void onCreate() {
              super.onCreate();
              FollowApps.init(this);
              FollowApps.registerGcm();
              [...]
          }
          [...]
    }

Notification icon and color

The SDK will use your app icon launcher as default notification icon. If you want a custom icon for your FollowAnalytics notification, add a ic_fa_notification.png file in your drawable folders. If you wish to have a custom background color on your notifications, you can ad a value to your color.xml: <color name="ic_fa_notification_color">#ff0000</color>

Validate

The SDK has a Validator that will ensure that everything is properly configured.

No matter whether you use jar or gradle, you should check your configuration. The SDK allows you to use the Validator in two ways:

  1. The validator can be displayed in a dialog using the following code

    if(Configuration.isApplicationInDebug()){
        InstallationChecker.displaySDKConfigurationCheckingInDialog(ActivityContext);
    }
  2. Alternatively, you can have it displayed in the console

    if(Configuration.isApplicationInDebug()){
        InstallationChecker.showSDKConfigurationInLog(this);
    }

Validator description

To know more about what the validator checks and how, please refer to its dedicated page.

Permission

The SDK uses the following permissions. If you're using gradle, they are automatically added by manifest merging process.

<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Geofencing (optional)

To be able to trigger messages based on geofencing, you have to add the following permissions to your manifest:

<!-- Add this permission if you want geofencing-related features to work, and if you want more accurate location data -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

For best user experience, you should request theses permissions in your first Activity as described here.

Logging

Data sent in debug mode will not appear on dashboards

When your app runs in DEBUG mode or in a simulator, the data is automatically sent as development logs, and is therefore not processed to be shown on the main UI page. DEBUG logs can be checked using the method given in the FAQ section.

See related entry in FAQ for more information on debug & release modes.

Logging best practices

To ensure your tags are relevant and will end up empowering your team through FollowAnalytics, please read the Logging best practices entry in the FAQ section.

Events vs Attributes

The FollowAnalytics SDK allows you to tag both events and attributes. If you are unsure about the difference, please refer to the corresponding FAQ entry.

Tag events

Regular, native event logging

The SDK allows you to log events happening in your code. These are the two methods you can call on the SDK:

// Log an event without details
FollowApps.logEvent(String eventName);
FollowApps.logError(String errorName);

// Log an event with String details
FollowApps.logEvent(String eventName, String details);
FollowApps.logError(String errorName, String details);

// Log an event with Map details
// This is useful to pass pairs of key-values into a single event
// Note that this Map should only contains basic types as values, including
// Integer, Long, Float, Double, String, Boolean
FollowApps.logEvent(String eventName, String details);
FollowApps.logError(String errorName, Map<String, ?> details);

Use the name as the unique identifier of your tag, use the details section to add specific details, context. Events can be renamed later: the name that you give to your event here can be overridden in the FollowAnalytics UI.

The details field can either be a String or a Map, so that you can associated multiple key-values for additional context.

For instance, logging the appearance of a view could be done the following ways:

FollowApps.logEvent("Product Page", "Product #42"); 
FollowApps.logError("Error log", "This is an error!");

You may use a Map for details. In this case, the Map values should only contain basic java types, such as Integer, Long, Float, Double, String, and Boolean.

HashMap<String, ?> detailsMap = new HashMap<String, Object>();
detailsMap.put("product_id", 42);
detailsMap.put("product_category", "Jeans");
FollowApps.logEvent("Add product to cart", detailsMap);

In debug mode, the SDK will acknowledge the saving by writing in the console whatever it receives.

If the parameters sent to these methods are over 60Kb, the method will refuse them, return NO, and write a message in the console, if it is running in debug mode.

Logging from a web view

Limitations

This feature is only activated for Android 4.2 (API Version >= 17) to prevent a security flaw in Google Android SDK, documented here by Google.

If you happen to use a web view to display elements of your app, you can also tag events and errors from within your HTML/JS code. To do so:

  1. Execute this method on your WebView to enable the SDK logging interface:

    this.addJavascriptInterface(new FaWebViewLogger(), "FollowAnalytics");
  2. Use the following method calls in your web page code to save events. For instance, you can do:

    <a onClick="if (typeof FollowApps !== 'undefined') {FollowApps.logEvent('My event');}">Send event without detail</a>
    <a onClick="if (typeof FollowApps !== 'undefined') {FollowApps.logEvent('My event', 'My event details');}">Send event with detail</a>
    <a onClick="if (typeof FollowApps !== 'undefined') {FollowApps.logError('fromWebView without detail');}">Send error without detail</a>
    <a onClick="if (typeof FollowApps !== 'undefined') {FollowApps.logError('fromWebView with detail','Error detail');}">Send error with detail</a>
  3. In case you want to register for push through a webview, you need to call fARegisterForPush():

    <a href="#" onClick="if (typeof FollowApps !== 'undefined') {FollowApps.faRegisterForPush();}">Register for push</a>
  4. Make sure to test if FollowApps object exists with if (typeof FollowApps !== 'undefined'). This way, you can reuse the exact same HTML code for your mobile web site without impact.

User ID and attributes

User ID

If users can sign in somewhere in your app, you can specify their identifier to the SDK. This way, you will be able to relate crashes to specific users, link your users between FollowAnalytics and your CRM, and more.

This identifier is usually an e-mail address, client identifier, phone number, or anything else that uniquely ties your customers to you.

To register the user identifier, use:

FollowApps.setCurrentIdentifier(String UserId);

If you want to remove the user identifier (in case of a sign out for instance) use the following method:

FollowApps.unsetCurrentIdentifier();

Predefined attributes

The SDK allows to set values for both custom and predefined attributes.

For predefined attributes, the SDK has the following properties:

setLastName(String lastName);
setFirstName(String firstName);
setRegion(String region);
setCountry(String country);
setCity(String city);
setCountry(String country);
setEmail(String email);
...

They are "predefined" in the sense that they will be attached to default fields on your user profiles.

For example, to set user Joe's city to "Paris", you would proceed as follows:

FollowApps.getAttributeManager().setCity("Paris");
FollowApps.getAttributeManager().setFirstname("Joe");

Custom attributes

Double check your custom attribute types

When a value for an unknown attribute is received by the server, the attribute is declared with the type of that first value.

If you change the type of an attribute in the SDK, values might be refused server-side. Please ensure the types match by visiting the profile data section of the product.

Set a custom attribute

To set your custom attributes, you can use methods that are adapted for each type: setInt, setString,setBoolean, setDate, setDateTime and setDouble.

For example, to set the user's job:

FollowApps.getAttributeManager().setString("key_job", "Taxi driver");
Delete a custom attribute value

You can delete the value of an attribute using its key. For example, to delete the user's job:

FollowApps.getAttributeManager().delete("key_job");
Set of Attributes

You can add or remove an item to or from a set of attributes.

To add an item:

FollowApps.getAttributeManager().add("fruits","apple");
FollowApps.getAttributeManager().add("fruits","strawberry");
FollowApps.getAttributeManager().add("fruits","lemon");

To remove an item:

FollowApps.getAttributeManager().remove("fruits","lemon"); // Removes "lemon" from set of fruits.

And to clear a set:

FollowApps.getAttributeManager().empty("fruits");  #Removes all the items from the set.

For further information, refer to the SDK header file.

AdaptiveSDK

The SDK has a feature called AdaptiveSDK: it allows to benefit from tags already in place and use them directly without having to implement a new tagging plan.

The Android SDK currently supports Mixpanel, Google Analytics, Localytics, Segment IO, Urban Airship, Google Tag Manager and Flurry.

Limitation

The AdaptiveSDK feature only works with the gradle implementation.

To enable the fetching of tags of a given SDK, please do as follows:

  1. Add the dependency:

    compile 'com.followapps.adaptivesdk:adaptivesdk:4.3.0@aar'
  2. Allow the FollowAnalytics SDK to start handling events:

    FollowApps.startHandlingExternalEvent();
  3. Add an external SDK to be handled.

    You can select one or more of the following SDK:

    GOOGLE_ANALYTIC,
    URBAN_AIRSHIP,
    MIXPANEL,
    SEGMENT_IO,
    GOOGLE_TAG_MANAGER,
    LOCALYTICS,
    FLURRY

    For istance, to handle Mixpanel events, do:

    FollowApps.addExternalSDK(ExternalSDK.MIXPANEL);
  4. To stop handling all events:

    FollowApps.stopHandlingExternalEvent();

How it works

All the events you save using the compatible Analytics SDKs will also be saved on FollowAnalytics. The event name will be prefixed with a two-character code identifying the source: UA for UrbanAirship, LL for Localytics, and so on.

Just like for events tagged directly with our SDK, you can see logs in your developer console when a log is saved, so that you can check it is properly working.

Advanced Use Cases

Deep-linking: URL, Parameters

Campaigns created through FollowAnalytics allow to deep link to content in your app. You can either use an App Link, or use key-value parameters that are forwarded to your code.

Version 4.1.0 of the SDK introduced the possibility to use direct App Links like twitter://messages, which will send you to the corresponding screen inside the Twitter application.

You're able to access the functionality by enabling the Deep Linking switch in our UI, when creating a campaign. There you'll find the field App Link that expects you to enter these type of url schemas. It can either be an URL Schema to an external application or for your own application.

Deep-linking parameters

In FollowAnalytics campaigns, you can specify deep-linking parameters, e.g. in your push messages or for in-app button actions.

These parameters are given to the developer's code by the SDK. It is then up to the developer to implement the deep-linking in the app (specific path of screens, format of the arguments, etc.).

To obtain these parameters, you can extend the DefaultMessageHandler class or implement MessageHandler, like in the following example:

public class CustomMessageHandler implements DefaultMessageHandler {
     @Override
     public void onPushMessageClicked(Context context, Map<String, String> data) {
         String value1 = data.get("a_custom_param_key");
         String value2 = data.get("another_key");

         // Silently do stuff ...
         // .. or start an activity

         Intent intent = new Intent(context, SpecificActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         context.startActivity(intent);
     }

       @Override
         public void onPushMessageClicked(Context context, String url, Map<String, String> data) {
            //Do something with the url
         }

     @Override
     public void onInAppMessageClicked(Context context, String buttonText, Map<String, String> data) {
         // Same as the above method, but from a in-app message!
     }
}

If you chose to define a custom MessageHandler, you must declare it in your Application, after the FollowApps.init(this) line:

FollowApps.setMessageHandler(new CustomMessageHandler());

Through the key value format, FollowAnalytics supports both standardized deep-linking (by defining the key you'll always use to give the path), and more direct parameter passing for simpler use cases integrations.

Regular deep-linking is usually implemented using a Router, that will handle the URL called on the app and translate it into the display of the right page, with the right content.

Control over campaigns

Custom handling of rich campaigns

Rich campaigns can be handled directly by the application code, instead of being showed automatically by the SDK. The behavior is defined when creating the campaign, using the "automatically display content" switch.

For campaigns where the content is not handled by FollowAnalytics, you will need to extend com.followapps.android.CustomRichCampaignBaseReceiver and declare it in your AndroidManifest.xml. You'll need to use an intent-filter on BROADCAST_RICH_CAMPAIGNS_ACTION. For instance:

<receiver android:name=".RichCampaignDataReceiver" >
    <intent-filter>
        <action android:name="%YOUR_APP_PACKAGE_NAME%.BROADCAST_RICH_CAMPAIGNS_ACTION" />
    </intent-filter>
</receiver>

Where %YOUR_APP_PACKAGE_NAME% is your application package name.

The method onRichCampaignDataReceived must be overridden. Rich campaign parameters are provided as method arguments:

Pausing in-app campaigns

You can prevent in-app campaigns from being displayed on certain views of your app. This can be useful when you are displaying a media content, or if the topmost screen is only shown for a few seconds, for instance.

Any campaign supposed to be displayed when the mechanism is paused is stacked and shown as soon as it is resumed.

To tell the SDK to prevent the display of rich campaigns, and then to activate it back, use the following methods:

FollowApps.pauseCampaignDisplay();  # will pause campaign display
FollowApps.resumeCampaignDisplay();  # will resume campaign display

Tip: use view lifecycle methods

If you want to prevent the display on a given page, you can call the pause method when on the method onStart, and the resume in its onStop.

Tip: only allow display in some places of the app

You can use these methods the other way round, by pausing all campaigns when the app starts, right after the SDK is initialized, and then resuming where the messages can be shown. Just pause again when the user leaves that "safe" area of your app.

Working with multiple GCMs

If you are already using GCM in your application, you will have to check the sender of each notification, as it can now come from different providers (e.g.you and FollowAnalytics).

Let FollowAnalytics do the process for you

To handle your push message inside the FollowAnalytics SDK, you have to extend the service FollowPushService of Follow and override its method onPushMessageArrived:

import android.os.Bundle;
public class OtherExternalPushService extends FollowPushService{

  @Override
  public void onPushMessageArrived(String from, Bundle data) {
    super.onPushMessageArrived(from, data);
    //process data not from Follow SDK
  }
}

And declare the service in the manifest:

<service
        android:name=".mypackage....OtherExternalPushService"
        android:exported="false"
        >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
    </intent-filter>
</service>

Forward the push message to FollowAnalytics SDK

  1. If you have implemented the BroadcastReceiver you should proceed as follows:

    public class MyCustomReceiver extends GcmReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            super.onReceive(context, intent);
            String from = intent.getStringExtra("from");
            if(FollowApps.isFollowAnalyticsPush(from)){
                FollowApps.onPushReceived(context,intent.getExtras(),from);
            }else{
             //DoSomething with it 
        }
    }

    And declare it in manifest:

    <receiver
            android:name="mypackage_name.MyCustomReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND"
            >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            <!-- for Gingerbread GSF backward compat -->
            <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
            <category android:name="mypackage_name"/>
        </intent-filter>
    </receiver>
  2. If you have implemented Google's GcmListenerService you should proceed as follows:

    public class MyGcmListenerService extends GcmListenerService {
    
        public MyGcmListenerService() {
            super();
        }
    
        @Override
        public void onMessageReceived(String from, Bundle data) {
            super.onMessageReceived(from, data);
            if (FollowApps.isFollowAnalyticsPush(from)) {
                FollowApps.onPushReceived(this, data, from);
            } else {
                //DoSomething with it  
            }
        }
    }

    And then declare it in manifest:

    <service
            android:name=".mypackage....MyGcmListenerService"
            android:exported="false"
            >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        </intent-filter>
    </service>

Integration with Parse

If you are using Parse in your application, you need to follow the steps bellow to ensure both tools work fine:

  1. Let Parse register both

    Parse uses its own senderId, and the other senderId must be added in the manifest as:

    <meta-data android:name="com.parse.push.gcm_sender_id" android:value="id:147726633311" />;
  2. Retrieve the token from Parse

    ParseInstallation.getCurrentInstallation().saveInBackground();
    
    Object deviceToken = ParseInstallation.getCurrentInstallation().get("deviceToken");
    if(deviceToken != null){
        FollowApps.setGcmToken(deviceToken.toString());
    }

Manual install using the jar file

Gradle is the prefered method

Even though you can install the SDK manually, using gradle is the prefered method, since it will take care of much of the work and ensure your SDK is easily updated.

To install the SDK manually, you need download the .jar file containing the code of our SDK, import the Play Services, and add some extra lines to your AndroidManifest.xml.

  1. In your application project, add the .jar file to the /libs directory. If your application does not have a /libs directory, place the .jar file in your application directory and add this directory to your Java CLASSPATH variable.

  2. Copy the library project found in your Android SDK installation under extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects. You must import version 9.6.0 or newer.

  3. Reference the google-play-services folder as a library project. If you are using Eclipse as an IDE, see Referencing a Library Project for Eclipse, otherwise see Referencing a Library Project on the Command Line for more information.

  4. Finalize the play-services installation by adding the following tag in your AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest ...>
        [...]
        <application ...>
            [...]
            <meta-data android:name="com.google.android.gms.version"
                       android:value="@integer/google_play_services_version" />
            [...]
        </application>
    </manifest>
  5. Add the following lines to the AndroidManifest.xml. It will specify the permissions the SDK needs and declare its components.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest ...>
        [...]
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <uses-permission android:name="android.permission.GET_TASKS" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    
        <application...>
            [...]
            <service android:name="com.followapps.android.internal.service.StorageService" />
            <service android:name="com.followapps.android.internal.service.CampaignService" />
            <service android:name="com.followapps.android.internal.service.RequestService" />
            <service android:name="com.followapps.android.internal.service.FollowPushService" android:exported="false">
                        <intent-filter>
                            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                        </intent-filter>
            </service>
            <service android:name="com.followapps.android.internal.push.FollowInstanceIDListenerService"
                              android:exported="false">
                              <intent-filter>
                                <action android:name="com.google.android.gms.iid.InstanceID"/>
                              </intent-filter>
            </service>
    
            <receiver android:name="com.followapps.android.internal.listener.FaSdkReceiver">
                <intent-filter>
                    <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                </intent-filter>
            </receiver>
    
            <activity android:name="com.followapps.android.internal.activities.RichCampaignActivity"
                android:theme="@android:style/Theme.Translucent.NoTitleBar"
                android:configChanges="keyboardHidden|orientation">
                <intent-filter>
                    <action android:name="%YOUR_APP_PACKAGE_NAME%.RICH_CAMPAIGN_VIEW" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
    
             <activity
                      android:name="com.followapps.android.internal.activities.FaWebViewActivity"
                      android:configChanges="keyboardHidden|orientation"
             />
    
            <activity android:name="com.followapps.android.internal.activities.DialogActivity"
                      android:theme="@android:style/Theme.Translucent.NoTitleBar"
                      android:configChanges="keyboardHidden|orientation" />
        </application>
    </manifest>

    Where %YOUR_APP_PACKAGE_NAME% is your application package name.

  6. Now, you can proceed to configuring and validating your setup.

Misc

Opt-out

The FollowAnalytics SDK allows to handle opt-out states for different features.

Flags

The SDK supplies methods to change some authorization flags:

boolean authorized = true;

// authorized to log events
FollowApps.setCollectLogsAuthorization(authorized);

// authorized to log location events
FollowApps.setCollectLocationLogsAuthorization(boolean authorized);

// authorized to receive push notifications
FollowApps.setPushAuthorization(boolean authorized);

Note that for logging locations events, both the collect logs and collect location logs authorizations must be true. In practice, the location logs are collected if and only if FollowApps.canCollectLocationLogs() returns true.

Dialog

In addition to the direct access to the flag, the SDK supplies methods to ask the user whether they accept to collect logs or receive push notifications or not, using a dialog box.

For getting the authorization to collect logs, you can do as follows:

FollowApps.sendLogAuthorization(String title, 
    String message, 
    String positiveButtonTitle, 
    String negativeButtonTitle, 
    Activity activity);

Example (within an Activity):

FollowApps.sendLogAuthorization("Help Us Improve This App", 
    "Do you accept us to collect anonymous information on your application usage?", 
    "Accept", 
    "Decline", 
    this);

For collectingl location logs:

FollowApps.sendLocationAuthorization(String title, 
    String message, 
    String positiveButtonTitle, 
    String negativeButtonTitle, 
    Activity activity);

Example (within an Activity):

FollowApps.sendLocationAuthorization("Better experience!", 
    "This application would like to use your device location in order to provide you with localized content, do you agree?", 
    "Accept", 
    "Decline", 
    this);

Proguard

If you need to obfuscate and/or shrink your app before Google Play publication, be sure you protect the FollowAnalytics SDK, otherwise logs won't be sent.

Here is the ProGuard configuration:

-keep class com.followapps** { *; }
-keep interface com.followapps.** { *; }

Migrating from older SDK versions

Migration from jar to gradle

If you're migrating from jar to gradle, please follow the steps below:

  1. Remove the permissions, services and receivers related to the FollowAnalytics SDK (gradle will put them automatically).

  2. If you use push or in-app messages, add the following permissions to your manifest:

    <permission android:name="%YOUR_APP_PACKAGE_NAME%.permission.C2D_MESSAGE"
                    android:protectionLevel="signature" />
     <uses-permission android:name="%YOUR_APP_PACKAGE_NAME%.permission.C2D_MESSAGE" />

    and add the GCM Receiver:

    <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND"
            >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            <!-- for Gingerbread GSF backward compat -->
            <action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
            <category android:name="%YOUR_APP_PACKAGE_NAME%"/>
        </intent-filter>
     </receiver>
  3. Add the FollowAnalytics repository to your build.gradle repositories:

    repositories {
        ...
        maven {
            url 'http://nexus.follow-apps.com/nexus/content/repositories/releases/'
        }
    }
  4. Add the FollowAnalytics SDK to your module's build.gradle dependencies:

    dependencies {
        ...
        compile 'com.google.android.gms:play-services-gcm:9.6.0'
      compile 'com.google.android.gms:play-services-location:9.6.0'
        compile 'com.followapps.android:sdk:4.3.+@aar'
    }

If you use Google Play Services with a version lower than 9.x.x, we recommend to update to 9.6.x (ex : 9.6.0).