Logo
Initialize SDK and get device details
To initialise the SDK add the below line of code with the public key you retrieved from Sense client panel. If you don't have a public key create new one and call that below function.
How to Install
toast-icon
Requirements
  1. OS 12.0 or above
  2. Swift version 5.0 and above
Note:If the application does not have the listed permissions, the values collected using those permissions will be ignored. To provide a valid device details, we recommend employing as much permission as possible based on your use-case.
  1. Pod Installation
    copy-icon
    copy-icon
    pod 'SenseSDK', '~> 1.0.1'
    Check out cocoapod.org for latest version of pod versions.
  2. Pod Update
    copy-icon
    copy-icon
    pod update
    Valid only for updated pod version
  3. Import SDK
    copy-icon
    copy-icon
    import SenseSDK
  4. Initialize SDK
    Add the following line of code to initialize it with the api key you obtained from the Sense Client panel. If you don't have a api key create new one
    copy-icon
    copy-icon
    func initiateSense(){
        let senseConfig = SenseConfig()
        senseConfig.apiKey = "Your Unique Public API Key"
        senseConfig.senseInfo = false // true or false
        senseConfig.allowGeoLocation = false // true or false
        senseConfig.tag = "" // String whatever you need like Home
        senseConfig.sessionId = "" //Optional used for Workflow
        // senseConfig.metaInfo = [
        //     "phone": "9xxxxxxxxx",
        //     "name": "xxxxxxxxxxx"
        // ] 
        // A collection of key-value pairs intended for storing supplementary data related 
        // to the request. The set supports up to 15 pairs, with each key 
        // and value limited to a maximum of 256 characters.
        Sense.initSDK(senseConfig: senseConfig, withDelegate: self)
    }
    Sense Config Information
    • If you pass senseInfo as true in above config means, it will return additional Information like Request ID, First seen, Last seen, IP Address with SenseID. Otherwise it will return only SenseID and Request .
    • If you pass allowGeoLocation as true in above config means, it will return Device Location Information in Sense Details via our Server API.
  5. Get Device Details
    copy-icon
    copy-icon
    SenseSDK.getSenseDetails(withDelegate: self)
    Use the below code to get the Device Details.
  6. Implement Delegate Method
    Set and Implement our Delegate method to receive the Callback details
    copy-icon
    copy-icon
    extension ViewController: SenseDelegate{
        func onFailure(message: String) {
            // Failure Callback.
        }
        func onSuccess(data: [String : Any]) {
            // Success Callback
        }
    }
  7. Location Permission (Optional)
    You have to add this permission in Info.plist to get Device Location Information.
    copy-icon
    copy-icon
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>This app needs access to your location to provide location-based services.</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Location access is required for enhanced app functionality.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Require to get user location</string>
  8. Remote Access Apps
    You have to add this permission in Info.plist to get Remote Access and Meeting Applications.
    copy-icon
    copy-icon
    <!-- Remote Access Apps -->
    <string>tvcontrol1</string> <!-- TeamViewer -->
    <string>anydesk</string> <!-- AnyDesk -->
    <string>rustdesk</string> <!-- RustDesk -->
    <!-- Meeting Apps -->
    <string>zoommtg</string> <!-- Zoom -->
    <string>msteams</string> <!-- Microsoft Teams -->
    <string>slack</string> <!-- Slack -->
    <string>skype</string> <!-- Skype -->
  9. Installed Apps (Optional)
    If you need to know Installed Applications in our SDK, kindly update your Info.plist like below. You can add those apps that you need to check whether it's installed or not.
    copy-icon
    copy-icon
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>whatsapp</string>
        <string>tez</string>
        <string>phonepe</string>
        <string>cred</string>
        <string>amazon</string>
    </array>
  10. Sample Program
    Here you can find the demonstration to do the integration.
    copy-icon
    copy-icon
    import UIKit
    import SenseSDK
    
    class SenseController: UIViewController, SenseDelegate, SenseBehaviourDelegate {
    
      @IBOutlet weak var txtUsername: UITextField!
      @IBOutlet weak var txtPassword: UITextField!
      @IBOutlet weak var scrollView: UIScrollView!
      @IBOutlet weak var btnSense: UIButton!
    
      override func viewDidLoad() {
          super.viewDidLoad()
          SenseSDK.initKeyStrokeBehaviour(for: [txtUsername, txtPassword])
          SenseSDK.initScrollBehaviour(for: [scrollView])
          SenseSDK.initTouchBehaviour(for: self.view)
      }
    
      func initiateSense(){
          let senseConfig = SenseConfig()
          senseConfig.apiKey = "Your Unique Public API Key"
          senseConfig.senseInfo = false // true or false
          senseConfig.allowGeoLocation = false // true or false
          senseConfig.tag = "" // String whatever you need like Home
          senseConfig.sessionId = "" //Optional used for Workflow
          // senseConfig.metaInfo = [
          //     "phone": "9xxxxxxxxx",
          //     "name": "xxxxxxxxxxx"
          // ] 
          // A collection of key-value pairs intended for storing supplementary data 
          // related to the request. The set supports up to 15 pairs, with each 
          // key and value limited to a maximum of 256 characters.
          Sense.initSDK(senseConfig: senseConfig, withDelegate: self)
      }
    
      @IBAction func btnSense(_ sender: Any) {
          initiateSense()
          SenseSDK.getSenseDetails(withDelegate: self)
      }
    
      @objc func onSuccess(data: String) {     
          // Handle success callback
      }
      @objc func onFailure(message: String) {
          // Handle failure callback
      }
      func onFailureBehaviour(message: String) {
          // Handle failure callback
      }
      func onSuccessBehaviour(data: String) {
          // Handle success callback
      }
    }
    To get Behaviour Data for Keystrokes, Mouse Movements, Scroll Metrics, Touch Metrics, you can add the below methods to initialize it.
    For Keystrokes, pass your textfields as arguments like below
    copy-icon
    copy-icon
    @IBOutlet weak var txtUsername: UITextField
    @IBOutlet weak var txtPassword: UITextField
    SenseSDK.initKeyStrokeBehaviour(for: [txtUsername, txtPassword]);
    For Scroll Metrics
    copy-icon
    copy-icon
    @IBOutlet weak var scrollView: UIScrollView
    SenseSDK.initScrollBehaviour(for: [scrollView]);
    For Touch Metrics
    copy-icon
    copy-icon
    SenseSDK.initTouchBehaviour(for: self.view)
    To get Behaviour Data, Call below method to get it
    copy-icon
    copy-icon
    SenseSDK.getBehaviourData(withDelegate: self)
    extension ViewController: SenseBehaviourDelegate{
        func onFailureBehaviour(message: String) {
            print("Failure data")
        }
        func onSuccessBehaviour(data: String) {
            print("Success data")
        }
    }