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.
Use your sandbox keys while you test and develop, and your production mode keys before you publish your app.
Installation
https://github.com/OkHi/ios-okhi
platform :ios,'12.0'target 'MyAwesomeApp'do pod 'OkHi','~> 1.0.6'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
importOkHi func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let okHiAppContext =OkHiAppContext().withAppMeta(name:"My Awesome App", version:"1.0.0", build:"1")let okHiAuth =OkHiAuth( branchId:"<my_branch_id>", clientKey:"<my_client_key>", environment: Environment.sandbox, // make sure to change this to prod when you're ready to go live 🚀 appContext: okHiAppContext) OkCollect.initialize(with: okHiAuth) OkVerify.initialize(with: okHiAuth, launchOptions: launchOptions)returntrue}
Usage
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.
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.