Guide to migrate to v2 of the iOS SDK for Loyalty applicationsImprove this page
This is a guide to help you migrate from version 1.x.x of the Fidel API iOS SDK to version 2.0.0.
Update your Fidel API iOS SDK integration
If you used Cocoapods to integrate iOS SDK
Update to v2 of the iOS SDK by running the following Cocoapods command, from the root folder of your Xcode project.
12pod update Fidel
You should see in the log the version to which the iOS SDK is updated to.
If you manually integrated the iOS SDK
- Download the latest
Fidel.xcframework
andanalytics.xcframework
artifacts from the iOS SDK GitHub repo. - Replace your existing
Fidel.xcframework
with the one you downloaded. - Add the
analytics.xcframework
to your project.
Check the following code as your migration guide
Use the following code as a guide related to the changes that to integrate with the Fidel API SDK:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. configureFidel() return true } private func configureFidel() { // We recommend storing the SDK key on your server. Please use one of your endpoints to // retrieve it and then configure the sdkKey property with it. Fidel.sdkKey = yourSDKKey //was apiKey Fidel.programID = "Your program ID" //was programId Fidel.bannerImage = UIImage(named: "fdl_test_banner") // Remove Fidel.autoScan Fidel.metaData = [ "id": "this-is-the-metadata-id", "myUserId": 123, "myUserId2": 123.3, "myUserId3": [12, nil], "myUserId4": ["subkey": 12.2, "subkey2": true], "customKey1": "customValue1" ] Fidel.allowedCountries = [.canada, .unitedStates] Fidel.companyName = "Cashback Inc." Fidel.privacyPolicyURL = "https://www.fidel.uk/" // was privacyURL Fidel.termsAndConditionsURL = "https://fidel.uk/docs/" //was termsConditionsURL Fidel.deleteInstructions = "contacting our support team" Fidel.supportedCardSchemes = [.visa, .mastercard, .americanExpress] Fidel.onResult = self.onResult // result callback } func onResult(_ result: FidelResult) { switch result { case .enrollmentResult(let enrollmentResult): print(enrollmentResult.cardID) case .error(let fidelError): switch fidelError.type { case .enrollmentError(let enrollmentError): switch enrollmentError { case .cardAlreadyExists: print("card was already enrolled") default: print("other enrollment error") } case .sdkConfigurationError: print("the SDK should be provided with all the information") case .userCanceled: print("the user cancelled the flow") case .deviceNotSecure: print("the device you’re using is not secure") @unknown default: print("unknown error") } @unknown default: print("unknown result") } } }
Starting the card-linking flow
On any action that you want (on a tap of a button, for example), add the following code:
12Fidel.start(from: yourViewController)
The Fidel.start
method replaces the previous: Fidel.present
method. To get notified about card enrollment events, you ca use the Fidel.onResult
callback. Please check our v2 Reference documentation for more details.