Teknasyon-Teknoloji / deepwall-android-sdk

Managing apps that offer in-app purchases have never been easier with Deepwall Android SDK

Home Page:https://docs.deepwall.com/sdk-framework/sdk-installation/install-android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeepWall Android SDK Usage

Implementation

Deepwall works with minSdkVersion 21

In your Project gradle

allprojects {
   repositories {
       google()
       jcenter()
       maven { url 'https://raw.githubusercontent.com/Teknasyon-Teknoloji/deepwall-android-sdk/master/' }
       maven { url 'https://developer.huawei.com/repo/' }
  }
} 
implementation 'deepwall:deepwall-core:2.6.6'

Google Implementation

If you use Deepwall SDK with Google services you should add google implementation too

implementation 'deepwall:deepwall-google:2.6.6'

Huawei Implementation

If you use Deepwall SDK with Huawei services you should add huawei implementation too

implementation 'deepwall:deepwall-huawei:2.6.6'

Initialize

The DeepWall library is started within the onCreate method of your application's launch activity class.

For Google

DeepWall.initDeepWallWith(
   platform = Platform.GOOGLE,
   activity = activity,
   apiKey = "DEEPWALL_API_KEY",
   environment = DeepWallEnvironment.PRODUCTION,
)

For Huawei

DeepWall.initDeepWallWith(
   platform = Platform.HUAWEI,
   activity = activity,
   apiKey = "DEEPWALL_API_KEY",
   environment = DeepWallEnvironment.PRODUCTION,
)
Parameters
platform Platform refers for GOOGLE or HUAWEI
activity Starting activity instance
apiKey DeepWall Api Key
environment DeepWall environment. You should use SANDBOX for test, PRODUCTION for prod

Configuration

DeepWall needs to know the following user properties for targeting.

Parameters
deviceId: String Unique identifier for specifying user profile or device.
Country : String Two-letter country code; Usage: DeepWallCountry.TURKEY // TURKEY
Language: String Two-letter language code; Usage: DeepWallLanguage.TURKISH // TURKISH
phoneNumber: String (Optional)
email: String (Optional)
firstName: String(Optional)
lastName: String(Optional)
Environment Style: DeepWallEnvironmentStyle Environment style for Paywall page appearance. Values: AUTOMATIC: Uses system appearance (Default) , LIGHT: Light appearance, DARK: Dark appearance

Important:

You must call Properties method before requesting any Paywall page.

DeepWall.setUserProperties( 
    deviceId = androidId, 
    languageCode = DeepWallLanguage.getLanguageCodeByName(DeepWallLanguage.ENGLISH_UNITED_STATES), 
    countryCode = DeepWallCountry.getCountryCodeByName(DeepWallCountry.UNITED_STATES_OF_AMERICA),
    environmentStyle = DeepWallEnvironmentStyle.DARK 
)

Updating User Properties

You could update the following user properties with DeepWall.updateUserProperties method.

Parameters
Country : String Two-letter country code; Usage: "TR" // TURKEY
Language: String Two-letter language code; Usage: "tr-tr" // TURKISH
Environment Style: DeepWallEnvironmentStyle Environment style for paywall page appearance. Values: AUTOMATIC: Uses system appearance (Default) , LIGHT: Light appearance, DARK: Dark appearance
phoneNumber: String (Optional)
email: String (Optional)
firstName: String (Optional)
lastName: String (Optional)
DeepWall.updateUserProperties(
   languageCode = "tr-tr", 
   countryCode = "TR"
   environmentStyle = DeepWallEnvironmentStyle.DARK  
)

Requesting Paywall Page

DeepWall.showPaywall(
  activity = this,
  action =ACTION_KEY”,
  orientation = PaywallOrientation.PORTRAIT
)
Parameters
activity Instance of the activity where the showPaywall method is called
action Action to be used for page display it is String value
orientation Orientation of the paywall (default Portrait)

Sending Extra Data

You could also use extraData parameter for sending extra data to paywall pages via Bundle.

For example Example model

val extraDataBundle = Bundle()
extraDataBundle.putString(“Name”, example.name)
extraDataBundle.putInt(“Id”, example.id)
DeepWall.showPaywall(
   activity = this,
   action =ACTION”,
   extraData = bundle,
   orientation = PaywallOrientation.PORTRAIT
)

Closing Paywall Page

You could use closePaywall method to close Paywall pages.

   DeepWall.closePaywall()

Custom Font Usage

If you want to use your app fonts in Paywalls You must have font directory in your res directory (android/res/font). After that you can use app fonts with DeepWall.

For the best performance you must call font function immediately after DeepWall initialization

   val fontFields = R.font::class.java.fields
   DeepWall.setFontFields(fontFields)

Consume Products

You can use consumeProduct method to consume your products.

DeepWall.consumeProduct(productId : String)

Subscription Upgrade/Downgrade

If you want to subscription upgrade or downgrade processes in your app you can use setProductUpgradePolicy method for general use

