New Android Sdk

Sdk Implementation

  • Add dengage sdk dependency to your project level gradle file.

// 6.0.60.1 with huawei module but without geofence module 

// 6.0.60.2 without huawei module and without geofence module 

// 6.0.60.3 with geofence module and with huawei module

// 6.0.60.4 with geofence module and without huwei module

dependencies {
    implementation 'com.github.dengage-tech:dengage-android-sdk:6.0.60.1'
}

For latest Android SDK click

Sdk Necessary Rules

Application Manifest Parameters

You should add some parameters with meta-data to your application manifest.

        
<!-- Event api url of Dengage -->
<meta-data
  android:name="den_event_api_url"
  android:value="https://your_push_api_endpoint" />

<!-- Push api url of Dengage -->
<meta-data
  android:name="den_push_api_url"
  android:value="https://your_push_api_endpoint" />

<!-- Geofence api url of Dengage -->
<meta-data
  android:name="den_geofence_api_url"
  android:value="https://your_push_api_endpoint" />
    
 <meta-data
   android:name="den_in_app_api_url"
   android:value="https://your_push_api_endpoint" />


Please see API Endpoints By Datacenter to set your event end point.

Application Manifest Services

You should add firebase and huawei messaging services to your application manifest. If you are using
your own messaging service classes, you don't need to add Dengage service classes to your manifest.

<!-- Fcm Messaging Service for handling push messages comes from firebase -->
<service
    android:name="com.dengage.sdk.push.FcmMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

<!-- Hms Messaging Service for handling push messages comes from huawei messaging service -->
<service
    android:name="com.dengage.sdk.push.HmsMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
    </intent-filter>
</service>

Application Manifest Push Receiver

You should add your PushNotificationReceiver class which extends NotificationReceiver class of
Dengage sdk.

<!-- For handling push notifications comes to messaging service classes -->
<receiver
    android:name="{your_package}.PushNotificationReceiver"
    android:exported="false">
    <intent-filter>
        <action android:name="com.dengage.push.intent.RECEIVE" />
        <action android:name="com.dengage.push.intent.OPEN" />
        <action android:name="com.dengage.push.intent.DELETE" />
        <action android:name="com.dengage.push.intent.ACTION_CLICK" />
        <action android:name="com.dengage.push.intent.ITEM_CLICK" />
        <action android:name="com.dengage.push.intent.CAROUSEL_ITEM_CLICK" />
    </intent-filter>
</receiver>

Registering LifeCycle Callbacks

You should register activity lifecycle callbacks to DengageLifecycleTracker. This is required for
fetching some contents from api like in app message list. You can do this operation on your application class.

registerActivityLifecycleCallbacks(DengageLifecycleTracker())

Sdk Methods

init

Should be called once in application lifecycle for initiation of Dengage sdk. You can place it into
Application class onCreate method.


For .1 version you can init like this .

Dengage.init(
        context: Context,
        firebaseIntegrationKey: String? = null,
        huaweiIntegrationKey: String? = null,
        firebaseApp: FirebaseApp? = null,
        deviceId: String? = null,
        deviceConfigurationPreference: DeviceConfigurationPreference? = DeviceConfigurationPreference.Google,
        contactKey: String? = null,
        partnerDeviceId: String? = null,
       disableOpenWebUrl:Boolean? =false,
        notificationDisplayPriorityConfiguration: NotificationDisplayPriorityConfiguration =NotificationDisplayPriorityConfiguration.SHOW_WITH_DEFAULT_PRIORITY
 

        )
  
  For .2 version you can init like this .

  Dengage.init(
        context: Context,
        firebaseIntegrationKey: String? = null,
        firebaseApp: FirebaseApp? = null,
        deviceId: String? = null,
        contactKey: String? = null,
        partnerDeviceId: String? = null,
       disableOpenWebUrl:Boolean? =false,
        notificationDisplayPriorityConfiguration: NotificationDisplayPriorityConfiguration =NotificationDisplayPriorityConfiguration.SHOW_WITH_DEFAULT_PRIORITY
 
    )
  
  
  For .3 version you can init like this .

  Dengage.init(
        context: Context,
        firebaseIntegrationKey: String? = null,
        huaweiIntegrationKey: String? = null,
        firebaseApp: FirebaseApp? = null,
        geofenceEnabled: Boolean = false,
        deviceId: String? = null,
        deviceConfigurationPreference: DeviceConfigurationPreference? = DeviceConfigurationPreference.Google,
        contactKey: String? = null,
        partnerDeviceId: String? = null,
       disableOpenWebUrl:Boolean? =false,
        notificationDisplayPriorityConfiguration: NotificationDisplayPriorityConfiguration =NotificationDisplayPriorityConfiguration.SHOW_WITH_DEFAULT_PRIORITY
 

        )
  
  
  For .4 version you can init like this .

  Dengage.init(
        context: Context,
        firebaseIntegrationKey: String? = null,
        firebaseApp: FirebaseApp? = null,
        geofenceEnabled: Boolean = false,
        deviceId: String? = null,
        contactKey: String? = null,
        partnerDeviceId: String? = null,
       disableOpenWebUrl:Boolean? =false,
        notificationDisplayPriorityConfiguration: NotificationDisplayPriorityConfiguration =NotificationDisplayPriorityConfiguration.SHOW_WITH_DEFAULT_PRIORITY
 
    )
  

