...
In order to use VIZpinSDK
with an iOS app, your app should include following permissions in the plist.
Code Block | ||
---|---|---|
| ||
Privacy - Bluetooth Peripheral Usage Description >> [App Name] uses bluetooth to unlock VIZpin powered locks. |
...
VIZpinSDK.Framework
contains a class VIZpinSDK
. Following code snippet shows creating an object and initializing your app with the app constants
Code Block | ||
---|---|---|
| ||
sdk = [[VIZpinSDK alloc] init]; sdk.apiServer = @"<https://YOUR_SANDBOX_HERE.force.com/VIZpin/services/apexrest/sdk";> sdk.APP_ID = @"YOUR_APP_ID_HERE"; sdk.APP_NAME = @"OEM AppName"; sdk.APP_KEY = @"YOUR_APP_KEY_HERE"; sdk.APP_KEY_VERSION = @"1.1"; sdk.APP_VERSION = @"OEM AppVersion_1.0"; VPUser* user = [[VPUser alloc] init]; user.phone = @"USER_PHONE_NUMBER"; user.password = @"USER_PASSWORD"; user.bluetooth = VIZpinSDK.BLE_MODE; [sdk initialize:user]; // Use this on an app start where you have cached user credentials // or [sdk initialize:nil]; // Use this on a fresh install where you have no cached user credentials |
...
Verifying the bluetooth subsystem on your user"s phone is ON is the responsibility of the developer.
Code Block | ||
---|---|---|
| ||
CBCentralManager* _centralManager = [[CBCentralManager alloc] initWithDelegate:nil queue:dispatch_queue_create("com.company.app", DISPATCH_QUEUE_SERIAL) options:@{CBCentralManagerOptionShowPowerAlertKey:@YES}]; ..... if( _centralManager.state != CBCentralManagerStatePoweredOn ) { // alert user that bluetooth is required } |
...
Verification is used to have the User received an SMS to their phone number to prove they own this device. Only the phone, password and sms properties of the VPUser need set for this function. If you want to reset a users password, simply send a different password that the server has and it will be udpated. Like all functions there will be a VPError return object and a function specific callback to receive the results. Below is a sample use of this function:
Code Block | ||
---|---|---|
| ||
VPUser* user = [[VPUser alloc] init]; user.phone = @"+17775551212"; user.password = @"secret123"; user.sms = @"123456"; VPError* ret = [sdk verifyUser:user withCompletion: ^ (VPError *error, VPUser *user) { if (error.status == VIZpinSDK.SDK_SUCCESS) { // do something else, the User is all setup and can now be granted VIZpins on the server } }]; if( ret != VIZpinSDK.RET_SDK_SUCCESS ) { // show error message or determine issue with parameters } |
...
Code Block |
---|
VPError* ret = [sdk getCredentials:NO withRefresh:NOYES withCompletion: ^ (VPError *error, NSDictionary *credentials) { if (error.status == VIZpinSDK.SDK_SUCCESS) { // do something else, you now have a list of the Credentials this User can use to unlock our Readers } }]; if( ret != VIZpinSDK.RET_SDK_SUCCESS ) { // show error message or determine issue with parameters } |
...