Connect SDK 7.4 migration guide for the iOS platform
Several changes were introduced in the new Pega® Mobile SDK 7.4 version which includes the Connect SDK. This article will help you migrate your application from an old version of the Connect SDK to the current version.
API changes
- The
PMPegaConfig
class is not available. - You must change all code snippets that include
PMPegaConfig
and the previous version ofPMPegaApi
to:PMPegaApi(serverURL: URL)
orPMPegaApi(serverURL: URL, urlSession: URLSession)
settingserverURL
on thePMPegaAPI
object. Please note thatPMPegaApi
is not a singleton. - For the authentication header functionality, you can use the new
setAuthenticationHeader(header: string)
method. - The
PMDataPage
class is available in the Connect SDK. It is used to create a datapage instance instead of creating a map by using ([String: Any]
). - You can register for push notifications by using a new method for the
PMAuthentication
class:func registerPushNotification(serverURL: URL, user: String, password: String, deviceToken: Data, completionHandler: @escaping (Error?) -> Void)
.
Code example of how to authenticate to Pega Platform with the Connect SDK for iOS is shown below:
let urlString = "http://sample.pega.com:8080/prweb/api/v1"; guard let serverURL = URL(string: urlString) else { fatalError("Please set valid url for Pega API") } let pegaapi = PMPegaApi(serverURL: serverURL)
You now logout from Pega Platform in the Connect SDK in the following way: PegaApi.shared.authenticationService.logout()
You can also set your own instance of the URLSession
during the creation of a new PMPegaApi
instance by using the following initializer function: PMPegaApi(serverURL: URL, urlSession: URLSession)
CocoaPods support
The previous versions of Connect SDK for iOS were based on CocoaPods and additional libraries. One of these libraries forced completionHandlers
to always run on the main queue called DispatchQueue.main
. You were required to do this in your code directly. This functionality was removed in the new Connect SDK version since you may use the Connect SDK with an application that does not contain a user interface or you may want to control what is executed from the main queue.
DispatchQueue.main
on all the user interface components.To learn more about Xcode project configuration for the iOS platform, see Adding the Connect SDK as framework.