Disable Open web

if you do not want the browser to be opened on the push click then you can use the parameter in the init block of the sdk as follows:

 disableOpenWebUrl = false 

setLogStatus

You can enable or disable logs comes from Dengage sdk to your Logcat.

Dengage.setLogStatus(
    enable: Boolean /* To enable logs send true, to disable logs send false */
)

setFirebaseIntegrationKey

You can also set your Dengage firebase app integration key after sdk initiation.

Dengage.setFirebaseIntegrationKey(
    integrationKey: String /* Your Dengage firebase app integration key */
)

setHuaweiIntegrationKey

You can also set your Dengage huawei app integration key after sdk initiation.

Dengage.setHuaweiIntegrationKey(
    integrationKey: String /* Your Dengage huawei app integration key */
)

getSubscription

You can get Dengage sdk subscription model from sdk cache if exists (If you init correctly, it will
exist).

Dengage.getSubscription(): Subscription?

setDeviceId

You can set device id of current user subscription.

Dengage.setDeviceId(
    deviceId: String /* Unique identifier of device */
)

setCountry

You can set country of current user subscription.

Dengage.setCountry(
    country: String /* Free country text */
)

setContactKey

You can set contact key of current user subscription.

Dengage.setContactKey(
    contactKey: String? /* User key */
)

setUserPermission

You can set user permission of current user subscription.

Dengage.setUserPermission(
    permission: Boolean /* User permission flag */
)

getUserPermission

You can get user permission of current user subscription.

Dengage.getUserPermission(): Boolean?

setToken

You can set firebase or huawei messaging token of current user subscription.

Dengage.setToken(
    token: String? /* Firebase or huawei messaging token */
)

getToken

You can get token of current user subscription.

Dengage.getToken(): String?

onNewToken

You can set firebase or huawei messaging token of current user subscription.

Dengage.onNewToken(
    token: String? /* Firebase or huawei messaging token */
)

setNotificationChannelName

You can set notification channel name for setting to notifications above android 26.

Dengage.setNotificationChannelName(
    name: String /* Notification channel name */
)

startAppTracking

You can start app tracking with package name of the apps that you want to track.

Dengage.startAppTracking(
    appTrackings: List<AppTracking>? /* App info list that you want to track */
)

getInboxMessages

You can get inbox messages with pagination. If you set push message addToInbox parameter as true,
push messages sent from Dengage are also saved to your inbox.

Dengage.getInboxMessages(
    limit: Int, /* Size limit of the inbox list */
    offset: Int, /* Offset of the inbox list, you should send 0 to get first page */
    dengageCallback: DengageCallback<MutableList<InboxMessage>> /* Callback for getting inbox message list returned from Dengage api */
)

deleteInboxMessage

You can delete any inbox message from the user's inbox.

Dengage.deleteInboxMessage(
    messageId: String /* Id of the inbox message that you want to delete from users inbox */
)

setInboxMessageAsClicked

You can set any inbox message as clicked with the user's interaction.

Dengage.setInboxMessageAsClicked(
    messageId: String /* Id of the inbox message that user clicked */
)

setNavigation

You can call this method for showing in app message popup if exists.

Dengage.setNavigation(
    activity: Activity /* For showing ui of in app message */
)

setNavigation

