Migrating to OkHI iOS v1.0.6

How to migrate to the latest release

To further improve both developer integration experience as well as library performance the latest release of OkHi iOS library combines all functionality of OkCollect & OkVerify into one single library.

Remove the previous libraries


Remove the previous libraries and add in the new single OkHi framework as shown bellow.

Once done run the bellow command in the same directory

$ pod install --repo-update


Remove all the previous packages by going to Package Dependancies tab on Xcode

Install the new OkHi package by clicking on "File > Add Packages..." in Xcode and in the seaarch box add the link to the bellow repository


Configure your AppDelegate file

In your AppDelegate file, remove previous library imports and import the single OkHi library.

Once thats done, rename the previous OkHiCollect and OkHiVerify static method calls to OkCollect & OkVerify as show bellow

Please note that OkHiCollect & OkHiVerify classes have been renamed to OkCollect and OkVerify

Update the integration in your ViewController

For OkVerify to work correctly "Always" Location permission needs to be granted by your users. The library provides the requestBackgroundLocationPermission method that enables you to manage these permission requirements as shown below.

import UIKit
import OkHi
import CoreLocation

class ViewController: UIViewController {
    private let okCollect = OkCollect()
    private let okVerify = OkVerify()
    override func viewDidLoad() {
        // Do any additional setup after loading the view.
        okCollect.delegate = self
        okVerify.delegate = self
    @IBAction func onButtonPress(_ sender: UIButton) {
        if okVerify.isLocationServicesEnabled() {
            if okVerify.isBackgroundLocationPermissionGranted() {
            } else {
    func startAddressCreation() {
        let okHiTheme = OkHiTheme().with(logoUrl: "https://cdn.okhi.co/icon.png").with(appBarColor: "#ba0c2f").with(appName: "OkHi")
        let okHiConfig = OkHiConfig().enableStreetView().enableAppBar()
        guard let vc = okCollect.viewController(with: OkHiUser(phoneNumber: "+254700110590"), okHiTheme: okHiTheme, okHiConfig: okHiConfig) else {
        self.present(vc, animated: true, completion: nil)
    func startAddressVerification(user: OkHiUser, location: OkHiLocation) {
        okVerify.startAddressVerification(user: user, location: location)

extension ViewController: OkCollectDelegate {
    func collect(didEncounterError error: OkHiError) {
        // handle error
    func collect(didSelectAddress user: OkHiUser, location: OkHiLocation) {
        startAddressVerification(user: user, location: location)

extension ViewController: OkVerifyDelegate {
    func verify(_ okverify: OkVerify, didChangeLocationPermissionStatus requestType: OkVerifyLocationPermissionRequestType, status: Bool) {
        if requestType == .always && status {
    func verify(_ okverify: OkVerify, didInitialize result: Bool) {
        print("initialized successfully")
    func verify(_ okverify: OkVerify, didEncounterError error: OkVerifyError) {
    func verify(_ okverify: OkVerify, didStartAddressVerificationFor locationId: String) {
        print("started verification for: \(locationId)")
    func verify(_ okverify: OkVerify, didStopVerificationFor locationId: String) {
        print("stopped verification for: \(locationId)")
    func verify(_ okverify: OkVerify, didUpdateLocationPermissionStatus status: CLAuthorizationStatus) {
        // called on each status change
        print("location permission status updated")

Have a look at the previous section to make sure that you have correctly configured the plist file with location permission rationale as well as set the correct background capabilities for OkVerify to work

Last updated