Skip to content

Custom Callbacks

In certain circumstances, it may be desirable for an action within the SDK to trigger another action within your application. Two examples of how different partners have leveraged this functionality are described below:

  1. A partner with a new card product created a custom banner asset to promote the card offering. That banner was then configured to appear within the offers feed shown by the SDK. Upon a user tapping the banner within the SDK, a callback was sent to the partner application to inform them of the tap event. At this point the partner chose to dismiss the SDK and redirect the user into their card acquisition flow.
  2. A partner had a custom offer type that allowed their users to pay by scanning a QR code at the payment terminal. When looking at an offer's details within the SDK their users could tap the "Scan" button that, in turn, triggered a callback to the partner application allowing them to present the device's camera view so the user could check out by scanning the code at the register.


Configuring callback functionality is a joint effort between Cardlytics and the partner to:

  1. Determine the use case and ruleset for when a callback should be triggered
  2. Agree on a contract for the callback including the specific callback name
  3. Implement the logic to trigger the callback (Cardlytics) and to handle the callback once triggered (partner)


Once the previously defined steps have been discussed and decided upon, partners can implement code allowing them to receive the callback and perform an associated action. Note that the SDK requires that you provide an array of callbacks that are expected by your app. This allows the SDK to manage backwards compatibility by automatically hiding any items which are associated with an unsupported callback. The following code samples demonstrate partner code for supporting and acting on a custom callback called "my_custom_feature".

To support this in your iOS app, pass in an array of supported callbacks and implement the DoshCallbackDelegate.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dosh.supportedCallbacks = ["my_custom_feature"]
dosh.callbackDelegate = self

func didReceiveCallback(from dosh: Dosh, name: String, payload: String?) {
    // Note: Dismissing the SDK is optional
    dosh.dismiss(animated: true) {
        if name == "my_custom_feature" {
            // Present your custom feature
        }
    }
}

To support this in your Android app, invoke the setSupportedCallbacks method and pass in a list of supported callbacks and an instance of DoshCallbackInterface.

1
2
3
4
5
6
7
8
PoweredByDosh.instance?.setSupportedCallbacks(listOf("my_custom_feature"), this) // THIS implements DoshCallbackInterface

override fun onCallBackTrigger(name: String, payload: String?): Boolean {
    if (name == "my_custom_feature") {
        // Present your custom feature
    }
    return true // return true to dismiss the activity, false to keep it in the backstack
}