PingOne Protect SDK for iOS
PingOne Signals (Protect) SDK for iOS (version 5.3.0)
Using the iOS version of the SDK involves the following steps:
-
Adding the SDK to your app using CocoaPods or Swift Package Manager
-
Importing the SDK module
-
Initializing the SDK
-
Getting the data for risk assessment
Adding the SDK to your app
Adding the SDK to your app using CocoaPods
If you’re new to CocoaPods, refer to the official documentation for information on how to create and use Podfiles.
Open your project’s Podfile and add the following to your app’s target:
|
Update the pod version to match the version of the PingOne Signals SDK for iOS that you are using. Currently the latest version is 5.3.0. |
pod 'PingOneSignals', '~> 5.3.0'
Run pod install from the command line:
pod install
Adding the SDK to your app using Swift Package Manager
-
Select File > Add Packages… in Xcode’s menu bar.
-
Search for the PingOne Signals SDK using the repo’s URL: https://github.com/pingidentity/pingone-signals-sdk-ios
-
Set the Dependency Rule to Branch with the value 'main' or select an exact version, and make sure that
Add to Projectis set to your project. -
Select
Add Package. -
Verify that the package was downloaded in your project.
SDK initialization
Initialize the SDK. You’ll typically do this in your app’s application:didFinishLaunchingWithOptions: method, or any other entry point during your application launch. For example:
import PingOneSignals
let initParams = POInitParams()
initParams.envId = <envId> // optional
// If you are using the PingFed authentication API and version 1.3 of the Integration Kit, uncomment the following line to turn off the collection of behavioral data
// initParams.behavioralDataCollection = false
let pingOneSignals = PingOneSignals.initSDK(initParams: initParams)
pingOneSignals.setInitCallback { error in
if let error = error {
print("Init failed - \(error.localizedDescription)")
} else {
print("SDK Initialized")
}
}
|
The code above contains the String placeholder < |
Optionally, set an event listener to get calls on successful or failed SDK initialization.
Getting the data for risk assessment
Get the data for risk assessment by adding a call to the SDK’s getData method, for example:
import PingOneSignals
let pingOneSignals = PingOneSignals.sharedInstance()
pingOneSignals?.getData { data, error in
if let data = data {
print("data: \(data)")
} else if let error = error {
print("error getting data: \(error)")
}
}