Swiftpack.co - PerimeterX/px-iOS-Framework as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by PerimeterX.
PerimeterX/px-iOS-Framework 2.0.0
PerimeterX iOS framework
⭐️ 10
🕓 2 weeks ago
iOS
.package(url: "https://github.com/PerimeterX/px-iOS-Framework.git", from: "2.0.0")

image


About PerimeterX

PerimeterX is the leading provider of application security solutions that keep your business safe in the digital world. Delivered as a service, the company’s Bot Defender, Code Defender and Page Defender solutions detect risks to your web applications and proactively manage them, freeing you to focus on growth and innovation. The world’s largest and most reputable websites and mobile applications count on PerimeterX to safeguard their consumers’ digital experience. PerimeterX is headquartered in San Mateo, California and at www.perimeterx.com.

Introduction

The PerimeterX iOS SDK works by constantly profiling and evaluating device behavior to ensure that the connections to your mobile APIs and services are genuine. This process is complex and detailed yet only requires initialization to manage a set of secure HTTP headers which are added to all HTTP and HTTPS requests made by the mobile application to the origin server. These HTTP headers are refreshed on a regular basis by the SDK as it is profiling the end-user’s mobile device. The PerimeterX iOS SDK works well with popular HTTP request libraries for iOS including Alamofire.

Supported versions

Operating System iOS 11 and higher
Xcode Xcode 13 and higher
Languages Swift 5.5 and higher, Objective-C

Integration

Adding PerimeterX SDK to your project with:

Swift Package Manager

Add the package from the following repository:

https://github.com/PerimeterX/px-iOS-Framework

CocoaPods

Add the PerimeterX pod to your Podfile:

platform :ios, '13.0'
use_frameworks!

target '<Your App Name>' do
    pod 'PerimeterX', '<Version>'
end

Manual

  1. Download PerimeterX_SDK.xcframework from https://github.com/PerimeterX/px-iOS-Framework

  2. In Xcode, add the framework to the "Frameworks and Libraries" section in your target.

Implementation

In your AppDelegate:

  1. Import the SDK.

    Swift:

    import PerimeterX_SDK
    

    Objective-C:

    @import PerimeterX_SDK;
    
  2. Make the AppDelegate class to conform to the PerimeterXDelegate.

    Swift:

    class AppDelegate: UIResponder, UIApplicationDelegate, PerimeterXDelegate
    

    Objective-C:

    @interface AppDelegate : UIResponder <UIApplicationDelegate, PerimeterXDelegate>
    
  3. Verify the SDK's version.

    Swift:

    print("SDK version: \(PerimeterX.sdkVersion())")
    

    Objective-C:

    NSLog(@"SDK version: %@", [PerimeterX sdkVersion]);
    
  4. Call the PerimeterX/start(appId:delegate:enableDoctorCheck:completion:) function with your AppID.

    Swift:

    PerimeterX.start(appId: "<APP_ID>", delegate: self, enableDoctorCheck: false) { success, error in
        if success {
            if let vid = PerimeterX.vid(forAppId: nil) {
                print("vid: \(vid)")
            }
        }
        else {
            if let error = error {
                print("error: \(error)")
            }
            
            // make sure to start the sdk again when it fails (network issue, etc.)
        }
    }
    

    Objective-C:

    [PerimeterX startWithAppId:@"<APP_ID>" delegate:self enableDoctorCheck:NO completion:^(BOOL success, NSError * _Nullable error) {
        if (success) {
            NSString *vid = [PerimeterX vidForAppId:nil];
            NSLog(@"vid: %@", vid);
        }
        else {
            NSLog(@"error: %@", error);
            
            // make sure to start the sdk again when it fails (network issue, etc.)
        }
    }];
    
  5. That's it! 🎉

The full documentation can be found here.

GitHub

link
Stars: 10
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics