VenueNext iOS SDK Integration
Prerequisites
For Objective-C only projects using Xcode 10.1 and higher:
You must set Always Embed Swift Standard Libraries
to YES
in the target’s Build Setting
Obtaining the SDK
Manual Installation
Get the latest SDK from here:
VenueNext v1.2.1 for Swift 5.3 (Xcode 12+)
download
VenueNext v1.2.1 for Swift 5.2.4 (Xcode 11.5+)
download
VenueNext v1.2.1 for Swift 5.1.2 (Xcode 11.3+)
download
VenueNext v1.2.0 for Swift 5.2.2 (Xcode 11.4+)
download
VenueNext v.1.2.0 for Swift 5.1.2 (Xcode 11.3+)
download
When prompted, enter the provided JFrog credentials.
Unzip the archive, locate the following frameworks, and drag them into Embedded Binaries
located in your target’s General
section:
VenueNextNetworkService.framework
VenueNextCore.framework
VenueNextCoreUI.framework
VenueNextOrderService.framework
VenueNextOrderData.framework
VenueNextOrderUI.framework
VenueNextLegacy.framework
VenueNextPayment.framework
VenueNextAnalytics.framework
If you intend to use the Wallet feature of the VenueNext SDK, be sure to include the following also:
VenueNextWalletService.framework
VenueNextWalletUI.framework
VenueNextWalletData.framework
Initialization and Examples
To initialize the SDK pass in your SDK key and secret.
Typically, this would happen in your AppDelegate
.
Objective C
#import "AppDelegate.h"
@import VenueNextCore;
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[VenueNext shared] initializeWithSdkKey: @"lulu:dev:venuenext-dev" sdkSecret: @"dev" configURL: configURL completion: nil];
return YES;
}
Swift
import UIKit
import VenueNextCore
import VenueNextOrderData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let key = "lulu:dev:venuenext-dev"
let secret = "dev"
//Please use our provided PaymentAdapter and make sure this is called
//before attempting to use anything that requires payment
VenueNext.configure(paymentProcessor: PaymentAdapter())
//Note you can also initialize the SDK with Data of the config file if you prefer to parse the file yourself
//Please also refer to JSON config docs on how to structure your JSON file
let configURL = URL(string: "/path/to/config.json")
// Use this method signature if you do not have an external User ID or JWT
// Please make sure that the SDK initializes successfully before attempting to use the SDK interfaces. Doing so can and will result in undesired behavior such as crashes or incorrect data displayed.
VenueNext.shared.initialize(sdkKey: key, sdkSecret: secret, configURL: configURL) { (success, error) in
print("Successfully initialized SDK")
}
// Use this if you have an external user ID at the time of initializing the VenueNext SDK
let externalID = "xxxxxx-xxx-xxxxxxx"
VenueNext.shared.initialize(sdkKey: key, sdkSecret: secret, externalID: externalID, configURL: configURL) { (success, error) in
print("Successfully initialized SDK")
}
// Use this if you have an external user ID at the time of initializing the VenueNext SDK
// Please see the example below and ensure the JWT has the correct payload.
let jwt = "xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxx"
let forceReset = false //Warning: Only set if you intend to wipe all data from the SDK i.e. CoreData, UserDefaults, Keychain
VenueNext.shared.initialize(sdkKey: key, sdkSecret: secret, jwt: jwt, configURL: configURL, forceReset: forceReset) { (success, errror) in
print("Successfully initialized SDK")
}
}
}
When using a JWT please ensure the following payload structure is included:
{
"sub": "1234567890",
"iat": 1516239022,
"email": "email@example.org",
"sth": true,
"name": "Sam Smith"
}
Warning: Please treat your SDK secret with care. Do not check into source repositories or pass around in the clear.
SDK JSON Config
Please refer to this page on how to customize your JSON config file. JSON Config Docs