Swiftpack.co - Judopay/DeviceDNA-iOS as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Judopay.
Judopay/DeviceDNA-iOS 2.0.0
Device DNA library for iOS SDK
⭐️ 5
🕓 1 year ago
iOS
.package(url: "https://github.com/Judopay/DeviceDNA-iOS.git", from: "2.0.0")

DeviceDNA

The DeviceDNA iOS library allows you to identify devices using the Judopay Genome service

Getting Started

Step 1: Initialize DeviceDNA

1. Add DeviceDNA as a dependency

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

  • You can install CocoaPods with the following command:
$ gem install cocoapods
  • Add DeviceDNA to your Podfile to integrate it into your Xcode project:
source 'https://github.com/CocoaPods/Specs.git'

pod 'DeviceDNA', '~> 2.0'
  • Then, run the following command:
$ pod install
  • Please make sure to always use the newly generated .xcworkspace file not not the projects .xcodeproj file

2. Initialize DeviceDNA with your Judo account details:

  • Add the following statement to the class where you intend to use DeviceDNA

swift

@import DeviceDNA

obj-c

#import <DeviceDNA/DeviceDNA.h>
  • Create an instance of DeviceDNA

swift

let credentials = Credentials(<YOUR_TOKEN> secret:<YOUR_SECRET>)
let deviceDNA = DeviceDNA(credentials: credentials)

obj-c

Credentials *credentials = [[Credentials alloc] initWithToken:<YOUR_TOKEN> secret:<YOUR_SECRET>];
DeviceDNA *deviceDNA = [[DeviceDNA alloc] initWithCredentials:credentials];

Step 2: Identify a device

  • Call DeviceDNA to identify the device, this executes a callback providing the discovered device identifier and an error object.

swift

deviceDNA.identifyDevice { (deviceIdentifier, error) in
    //Your provided callback.            
}

obj-c

[deviceDNA identifyDevice:^(NSString * _Nullable deviceIdentifier, NSError * _Nullable error) {
    //Your provided callback.    
}];

Step 3: Check the device profile

  • Using the device identifier returned in step 2, call to retrieve the device profile

swift

deviceDNA.getDeviceProfile(deviceId) { (device, error) in
    //Your provided callback.  
}

obj-c

[deviceDNA getDeviceProfile:deviceId completion:^(NSDictionary<NSString *,id> * _Nullable device, NSError * _Nullable error) {
    //Your provided callback.    
}];

Device signals for server to server fraud prevention

When performing server to server payments using the Judopay API, you may wish to identify the device at the time of payment. To obtain the device signals necessary for fraud prevention, use DeviceDNA to obtain the encrypted signals which will be passed in the clientDetails JSON field of the request body:

swift

deviceDNA.getDeviceSignals { (device, error) in
    if let device = device as [String : String]? 
        let deviceId = device["deviceIdentifier"];
        let key = device["key"];
        let value = device["value"];
    }
}

obj-c

[deviceDNA getDeviceSignals:^(NSDictionary<NSString *,NSString *> * _Nullable device, NSError * _Nullable error) {
    NSString *deviceId = device["deviceIdentifier"];
    NSString *key = device["key"];
    NSString *value = device["value"];
}];

GitHub

link
Stars: 5
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2.0.0
1 year ago

XCFramework support

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