Preferences
Introduction
The Preferences Service enables developers to fetch all user-defined and marketing preferences as well as a way to update them.
Key Features:
- Offers a way to fetch all user-defined and marketing preferences.
- Supports a way to update the user-defined and marketing preferences.
Prerequisites
Before integrating the Preferences Service, ensure you have:
- A valid Paysafe account with appropriate permissions.
- Set up instructions for Paysafe SDK Android or iOS.
To get started, initialize the PreferencesService
instance in your app as shown below:
- Kotlin
- Swift
import com.paysafe.wallet.android.core.wallet.Wallet
val preferencesService = Wallet.getInstance().getPreferencesService()
import PaysafeWallet
let preferences = Wallet.instance.preferencesService
Functionalities
Get Preferences
- Kotlin
- Swift
Use get
method to retrieve the user-defined and marketing Preferences.
val preferences = preferencesService.get()
Use get
method to retrieve the user-defined and marketing Preferences.
preferencesService.get(completion: { result in
switch result {
case .success(let preferences):
// Display preferences
case .failure(let error):
// Handle error
}
})
Update Preferences
- Kotlin
- Swift
Use the update
method to update the user-defined and marketing preferences by providing a Preferences object.
val updatedPreferences = Preferences(
marketing = MarketingPreferences(
receivePushNotifications = true,
receiveMarketingEmails = true,
receiveMarketingSms = true,
receiveSocialAds = false,
receiveTargetedAds = false,
receiveThirdPartyAds = false,
),
data = DataPreferences(
consentForTargetedAds = true,
consentForAnalytics = false,
consentForPerformanceTracking = true
)
)
val preferences = preferencesService.update(preferences: updatedPreferences)
Use the update
method to update the user-defined and marketing preferences by providing a Preferences object.
let updatedPreferences = Preferences(
marketing = MarketingPreferences(
receivePushNotifications = true,
receiveMarketingEmails = true,
receiveMarketingSms = true,
receiveSocialAds = false,
receiveTargetedAds = false,
receiveThirdPartyAds = false,
),
data = DataPreferences(
consentForTargetedAds = true,
consentForAnalytics = false,
consentForPerformanceTracking = true
)
)
preferencesService.update(preferences: updatedPreferences, completion: { result in
switch result {
case .success(let preferences):
// Display preferences
case .failure(let error):
// Handle error
}
})