Skip to main content

Implementação

import UIKit
import ZaigIosDeviceScan

class ViewController: UIViewController {

var zaigDeviceScan : ZaigIosDeviceScan?

override func viewDidLoad() {
super.viewDidLoad()
self.setupDeviceScan()
}

func setupDeviceScan() -> Void
{
// The environment can be 'sandbox' ou 'production'
let environment = "sandbox"

// MobileToken is the key sent to you by QI Tech. Each environment requires a different MobileToken.
let mobileToken = "YOUR_MOBILE_TOKEN_SENT_BY_QITECH"

// You must send the same session id in the moment of using the device scan and event analysis. It must be a key that uniquely identifies each user session in the app
let sessionId = "62715840-068a-4ded-a4e2-a1ec83f857d4"

do{
self.zaigDeviceScan = try ZaigIosDeviceScan(environment: environment, mobileToken: mobileToken, sessionId: sessionId)
}
catch{
print ("Error found when instantiating Zaigs DeviceScan")
}

let permissions = ["location"]

do{
try self.zaigDeviceScan?.requestPermissions(permissions: permissions)
}
catch{
print ("Error found when requesting Zaigs DeviceScan's permissions")
}
}

func onSuccess()
{
// Do something if QI Tech DeviceScan's collectData method succesfully collected device data
}

func onError()
{
// Do something if QI Tech DeviceScan's collectData method found any error when collecting device data
}

func collectZaigDeviceScanData()
{
// If you have your customer's document number (CPF or CNPJ without dots, hyphen or slash), you must sent it to QI Tech
let documentNumber = "12345678900"

// EventType must represent with type of interation the user had with your app on the moment that collectData method was called
let eventType = "login"

// EventId is your code that identifies the event sent to QI Tech
let eventId = "7038632032"

do{
try self.zaigDeviceScan?.collectData(documentNumber: documentNumber, eventId: eventId, eventType: eventType, onSuccessHandler: self.onSuccess, onErrorHandler: self.onError)
}
catch{
print("Error found when collecting Zaigs DeviceScan data")
}
}
}

Para utilizar a SDK do Device Scan iOS, os seguintes passos são necessários:

Inserir as autorizações no arquivo Info.plist Adicionar o framework ao projeto do aplicativo Ao iniciar a aplicação, instanciar a biblioteca, passando os parâmetros adequados Caso sua aplicação ainda não tenha solicitado as permissões ao usuário, requisitar as permissões ao usuário por meio da função requestPermissions do objeto previamente instanciado Coletar e enviar os dados por meio do método collectData