diff --git a/inappmessaging/USERGUIDE.md b/inappmessaging/USERGUIDE.md index ced8bd9e..da127f0b 100644 --- a/inappmessaging/USERGUIDE.md +++ b/inappmessaging/USERGUIDE.md @@ -12,7 +12,6 @@ In-App Messaging (IAM) module allows app developers to easily configure and disp * [SDK Integration](#integration) * [SDK Logic](#logic) * [Advanced Features](#advanced) -* [Final Code (Sample)](#final-code) * [Troubleshooting](#troubleshooting) * [FAQ](#faq) * [Documentation and Useful Links](#see-also) @@ -26,6 +25,96 @@ This SDK supports Android API level 23 (Marshmallow) and above. You must have a subscription key for your application from IAM Dashboard. ## SDK Integration + +### Final Code Preview (Sample) + +By the end of this integration guide, the final code should basically look something like this: + +
+(click to expand) + +AndroidManifest.xml +```xml + + + + + +``` + +MainApplication.kt +```kotlin +class MainApplication: Application() { + + override fun onCreate() { + InAppMessaging.configure(this) + InAppMessaging.instance().registerPreference(YourUserInfoProvider()) + } +} +``` + +YourUserInfoProvider.kt +```kotlin +class YourUserInfoProvider: UserInfoProvider() { + + // Update during login or logout + var userId = "" + var accessToken = "" + var idTracking = "" + + override fun provideUserId() = userId + + override fun provideAccessToken() = accessToken + + override fun provideIdTrackingIdentifier() = idTracking +} +``` + +MainActivity.kt +```kotlin +class MainActivity: AppCompatActivity(), View.OnClickListener { + + override fun onStart() { + super.onStart() + InAppMessaging.instance().logEvent(AppStartEvent()) + } + + override fun onResume() { + super.onResume() + InAppMessaging.instance().registerMessageDisplayActivity(this) + } + + override fun onPause() { + super.onPause() + InAppMessaging.instance().unregisterMessageDisplayActivity() + } + + fun onUserLogin() { + // When user logins successfully + InAppMessaging.instance().logEvent(LoginSuccessfulEvent()) + } + + override fun onClick(v: View) { + // Log the events based on your use-cases + + when (v.id) { + R.id.purchase_button_tapped -> InAppMessaging.instance().logEvent(PurchaseSuccessfulEvent()) + + R.id.home_tab_tapped -> InAppMessaging.instance().logEvent(CustomEvent("tab_visit").addAttribute("tab_name", "home")) + + R.id.cart_tab_tapped -> InAppMessaging.instance().logEvent(CustomEvent("tab_visit").addAttribute("tab_name", "cart")) + } + } +} +``` +
+ ### #1 Include Maven Central repo in your project, this should be added in your project root `build.gradle` file. ```groovy @@ -130,6 +219,7 @@ class MainApplication : Application() { **Notes:** * Missing Subscription Key or other critical information are some of the possible issues that can be encountered during configuration. * If `configure()` is not called, subsequent calls to other public API SDK functions have no effect. +* To enable [tooltips](#tooltip-campaigns) (beta feature) you must set `enableTooltipFeature` flag to true. ### #6 Registering and unregistering activities. Only register activities that are allowed to display In-App messages. Your activities will be kept in a `WeakReference` object, so it will not cause any memory leaks. Don't forget to unregister your activities in `onPause()` method. @@ -417,85 +507,6 @@ override fun onRequestPermissionsResult(requestCode: Int, permissions: ArrayFinal Code (Sample) - -The final code should basically look something like this: - -
-(click to expand) - -MainApplication.kt -```kotlin -class MainApplication: Application() { - override fun onCreate() { - InAppMessaging.configure(this) - InAppMessaging.instance().registerPreference(YourUserInfoProvider()) - } -} -``` - -YourUserInfoProvider.kt -```kotlin -class YourUserInfoProvider: UserInfoProvider() { - - // Update during login or logout - var userId = "" - var accessToken = "" - var idTracking = "" - - override fun provideUserId() = userId - - override fun provideAccessToken() = accessToken - - override fun provideIdTrackingIdentifier() = idTracking -} -``` - -MainActivity.kt -```kotlin -class MainActivity: AppCompatActivity(), View.OnClickListener { - - override fun onStart() { - super.onStart() - InAppMessaging.instance().logEvent(AppStartEvent()) - } - - override fun onResume() { - super.onResume() - InAppMessaging.instance().registerMessageDisplayActivity(this) - } - - override fun onPause() { - super.onPause() - InAppMessaging.instance().unregisterMessageDisplayActivity() - } - - fun onUserLogin() { - // When user logins successfully - InAppMessaging.instance().logEvent(LoginSuccessfulEvent()) - } - - override fun onClick(v: View) { - // Log the events based on your use-cases - - when (v.id) { - R.id.purchase_button_tapped -> InAppMessaging.instance().logEvent(PurchaseSuccessfulEvent()) - - R.id.home_tab_tapped -> InAppMessaging.instance().logEvent(CustomEvent("tab_visit").addAttribute("tab_name", "home")) - - R.id.cart_tab_tapped -> InAppMessaging.instance().logEvent(CustomEvent("tab_visit").addAttribute("tab_name", "cart")) - } - } -} -``` -
- ## Troubleshooting ### Proguard ParseException ```kotlin