DeepWall.setProductUpgradePolicy(
  prorationType = ProrationType.IMMEDIATE_WITHOUT_PRORATION,
  upgradePolicy = PurchaseUpgradePolicy.ENABLE_ALL_POLICIES
)

If you have different policies for your products you can use updateProductUpgradePolicy method for your paywalls.

DeepWall.updateProductUpgradePolicy(
    prorationType = ProrationType.IMMEDIATE_WITHOUT_PRORATION,
    upgradePolicy = PurchaseUpgradePolicy.ENABLE_ALL_POLICIES)

For the detailed information about ProrationTypes you can see this document https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode

PurchaseUpgradePolicy
ENABLE_ALL_POLICIES All policies are open. Users can upgrade or downgrade their products
DISABLE_ALL_POLICIES All policies are closed. Users can not upgrade or downgrade their products
ENABLE_ONLY_UPGRADE Users can only upgrade their products
ENABLE_ONLY_DOWNGRADE Users can only downgrade their products

Event Handling

DeepWall posts some various events depending on ....

  • PAYWALL_OPENED Paywall opened event data as PaywallOpenedInfo Parameters : pageId: Int testInfo: PaywallTestInfo

  • CLOSED Paywall closed event data as PaywallClosedInfo Parameters : pageId: Int testInfo: PaywallTestInfo

  • PAYWALL_RESPONSE_FAILURE PAYWALL response failure event data as PaywallFailureResponse Parameters: errorCode: String reason: String testInfo: PaywallTestInfo

  • DO_NOT_SHOW Paywall action show disabled event data as PaywallActionShowDisabledInfo Parameters: pageId : Int

  • PAYWALL_PURCHASING_PRODUCT Paywall purchasing product event data as PaywallPurchasingProductInfo Parameters: productCode: String testInfo: PaywallTestInfo

  • PAYWALL_PURCHASE_SUCCESS Purchase success event. Fired after receipt validation if Ploutos service active.

val subscriptionResponse = it.data as SubscriptionResponse

Parameters: type : DeepWallReceiptValidationType result : SubscriptionDetail -subscriptions : Array of PurchaseSubscriptionItem -products : Array of String

  • PAYWALL_PURCHASE_FAILED Purchase failed event
val data = it.data as SubscriptionErrorResponse

Parameters: type : DeepWallReceiptValidationType result : String

  • EXTRA_DATA Extra data received event Parameters:Any

  • PAYWALL_REQUESTED Fired after paywall requested. Useful for displaying loading indicator in your app.

  • PAYWALL_RESPONSE_RECEIVED Fired after paywall response received. Useful for hiding loading indicator in your app.

  • PAYWALL_NOT_OPENED Fired if your product list is empty.

  • CONSUME_SUCCESS Fired after consume product request success

  • CONSUME_FAILURE Fired after consume product request failure

Test Info

Some events provides info about related test. To check test info snipped below can be used. Which events provides event info is listed in event list.

val eventData = it.data
if(eventData is TestEvent){
    Log.d("DeepWall","${data.testInfo}")
}

Usage Example

EventBus.subscribe(Consumer { 
when(it.type){
   DeepWallEvent.EXTRA_DATA.value -> { 
   Toast.makeText(this, it.data.toString(), Toast.LENGTH_SHORT).show() } 

DeepWallEvent.CLOSED.value ->  {
val data = it.data as PaywallClosedInfo
Toast.makeText(this@MainActivity, "PAYWALL_CLOSED : ${data.pageId}", Toast.LENGTH_LONG).show() }


DeepWallEvent.PAYWALL_PURCHASE_SUCCESS.value -> {
val subscriptionResponse = it.data as SubscriptionResponse
subscriptionResponse.result.subscriptionList.forEach { subItem->
   if(subItem.isActive == 1){
       //Do something
   }
       }
DeepWall.closePaywall()
}

DeepWallEvent.PAYWALL_OPENED.value -> { 
val data = it.data as PaywallOpenedInfo
Toast.makeText(this@MainActivity, "PAYWALL OPENED : ${key.pageId}", Toast.LENGTH_LONG).show() } 
}})

Changing ExoPlayer Version

DeepWall is shipped with ExoPlayer 2.18.1. If other versions of ExoPlayer required, deepwall-video package should be excluded and compatible version of deepwall-video should be added.

implementation('deepwall:deepwall-core:2.6.6'){
    exclude group: 'deepwall', module: 'deepwall-video'
}
implementation('deepwall:deepwall-video:DEEPWALL_VIDEO_VERSION')

DeepWall Video package versions and corresponding ExoPlayer versions are listed below

DeepWall Video ExoPlayer
2.13.2.0 2.13.2
2.14.2.0 2.14.2
2.15.1.0 2.15.1
2.16.1.0 2.16.1
2.17.1.0 2.17.1
2.18.1.0 2.18.1

About

Managing apps that offer in-app purchases have never been easier with Deepwall Android SDK

https://docs.deepwall.com/sdk-framework/sdk-installation/install-android