2.3.0
SwedbankPaySDKController now support view controller state restoration. If your app uses state restoration, you can assign a restoration identifier to the SwedbankPaySDKController to have it participate. The state restoration is a best-effort business, and will currently result in reloading the payment menu for the ongoing payment.
To support state restoration, a new API for SwedbankPaySDKController has been introduced. Previously you would create a SwedbankPaySDKController by calling .init(configuration:withCheckin:consumer:paymentOrder:userData:)
This initializer is still available, but will not work with state restoration. Instead, create the SwedbankPaySDKController by calling the no-argument initializer or instantiate it from a storyboard. Then, start the payment by calling startPayment(withCheckin:consumer:paymentOrder:userData:)
. The configuration cannot be passed as an argument here; rather, you should set it as SwedbankPaySDKController.defaultConfiguration
. If your application requires both state restoration and multiple configurations, you need to subclass SwedbankPaySDKController and overrider the configuration
property accordingly.
Note that if you use state restoration and pass a userData
argument, that argument must conform to either NSCoding
or Codable
, and to use a Codable
userData, you must first register the type with SwedbankPaySDK.registerCodable
. The same is true for any value your configurations sets as ViewPaymentOrderInfo.userInfo
. Both this registration and setting SwedbankPaySDKController.defaultConfiguration
should happen before any state restoration is done; the best place is in UIApplicationDelegate.application(_:willFinishLaunchingWithOptions:)
.