The suite of OkHi iOS framework that will enable you to start collecting and verifying your user's addresses.
OkCollect and OkVerify supports iOS 12 and above
Prerequisites
OkHi Client Key and Branch Id
First you need to obtain your OkHi client key and branch ID. You can get these by signing up here.
Installation
https://github.com/OkHi/ios-okhi
platform :ios,'12.0'target 'MyAwesomeApp'do pod 'OkHi','~> 1.9.9'end
Configure your app
OkCollect requires access WhenInUse location permission to the user's location in order to create an address at their current location. OkVerify requires AlwaysAndWhenInUseUsage location to verify the user's address
To satisfy these requirements add the following to your info.plist file and provide a useful description as to why your application needs access to the user's location.
<key>NSLocationWhenInUseUsageDescription</key>
<string>String that explains why you need this permission</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>String that explains why you need this permission</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>String that explains why you need this permission</string>
Background Mode Capabilities
OkVerify obtains and transmits verification signals in the background, to enable this make sure to add "Location updates" and "Background fetch" at Background Modes under Signing & Capabilities of your target
Authentication
In your AppDelegate.swift file configure the OkHi Auth object with your client key and branch ID. Make sure to also setup your app's context with meta data about your application
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.
Always use your phone number or a phone number you own during testing as a message will be sent to this number after an address is created.
importUIKitimportOkHiimportCoreLocationclassViewController:UIViewController {privatelet okCollect =OkCollect()privatelet okVerify =OkVerify()overridefuncviewDidLoad() { super.viewDidLoad()// Called in the initial screen OkVerify.onStart()// Do any additional setup after loading the view. okCollect.delegate = self okVerify.delegate = self }@IBActionfunconButtonPress(_sender: UIButton) {if okVerify.isLocationServicesEnabled() {if okVerify.isBackgroundLocationPermissionGranted() {startAddressCreation() } else { okVerify.requestBackgroundLocationPermission() } } }funcstartAddressCreation() { let okHiTheme = OkHiTheme().with(logoUrl: "https://cdn.okhi.co/icon.png").with(appBarColor: "#ba0c2f").with(appName: "OkHi")
let okHiConfig =OkHiConfig().enableStreetView().enableAppBar()guardlet vc = okCollect.viewController( with: OkHiUser(phoneNumber: "+234xxxxx") // It is important to provide your actual phone number, as a message will be sent to this number
.with(firstName:"Gift") .with(lastName:"Moore") .with(email: "giftmoore@okhi.com"), // It is important to use your actual email address, an email may be sent to the provided address
okHiTheme: okHiTheme, okHiConfig: okHiConfig)else {return } self.present(vc, animated:true, completion:nil) }funcstartAddressVerification(user: OkHiUser, location: OkHiLocation) { okVerify.startAddressVerification(user: user, location: location) }}extensionViewController:OkCollectDelegate {funccollect(didEncounterErrorerror: OkHiError) {// handle errordebugPrint(error) }funccollect(didSelectAddressuser: OkHiUser, location: OkHiLocation) {startAddressVerification(user: user, location: location) }}extensionViewController:OkVerifyDelegate { func verify(_ okverify: OkVerify, didChangeLocationPermissionStatus requestType: OkVerifyLocationPermissionRequestType, status: Bool) {
if requestType == .always && status {startAddressCreation() } }funcverify(_okverify: OkVerify, didInitializeresult: Bool) {print("initialized successfully") }funcverify(_okverify: OkVerify, didEncounterErrorerror: OkVerifyError) {debugPrint(error) }funcverify(_okverify: OkVerify, didStartAddressVerificationForlocationId: String) {print("started verification for: \(locationId)") }funcverify(_okverify: OkVerify, didStopVerificationForlocationId: String) {print("stopped verification for: \(locationId)") }funcverify(_okverify: OkVerify, didUpdateLocationPermissionStatusstatus: CLAuthorizationStatus) {// called on each status changeprint("location permission status updated") }funcverify(_okverify: OkVerify, didUpdateNotificationPermissionStatusstatus: Bool) {print("push notification permission status updated") }}
Customizing address type parameters
OkCollect V1 introduces the ability to specify out of two types, the location the customer is at.
home
work
Ideally, you would ask your user to specify this during address creation and it helps our AI more efficiently and quickly verify an address.
let okHiConfig = OkHiConfig().enableStreetView().enableAppBar().withAddressTypes(work: true, home: false)
Whenever a user's OkHi address is created or used an SMS is sent to them notifying them of this usage. When testing make sure to use your phone number
Whereas OkCollect does provide ways to customise the look and feel of the address creation process as well as alter some of the in built functionality. Due to accessibility concerns, the product will work with select brand colours that provide enough contrast to the text being rendered.
Start verification without OkCollect
It's possible to construct your own OkHiLocation object using an identifier (provided by us, when a user creates an address using OkCollect) and a pair of coordinates.