/Stack-HolisticSolution-SDK-Android

Stack Holistic Solution SDK for Android simplifies the collection and transfer of the necessary parameters from third-party services to the corresponding Stack SDKs to improve the performance of services such as Mediation and UA

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

About

Stack Holistic Solution SDK for Android simplifies the collection and transfer of the necessary parameters from third-party services to the corresponding Stack SDKs to improve the performance of services such as Mediation and UA

Integration Guide

Before integration started

HS SDK using AndroidX, so please make sure you have enabled Jetifier

Import SDK

1. Add the Appodeal maven repository

Apps can import the HS SDK with a Gradle dependency that points to the Appodeal's Maven repository. In order to use that repository, you need to reference it in the app's project-level build.gradle file. Open yours and look for an allprojects section:

Example project-level build.gradle (excerpt)

allprojects {
    repositories {
        // ... other project repositories
        maven {
            url "https://artifactory.appodeal.com/appodeal"
        }
    }
}

2. Add maven dependencies

Next, open the app-level build.gradle file for your app, and look for the dependencies section:

Example app-level build.gradle (excerpt)

dependencies {
    // ... other project dependencies
    implementation 'com.explorestack.hs:sdk:2.0.2.+'
}

3. Setup required services

3.1. Facebook Service

Note that HS Facebook Service will include only 'facebook-core' dependency independently

1. Configure Your Facebook App

Please follow this guide to configure you Facebook app

2. Add Your Facebook App ID

You can find more info about Facebook integrations in this guide

Open your /app/res/values/strings.xml file and add the following lines (remember to replace [APP_ID] with your actual Facebook app ID):

<string name="facebook_app_id">[APP_ID]</string>

Add a meta-data element to the application element:

<application ...>
    ...
    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id"/>
    ...
</application>

3.2. Firebase Service

Note that HS Firebase Service will include 'firebase-analytics' and 'firebase-config' dependencies independently

1. Configure Your Firebase App

Please, follow this guide to configure you Firebase app

Initialize SDK

Holistic Solution SDK will automatically initialize all components and sync all required data to connectors (e.g - Appodeal).

To initialize SDK add the line below to onCreate method of your application or activity class.

Initialization example:

public class YourApplication extends Application {
    ...
    @Override
    public void onCreate() {
        super.onCreate();

	//Create HSApp configuration
        HSAppConfig appConfig = new HSAppConfig()
                .setAppKey(YOUR_APPODEAL_KEY)
                .setAdType(REQUIRED_ADS_TYPES)
                .setDebugEnabled(...)
                .setComponentInitializeTimeout(...);

        //Initialize HSApp
        HSApp.initialize(activity, appConfig, new HSAppInitializeListener() {
            @Override
            public void onAppInitialized(@Nullable List<HSError> errors) {
                //HSApp initialization finished, now you can initialize required SDK
            }
        });
    }
    ...
}
Parameter Description
appKey Appodeal application key.
adType Appodeal ad types (e.g - Appodeal.INTERSTITIAL).
debug Enable sdk, services and connectors debug logic if possible.
timeout In this case is timeout for one operation: starting attribution service or fetching remote config. By default the value is 30 sec.

Code example

Features

Enable logs

Enable HSApp, services and connectors logging.

HSLogger.setEnabled(true)

After enabling it, you can view logs by the HSApp tag

Events

Holistic Solution SDK allows you to send events to analytic services such as Firebase, AppsFlyer and Facebook using a single method:

// Create map of event parameters if required
Map<String, Object> params = new HashMap<>();
params.put("example_param_1", "Param1 value");
params.put("example_param_2", 123);

// Send event to all connected analytics services
HSApp.logEvent("hs_sdk_example_test_event", params);

Event parameters can only be strings and numbers

Code example

Purchase validation

Holistic Solution SDK allows you to unify purchase validation using a single method:

// Purchase object is returned by Google API in onPurchasesUpdated() callback
public void validatePurchase(Purchase purchase) {
    
    // Create new HSInAppPurchase
    HSInAppPurchase hsPurchase = HSInAppPurchase.newBuilder("PURCHASE_TYPE")
        .withPublicKey("YOUR_PUBLIC_KEY")
        .withSignature(purchase.getSignature())
        .withPurchaseData(purchase.getOriginalJson())
        .withPurchaseToken(purchase.getPurchaseToken())
        .withPurchaseTimestamp(purchase.getPurchaseTime())
        .withDeveloperPayload(purchase.getDeveloperPayload())
        .withOrderId(purchase.getOrderId())
        .withSku(...)
        .withPrice(...)
        .withCurrency(...)
        .withAdditionalParams(...)
        .build();	    

    // Validate InApp purchase
    HSApp.validateInAppPurchase(hsPurchase, new HSInAppPurchaseValidateListener() {
        @Override
        public void onInAppPurchaseValidateSuccess(@NonNull HSInAppPurchase purchase,
                                                   @Nullable List<HSError> errors) {
            // In-App purchase validation was validated successfully by at least one
            // connected service
        }

        @Override
        public void onInAppPurchaseValidateFail(@NonNull List<HSError> errors) {
            // In-App purchase validation was failed by all connected service
        }
    });
}
Parameter Description Usage
purchaseType Purchase type. Must be one of PurchaseType. Adjust/AppsFlyer
publicKey Public key from Google Developer Console. AppsFlyer
signature Transaction signature (returned from Google API when the purchase is completed). Adjust/AppsFlyer
purchaseData Product purchased in JSON format (returned from Google API when the purchase is completed). AppsFlyer
purchaseToken Product purchased token (returned from Google API when the purchase is completed). Adjust
purchaseTimestamp Product purchased timestamp (returned from Google API when the purchase is completed). Adjust
developerPayload Product purchased developer payload (returned from Google API when the purchase is completed). Adjust
orderId Product purchased unique order id for the transaction (returned from Google API when the purchase is completed). Adjust
sku Stock keeping unit id. Adjust
price Purchase revenue. Adjust/AppsFlyer/Appodeal
currency Purchase currency. Adjust/AppsFlyer/Appodeal
additionalParameters Additional parameters of the purchase event. Adjust/AppsFlyer

In-App purchase validation runs by FIFO queue in a single thread

Code example