Migrating from v4 to v5
The 5.0.0 version brings many changes to the In Loco SDK public interfaces, by breaking the InLocoMedia interface into multiple interfaces. A brief description of the interfaces is as follows.
InLoco
Contains the initialization, user, and privacy-related methods
InLocoNotificationAds
Contains the methods related to notification ads
InLocoVisits
Contains the methods related to visit detection and location

1. Update your dependencies

Change the version of com.inlocomedia.android:android-sdk-ads to 5.4.+ on your app-level build.gradle file.Groovy
1
dependencies {
2
compile 'com.inlocomedia.android:android-sdk-ads:5.4.+'
3
}
Copied!
For more details, take a look at the Setting your App section.

2. Update the SDK initialization

The In Loco SDK initialization now relies on the presence of an in-loco-options.properties file in the main/assets directory of your project. We recommend that the previous initialization is replaced with the new one, according to the initialization section.
The previous initialization using the InLocoMedia.init(...) is then replaced with InLoco.init(context).Java
1
// v4 initialization
2
InLocoMediaOptions options = InLocoMediaOptions.getInstance(this);
3
options.setApplicationId("YOUR_APP_ID");
4
options.setLogEnabled(true);
5
InLocoMedia.init(this, options);
6
​
7
// v5 initialization: Initializes the In Loco SDK by using the in-loco-options.properties file.
8
InLoco.init(this);
Copied!
in-loco-options.properties example
1
# The Application ID
2
appId=<YOUR_APP_ID>
3
​
4
# Indicates whether the SDK should present logs or not. Default value: true
5
logEnabled=true
Copied!
If you still prefer to use an Options object, the InLocoMediaOptions class can be replaced with InLocoOptions class.Java
1
// v4 initialization
2
InLocoMediaOptions options = InLocoMediaOptions.getInstance(this);
3
options.setApplicationId("YOUR_APP_ID");
4
options.setLogEnabled(true);
5
InLocoMedia.init(this, options);
6
​
7
// v5 initialization
8
InLocoOptions inLocoOptions = new InLocoOptions.Builder()
9
.appId("YOUR_APP_ID")
10
.logEnabled(true)
11
.build()
12
InLoco.init(this, options)
Copied!

3. Changes to the User Privacy interface

Methods related to user privacy were moved from the InLocoMedia class to the InLoco class.
Furthermore, new methods concerning user privacy were added to provide more fine-grained control amongst data usage. To know more, refer to the Privacy section.
v4
v5
InLocoMedia.givePrivacyConsent(Context context, boolean consent)
InLoco.givePrivacyConsent(Context context, boolean consent)
InLocoMedia.hasGivenPrivacyConsent(Context context)
InLoco.hasGivenPrivacyConsent(Context context)
InLocoMedia.isWaitingUserPrivacyConsent(Context context)
InLoco.isWaitingUserPrivacyConsent(Context context)

4. Changes to the Notifications Ads interface

Methods related to notification ads were moved from the InLocoMedia.Notification class to the InLocoNotificationAds class.
v4
v5
InLocoMedia.Notification.setEnabled(...)
InLocoNotificationAds.setEnabled(...)
InLocoMedia.Notification.isEnabled(...)
InLocoNotificationAds.isEnabled(...)
InLocoMedia.Notification.setAdRequest(...)
InLocoNotificationAds.setAdRequest(...)
InLocoMedia.Notification.getById(...)
InLocoNotificationAds.getById(...)
InLocoMedia.Notification.showById(...)
InLocoNotificationAds.showById(...)
InLocoMedia.Notification.discardById(...)
InLocoNotificationAds.discardById(...)
Last modified 1yr ago