You can call this method for showing in app message popup if exists with the given screen name.

Dengage.setNavigation(
    activity: Activity, /* For showing ui of in app message */
    screenName: String? /* For filtering in app messages with respect to current screen in your app */
)

Retrieve on the same link parameter from the dashboard

Starting from 6.0.11.x , we have added a new parameter if you want to handle deeplink by yourself and do not want the app to restart then you need to pass request code in the setNavigation function and the result intent would be provided in the onActivityForResult

Dengage.setNavigation(
    activity: Activity, /* For showing ui of in app message */
    screenName: String? /* For filtering in app messages with respect to current screen in your app */
    requestCode:Int , /*request code to get the intent*/
    
//

Dengage.setNavigation(
    activity: Activity, /* For showing ui of in app message */
    requestCode:Int  /*request code to get the intent*/
    

To set deeplink in the sdk you can use the link 

Dengage.inAppLinkConfiguration(inappDeeplink:String)


    

setTags

You can send tag items to Dengage api.

Dengage.setTags(
    tags: List<TagItem> /* TagItem list that you want to send Dengage api */
)

onMessageReceived

You should send push message data, if you are using your own firebase or huawei messaging service
receivers.

Dengage.onMessageReceived(
    data: Map<String, String?>? /* Data of the push message comes to your firebase or huawei messaging service */
)

showTestPage

You can use our embedded test pages if you want to show or manipulate any data on Dengage sdk. It is
useful for your development or qa team. Test pages contain;

  • Push Message ui and events
  • In App Message ui and events
  • Getting your device's info on Dengage sdk (Contains copy paste)
  • Getting your device's cache on Dengage sdk (Contains copy paste)
  • Manipulating fetch times of device parameters
  • Showing last 200 logs of Dengage sdk operations (Contains copy paste)
Dengage.showTestPage(
    activity: Activity /* For showing ui of test pages */
)

saveRFMScores

You can save rfm scores to local storage if you will use rfm item sorting.

Dengage.saveRFMScores(
    scores: RFMScore(
        categoryId: String, /* Category identifier of the RFMScore object */
        score: Double /* The score value of the RFMScore object, specified as a value from 0.0 to 1.0. 
                         Score values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0 */
    )
)

categoryView

You can update rfm score of viewed category.

Dengage.categoryView(
    categoryId: String /* Category identifier of viewed category */
)

sortRFMItems

You can sort rfm items with respect to rfm scores saved to local storage.
Returns list of the sorted rfm items

Dengage.sortRFMItems(
    rfmGender: RFMGender,
    rfmItems: MutableList<RFMItem>
)

RFMItem(
    id: String,
    categoryId: String,
    personalized: Boolean,
    gender: RFMGender{
        MALE,
        FEMALE,
        NEUTRAL
    },
    sequence: Int
)

You can use RFMItem directly. Also you can create your own rfm item object that extends RFMItem.
Then sort your own items like below:

class YourOwnRFMItem(
    id: String,
    categoryId: String,
    personalized: Boolean,
    gender: RFMGender,
    sequence: Int,
    var parameter1: String,
    var parameter2: String,
) : RFMItem(
    id = id,
    categoryId = categoryId,
    personalized = personalized,
    gender = gender,
    sequence = sequence,
)

val sortedYourOwnRFMItems: MutableList<YourOwnRFMItem> = Dengage.sortRFMItems(
    rfmItems = listOfYourOwnRFMItems
)

Event Methods

You can send events to Dengage sdk. Available event methods listed below. But you can send your own
custom events also.

Dengage.pageView(data: HashMap<String, Any>)

Dengage.sendCartEvents(data: HashMap<String, Any>, eventType: String)

Dengage.addToCart(data: HashMap<String, Any>)

Dengage.removeFromCart(data: HashMap<String, Any>)

Dengage.viewCart(data: HashMap<String, Any>)

Dengage.beginCheckout(data: HashMap<String, Any>)

Dengage.cancelOrder(data: HashMap<String, Any>)

Dengage.order(data: HashMap<String, Any>)

Dengage.search(data: HashMap<String, Any>)

Dengage.sendWishListEvents(data: HashMap<String, Any>, beventType: String)

Dengage.addToWishList(data: HashMap<String, Any>)

Dengage.removeFromWishList(data: HashMap<String, Any>)

Dengage.sendCustomEvent(
    tableName: String,
    key: String,
    data: HashMap<String, Any>
)

Dengage.sendDeviceEvent(
    tableName: String,
    data: HashMap<String, Any>
)

Dengage.sendOpenEvent(
    buttonId: String,
    itemId: String,
    message: Message?
)

Adjust Adid sync with dengage

You can sync adjust adid with dengage through the following method

Dengage.setPartnerDeviceId(adid:String)
    

Real time inapp functions

You can use the real time in-app functionality by using the function.

     showRealTimeInApp(
        activity: Activity,
        screenName: String? ,
        params: HashMap<String, String>? , resultCode: Int 
    ) 

    here the params are the custom parameters used for comparison.

    

    Some functions used to set properties are as follows 

     /**
     * Set category path for using in real time in app comparisons
     */
    fun setCategoryPath(path: String?) 

    /**
     * Set cart item count for using in real time in app comparisons
     */
    fun setCartItemCount(count: String?) 

    /**
     * Set cart amount for using in real time in app comparisons
     */
    fun setCartAmount(amount: String?) 

    /**
     * Set state for using in real time in app comparisons
     */
    fun setState(name: String?) 

    /**
     * Set city for using in real time in app comparisons
     */
    fun setCity(name: String?) 

Google Tag Manager Implementation

You should use the interface CustomTagProvider.CustomTagProvider is automatically called by tag manager internal sdk.

The execute function provides the hashmap which then can be feeded to our sdk for event collection.

@Keep
class TagManager : CustomTagProvider {
    override fun execute(map: Map<String, Any>) {


        Log.d("tagRecieved", " $map")
        // you can use any of the two methods to send event based on your requirements


        Dengage.sendCustomEvent("Table Name", "key ", map as HashMap<String, Any>)


        Dengage.sendDeviceEvent("Table Name", map)
    }

    

    

For GTM integration please refer

https://developers.google.com/tag-platform/tag-manager/android/v5

https://developers.google.com/android/reference/com/google/android/gms/tagmanager/CustomTagProvider

Restarting Application

If anyone wishes not to restart application when application is in foreground then you can use the function

   Dengage.setCurrentActivity(this)
   Dengage.restartApplicationAfterPushClick(false)

Here the setCurrentActivity accepts the current activity. For example ,you want to open activity N then in the onCreate function of Activity N you can use Dengage.setCurrentActivity(this).

Set Development Status

If you wish to bypass all the delay and fetch times for inapp , you can use this function.

Dengage.setDevelopmentStatus(isDebug: Boolean? = false)

This however should be used when debugging not in production.


In App Inline

Dengage.showInlineInApp(propertyId:String, inAppInlineElement: InAppInlineElement, activity: Activity, customParams: HashMap<String, String>? = null, screenName: String?,  hideIfNotFound:Boolean? = false)

Here propertyID is the android selector that you will be placing while creating campaign.

InApp inline element is the view that you will be placing where inapp inline is to be shown.

custom params is the hashmap for custom params filter that you will be placing on the panel while creating campaign.

screen name parameter is when the inapp inline is to be shown on the specific screen.

hide if not found is a parameter where user can tell the sdk whether hide the view if inappinline is not found.



Pro guard rules

-keep class com.dengage.** { *;}

You can use the above pro guard rules if you face any error.
If you cannot log any data or witness sdk not calling any api then you need to add retrofit rules also as shown below.

https://github.com/square/retrofit/blob/trunk/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro

Sample App Content

1- Adding Manifest Rules of Sdk (See AndroidManifest)

2- Initiating Dengage Sdk (See
class App)

3- Push Notification Receiver (See
class PushNotificationReceiver)

4- Sending Page View Events (See
class BaseDataBindingFragment)

5- Showing Device Subscription Parameters (See
class DeviceInfoFragment)

6- Changing Contact Key (See
class ContactKeyFragment)

7- Listing Inbox Messages & Actions of Inbox Messages (See
class InboxMessagesFragment)

8- Sending Custom Events (See
class CustomEventFragment)

9- In App Message (See
class InAppMessageFragment)

10- Send Tags (See
class TagsFragment)

11- Show Dengage Test Page (See
class HomeFragment)

Migration From Old Sdk

You can follow the instructions on this documentation for migration from old sdk of Dengage.
Visit here