The SDK can be configured when the application starts (in AppDelegate’s application: didFinishLaunchingWithOptions method for UIKit framework or in @main App’s init method for SwiftUI framework).
DateioSdkApp is a singleton object. Configure method should be called only once in the application.
Basic API parameters can be changed using the DateioSdkApiConfiguration protocol. You can change API server URL host or request headers (add custom Authorization header etc.).
Make sure that you set deviceHttpRequestHeaders parameters correctly, as this will help us solve potential issues and identify requests by platform. mobile ios 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.
There are two ways to pass an access token in the request header.
The first one is more suitable for testing purposes or if the token has a long-term validity. Just pass the token within the DateioSdkApiConfiguration protocol in the httpRequestHeaders variable.
The second, dynamic approach uses the getRequestHeaders function of the DateioSdkApiConfiguration protocol.
This method is called before each request and waits for the request headers to be passed in, which are then passed in the request. Within this method, other services can be called asynchronously to receive the token. It is good practice to cache the data (if the token expiration is known) and not call the services every time.
You can also use func getRequestHeaders(requestInfo: [String: String?], completion: @escaping ([String : String]) -> Void) when you need requests info that SDK generate. Eg. for PowerAuth.
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. Use it in DateioSDKApp.shared.configure(apiErrorCallbackConfiguration:) call.
Will register user on Dateio BE. This call is intended to be used once the user give all consents with program usage. Return true / false based on result. For details see user consents section.
Will delete user on Dateio BE. Return true / false based on result. For details see user consents section.
Will logout user on Dateio BE. Return 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 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 configuration object. Call this function when user logs out from bank application. This will clear the SDK configuration and all its information. When this function is called, you will have to configure the SDK again in further usage.
Will return number of new offers for user. This is intended for “red dot” use case.
Will use this SSL hashes for given domains. SDK will not trust to other certificates. Use it in DateioSDKApp.shared.configure(apiConfiguration:) call.
You can pass data from push notifications via this method to SDK. SDK will perform given action e.g. redirect to detail and delete passed data. notification is DateioSDKShared.Notification object with two parameters. Notification type enum NotificationType and objectId (In some cases you need to pass objectId so SDK knows which offer or category should be redirected.). Function return Bool value which correspond to process success.
For example:
Notifications can trigger the following types of actions:
openOffersList - will open SDK on offer list. Same if you navigate to SDK without processNotification.openOfferDetail - will open offer detail. Need pass objectId as offer id.openOfferHistory - will open user history with transactions.openOfferCategory - will open offers list in given category. Need pass objectId as category id.openOfferMap - will open a map with offers on it.activateOffer - 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.This method is intended mainly for push notifications but might be used as well for in-app banners and others.
Configuration.BankLoggerConfiguration file is Protocol ConfigurationBankLoggerCallback implementation. It allows set custom logging for actions which happen inside the SDK. In the protocol, it is necessary to implement function func logAction(AnalyticsAction: String, AnalyticsOrigin: String?, id: String?, info: String?)which is called on user activity.
Inside the SDK, the logging function is called like asynchronous Task without a try block, as its behavior needs to be implementation-specific.
You also need to handle error states appropriately in this function.
AnalyticsAction.PAGE_ENTER and AnalyticsAction.PAGE_LEAVE actions are called when .onAppear or .onDisappear event starts on a page view.
Will enable only some offer types - you might use values defined in DateioSDKShared.OfferType. Use it in DateioSDKApp.shared.configure(apiConfiguration:) call.
This method should be used only after consultation with Dateio as this will reduce number of available offers.
You can change SDK API version. In case you change the API version, warning will be logged, since this should be used only in edge cases. Use it in DateioSDKApp.shared.configure(apiConfiguration:) call.
This parameter should be used only after consulting with Dateio in advance, since it might cause errors when set incorrectly.
The SDK supports system applications chooser when user clicks on store in offer detail. If the user has installed any of these applications:
Chooser will be shown with available options. To use this feature, you need to add the following code to Info.plist:
By this point you are able to load offers and other data for given user. Now, you can continue to last step - SDK customization to get same look and feel as your app.