Preferences
Introduction
The Preferences service enables users to view their preferences, offering a straightforward way to understand the settings related to tracking and promotional communications. These preferences are organized into distinct categories:
- Data Preferences: Manage and track the user consent for tracking, ensuring compliance with privacy regulations while enabling personalized experiences.
- Marketing Preferences: Manage and track user consent for receiving promotional communications, ensuring targeted outreach while respecting user choices and privacy regulations.
Key Features:
- Get all preferences.
- Update user's 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 data and marketing Preferences.
val preferences = preferencesService.get()
Use get method to retrieve the data 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 data 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 data 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
}
})