When you have successfully added the SDK screen into your app, you will need to configure the SDK. Configuration will ensure the proper URL and headers are in use.
First, you will need to set your Bank BE URL via Configuration.api.urlHost = "https://your_bank_BE". For security reasons make sure that the connection use HTTPS, otherwise an exception will be thrown.
Next, set your app identification like this:
Make sure that you set these parameters correctly, as this will help us solve potential issues and identify requests by platform. mobile android is a static value and should not be changed. BANK_NAME_APP [version X.Y.Z] should contain your application or bank name and app version. The exact format is not required and depends on your preferences. Setting user device information is also helpful.
By Configuration.setIsLocationEnabled(bool) you will set up if to use user location or not. For this purpose, we use standard Google Play services. User need to grant permission to it, if it was not given before.
Authorization is done by setting user authentication in the headers. This header is configurable by name and value. Format of this header depends on the bank’s preferences and infrastructure (see Communication with bank backend and Dateio API). SDK offers two methods for user identification. One for long-lasting tokens and another for short-lived ones.
For long-lasting tokens headers can be set as follows:
If your token needs to be refreshed (e.g. they are valid only a few minutes), you should use this method instead:
Where you can pass callback function, that’s return a map of headers that you want to set.
You can also use Configuration.setRefreshAuthHeadersCallback(callback: suspend (requestInfo: Map<String, String?>, authHeaders: (Map<String, String>) -> Unit) -> Unit) when you need requests info that the SDK generate. E.g. for PowerAuth.
Please note that this function is called before all requests. So, in this callback you should call your API / do refresh only if it's really needed, otherwise use the present token.
When you are configuring user tokens, you might add the "Accept-Language" to Locale.getDefault().language to set user preferred language. When an offer is available in this language, the API will return it instead of the default one.
This section describes other SDK functions and settings.
You can set a callback in case an API error occurs. This callback has two methods, one specifically for 401 authentication error and the other one for all the other types of errors:
Will register user on Dateio BE. This call is intended to be used once the user gives all consents with program usage. Returns true / false based on result. For details see user consents section.
Will delete the user on Dateio BE. Returns true / false based on result. For details see user consents section.
Will logout user on Dateio BE. Returns true / false based on result.
To load cashback history totals outside of SDK screens use this method. This method returns a CashbackHistoryTotals object with the following parameters:
When you use this function you must authenticate the user before navigating within the SDK. This function should only be used for registered users.
Example how to use this function:
Will free up all resources in the configuration object. Call this function when user logs out from bank application. This will clear SDK configuration and all its information. When this function is called, you will have to configure the SDK again for further use.
Will return number of new offers for user. This is intended for “red dot” use case.
Will use SSL hashes for the given domains. SDK will not trust other certificates. Please note, that when you set this parameter, you won't be able to use Configuration.sslInterceptor and Configuration.sslNetworkInterceptor. Interceptors will be ignored in this case.
This parameter should be used when you are targeting Android version below 24 as it is not possible to use network-security-config.
You can set Interceptors with this when you need to use Certificate Transparency. Internally we set all interceptors as addInterceptor(it) and addNetworkInterceptor(it) fromOKHttpClient. These parameters will be ignored when you use Configuration.sslPins.
You can pass data from push notifications via this method to SDK. SDK will perform the given action e.g. redirect to detail and delete passed data. type is eu.dateio.dateiosdkmutliplatform.modules.offer.data.models.Notification instance defined by enum from NotificationType e.g. Notification(NotificationType.OPEN_OFFER_DETAIL, objectId = 16698940774). In some cases you need to pass objectId so SDK knows which offer or category should be redirected.
Notifications can trigger the following types of actions:
OPEN_OFFERS_LIST - will open SDK on offer list. Same if you navigate to SDK without processNotification.OPEN_OFFER_DETAIL - will open offer detail. Need pass objectId as offer id.OPEN_OFFER_HISTORY - will open user history with transactions.OPEN_OFFER_CATEGORY - will open offers list in given category. Need pass objectId as category id.OPEN_OFFER_MAP - will open a map with offers on it.ACTIVATE_OFFER - use this type when you want directly activate offer without navigating to SDK. Need pass objectId as offer id. Note that you will still need to authenticate the user as usual.When you set notification type OPEN_X then you just need to navigate into to SDK via handler. No other actions are needed and handler can be something like switchToSDK(). If you use ACTIVATE_OFFER your handler should perform activation itself via activationUseCase.executeDispatched(offerId, ActivationOfferSource.NOTIFICATION, Dispatchers.IO). This async function returns activated offer or null if activation failed.
This method is intended mainly for push notifications but might be used as well for in-app banners and others.
Allows the use of custom bank analytics based on user actions as described in the overview section. You need to override logAction(action: AnalyticsAction, origin: AnalyticsOrigin?, id: String?, info: String?) with custom logging e.g. batch logging, one action / one request logging or third-party solution.
It is important that this override in bank application offloads time-consuming actions like HTTPS requests from the UI thread otherwise it will block the application. For example with CoroutineScope(Dispatchers.IO).launch. You also need to handle error states appropriately. As Dateio doesn’t know how bank will implement custom logging it is not possible to do this in the SDK. Basically logAction is called inside SDK like this Configuration.getBankLoggerCallback?.logAction(...) without try or CoroutineScope change.
AnalyticsAction.PAGE_ENTER and AnalyticsAction.PAGE_LEAVE actions are called inside ViewModels in onPause and onResume. These ViewModels are observed via DefaultLifecycleObserver in SDK screens.
Will enable only some offer types - you might use values defined in eu.dateio.dateiosdkmutliplatform.modules.offer.data.models.OfferType.
This method should be used only after consultation with Dateio as this will reduce number of available offers.
You can change SDK API version via Configuration.api.version = numericVersion. In case you change the API version, a warning will be logged, since this should be used only in edge cases.
This parameter should be used only after consulting with Dateio in advance, since it might cause errors when set incorrectly.
By that you might sort blocks in offer detail screen. Dateio will provide configuration based on the agreed UI. Detail will be sorted by the exact same order as set in these lists. Some parts might be disabled when they are not in list. Only OfferDetailMainParts and OfferDetailHeaderParts values can be used.
You can set tutorial type with this. SDK supports these values:
FOUR_OVERLAY_PAGES - there will be four overlay tutorials on homepage when user starts app for the first time.HOW_IT_WORKS_WIDGET - there will be widget with info on how program work above offers list. It will be shown until the user have some cashback.NONE - there will be no tutorial. Default value.You can set type for how it works bottom sheet with this. SDK supports these values:
BIG_WITH_IMAGES - bottom sheet with big images.BIG_WITH_OVERLAPPING_IMAGES - bottom sheet that has images overlaying text. Useful when you want to show steps like 1, 2, 3.SIMPLE_TEXT - simple bottom sheet with text only. Default value.You can set list of tags for offers to match this to allowed offers to the client. This might be useful when you have e.g. retail and SME users.
This method should be used only after consultation with Dateio as this will reduce the number of available offers.
Callback for showing / hiding the tab bar in your host app. Tabbar is shown only on offers list when bottom sheet is not open. Otherwise it is hidden. You might use it like this:
By this point you will be able to load offers and other data for given user. Now, you can continue to last step - SDK customization to get the same look and feel as your app.