dependencies {
implementation 'com.github.dengage-tech:dengage-android-sdk:6.0.104'
}
For latest Android SDK click
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.
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.hms.HmsMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
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>
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())
Should be called once in application lifecycle for initiation of Dengage sdk. You can place it into
Application class onCreate method.
init(
context: Context,
firebaseIntegrationKey: String? = null,
huaweiIntegrationKey: String? = null,
firebaseApp: FirebaseApp? = null,
dengageHmsManager: IDengageHmsManager? = null,
deviceId: String? = null,
deviceConfigurationPreference: DeviceConfigurationPreference? = DeviceConfigurationPreference.Google,
contactKey: String? = null,
partnerDeviceId: String? = null,
disableOpenWebUrl:Boolean? =false,
notificationDisplayPriorityConfiguration: NotificationDisplayPriorityConfiguration =NotificationDisplayPriorityConfiguration.SHOW_WITH_DEFAULT_PRIORITY
)
e.g :
val dengageHmsManager = DengageHmsManager()
Dengage.init(
context = context,
firebaseIntegrationKey = Constants.FIREBASE_APP_INTEGRATION_KEY,
dengageHmsManager = dengageHmsManager,
deviceConfigurationPreference = DeviceConfigurationPreference.Huawei,
disableOpenWebUrl = false,
notificationDisplayPriorityConfiguration = NotificationDisplayPriorityConfiguration.SHOW_WITH_HIGH_PRIORITY
)
to start geofence
DengageGeofence.startGeofence()
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
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 */
)
You can also set your Dengage firebase app integration key after sdk initiation.
Dengage.setFirebaseIntegrationKey(
integrationKey: String /* Your Dengage firebase app integration key */
)
You can also set your Dengage huawei app integration key after sdk initiation.
Dengage.setHuaweiIntegrationKey(
integrationKey: String /* Your Dengage huawei app integration key */
)
You can get Dengage sdk subscription model from sdk cache if exists (If you init correctly, it will
exist).
Dengage.getSubscription(): Subscription?
You can set country of current user subscription.
Dengage.setCountry(
country: String /* Free country text */
)
You can set contact key of current user subscription.
Dengage.setContactKey(
contactKey: String? /* User key */
)
You can set user permission of current user subscription.
Dengage.setUserPermission(
permission: Boolean /* User permission flag */
)
You can get user permission of current user subscription.
Dengage.getUserPermission(): Boolean?
You can set firebase or huawei messaging token of current user subscription.
Dengage.setToken(
token: String? /* Firebase or huawei messaging token */
)
You can get token of current user subscription.
Dengage.getToken(): String?
You can set firebase or huawei messaging token of current user subscription.
Dengage.onNewToken(
token: String? /* Firebase or huawei messaging token */
)
You can set notification channel name for setting to notifications above android 26.
Dengage.setNotificationChannelName(
name: String /* Notification channel name */
)
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 */
)
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 */
)
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 */
)
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 */
)
You can call this method for showing in app message popup if exists.
Dengage.setNavigation(
activity: Activity /* For showing ui of in app message */
)
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 */
)
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 */
resultCode:Int , /*result code to get the intent*/
//
Dengage.setNavigation(
activity: Activity, /* For showing ui of in app message */
resultCode:Int /*result code to get the intent*/
To set deeplink in the sdk you can use the link
Dengage.inAppLinkConfiguration(inappDeeplink:String)
You can send tag items to Dengage api.
Dengage.setTags(
tags: List<TagItem> /* TagItem list that you want to send Dengage api */
)
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 */
)
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;
Dengage.showTestPage(
activity: Activity /* For showing ui of test pages */
)
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 */
)
)
You can update rfm score of viewed category.
Dengage.categoryView(
categoryId: String /* Category identifier of viewed category */
)
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
)
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?
)
You can sync adjust adid with dengage through the following method
Dengage.setPartnerDeviceId(adid:String)
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?)
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
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).
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.
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.
showStoriesList(
storyPropertyId: String,
storiesListView: StoriesListView,
activity: Activity,
customParams: HashMap<String, String>? = null,
screenName: String?
)
here StoriesListView view can be found in
com.dengage.sdk.ui.story.StoriesListView
Here propertyID is the story property id that you will be placing while creating campaign.
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.
-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.
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)
You can follow the instructions on this documentation for migration from old sdk of Dengage.
Visit here
Source: dev.dengage.com