AirServiceKitViewController
@interface AirServiceKitViewController : UIViewController
AirServiceKitViewController
Include the AirService ordering platform right within your own application. AirServiceKitViewController can be used directly, or subclassed, and is simple to integrate anywhere you would typically use a View Controller.
See
https://github.com/airservice/Open-API-and-SDKs for more information.-
Your application code as provided by AirService
Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *appCode; -
Your client identifier for the AirService API
Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *clientID; -
Your client secret for the AirService API
Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *clientSecret; -
Your collection name as provided by AirService
Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *collection; -
Implement any desired optional methods and set your object as the delegate.
@interface AppDelegate () <AirServiceKitDelegate> ... self.viewController = [[AirServiceKitViewController alloc] initWithClientID:@"XX" clientSecret:@"XX" collection:@"XX" delegate:self]; or self.viewController.delegate = self;Declaration
Objective-C
@property (readwrite, nonatomic) id<AirServiceKitDelegate> delegate;Swift
weak var delegate: AirServiceKitDelegate! { get set } -
Your sector name as provided by AirService
Depending on your setup by AirService this value may not be required.
Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *sector; -
Your venue id as provided by AirService
Depending on your setup by AirService this value may not be required.
Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *venueID; -
Determines the return/exit button that will be shown when AirService is presented or pushed
A button is displayed in the root view of AirService enabling your users to return to your View Controller. The value of hostAction determines what icon is shown on the button.
Note
Defaults toASHostActionTypeNoneSee
ASHostActionTypeenum for detailsDeclaration
Objective-C
@property (assign, readwrite, nonatomic) ASHostActionType hostAction;Swift
var hostAction: Int32 { get set } -
Determines which envionment of AirService to run.
QA: To be used during development and testing.
Production: Live environment, real money, real people, real food..
Note
Defaults toASAppEnvironmentProductionSee
ASAppEnvironmentenum for detailsDeclaration
Objective-C
@property (assign, readwrite, nonatomic) ASAppEnvironment appEnvironment;Swift
var appEnvironment: Int32 { get set } -
Set this flag to indicate your application will support PayPal payments
Supporting PayPal payments inside AirServiceKit also requires the ASPayPalPayments library.
self.viewController.acceptPayPalPayments = YES; self.viewController.payPalPaymentsClient = [[ASPayPalPayments alloc] init];Note
Defaults to NODeclaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL acceptPayPalPayments;Swift
var acceptPayPalPayments: Int32 { get set } -
Your initialised ASPayPalPayments instance.
Supporting PayPal payments inside AirServiceKit also requires the ASPayPalPayments library. Provide an initialised instance of ASPayPalPayments as well as setting acceptPayPalPayments to true
self.viewController.acceptPayPalPayments = YES; self.viewController.payPalPaymentsClient = [[ASPayPalPayments alloc] init];Declaration
Objective-C
@property (readwrite, strong, nonatomic) id<ASPayPalPaymentsConnector> payPalPaymentsClient; -
Override your application display name.
Note
This is optional and will otherwise be taken from your app bundle automatically to match what is shown on the iOS homescreen.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *appName; -
If your application launched as a result of a user interacting with a push notification, pass this notification to
AirServiceKitViewControllerduring initialisation.- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... NSDictionary* remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (remoteNotification) { self.viewController.notification = remoteNotification; } ... }Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSDictionary *notification; -
Apple AppStore identifier.
Note
Advanced property, not required for standard implementation.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *appStoreID; -
AirService specific app type identifier.
Note
Advanced property, not required for standard implementation.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *appIdentifier; -
Overrides the default AirService App URL.
Note
Advanced property, not required for standard implementation.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *overrideBaseAppURL; -
Overrides the default AirService API URL.
Note
Advanced property, not required for standard implementation.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSString *overrideBaseApiURL; -
Provide additional custom parameters to
AirServiceKit.Note
Advanced property, not required for standard implementation.Declaration
Objective-C
@property (readwrite, strong, nonatomic) NSMutableArray *customParameters; -
Override the default colour with your brand colour.
Note
This is optional, not required for standard implementation.Declaration
Objective-C
@property (readwrite, strong, nonatomic) UIColor *brandColour; -
Enables
AirServiceKitlogging to the console. This is useful for debugging during development but should be disabled in production applications.Note
Defaults to NONote
Advanced property, not required for standard implementation.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL loggingEnabled;Swift
var loggingEnabled: Int32 { get set } -
Convenience initializer to create an AirServiceKitViewController instance. Its parameters are required in order to authenticate with AirService.
Declaration
Objective-C
- (instancetype)initWithAppCode:(NSString *)appCode clientID:(NSString *)clientID clientSecret:(NSString *)clientSecret collection:(NSString *)collection delegate:(id<AirServiceKitDelegate>)delegate;Swift
init!(appCode: Any!, clientID: Any!, clientSecret: Any!, collection: Any!, delegate: AirServiceKitDelegate!)Parameters
appCodeYour application code as provided by AirService
clientIDYour client identifier for the AirService API
clientSecretYour client secret for the AirService API
collectionYour collection name as provided by AirService
delegateA delegate object adopting
AirServiceKitDelegatethat wishes to receive messagesReturn Value
An
AirServiceKitViewControllerinstance -
When your application successfully registers for remote notifications you must pass the device token through to your
AirServiceKitViewControllerinstance. This is so that AirService can use Apple Push Notifications to communicate order related messages to customers.- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [self.viewController addPushDeviceToken:deviceToken]; }Declaration
Objective-C
- (void)addPushDeviceToken:(NSData *)token;Swift
func addPushDeviceToken(_ token: Any!)Parameters
tokenA device token object
-
A string representation of the saved device token, if any, that
AirServiceKitcurrently holds.Declaration
Objective-C
+ (NSString *)pushDeviceToken;Swift
class func pushDeviceToken() -> Any!Return Value
A device token string
-
When your application receives a notification via one of
UIApplication'sseveral delegate methods you must pass this notification through to yourAirServiceKitViewControllerinstance so that AirServiceKit can handle it.- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [self.viewController notificationReceived:userInfo handler:nil local:NO]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [self.viewController notificationReceived:userInfo handler:completionHandler local:NO]; } - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { if (notification.userInfo) { [self.viewController notificationReceived:notification.userInfo handler:nil local:YES]; } }Note
If your application also makes use of push notifications you can check the notification payload for the key/value pair"source":"airservice"and only pass the AirService specific notifications through toAirServiceKit.Declaration
Objective-C
- (void)notificationReceived:(NSDictionary *)payload handler:(void (^)(UIBackgroundFetchResult))handler local:(BOOL)local;Swift
func notificationReceived(_ payload: Any!, handler: Any!, local: Any!)Parameters
payloadThe complete Apple Push Notification payload
handlerThe existing
UIBackgroundFetchResultcompletion handler ornillocalSpecify whether the notification you are passing is a local or remote notification
-
AirServiceKit makes use of resource URLs, URL schemes and services such as PayPal Payments. If your application receives a request to handle a URL pass this through to your
AirServiceKitViewControllerinstance so that AirServiceKit can determine whether to handle it.//iOS 8 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [self.viewController handleOpenURL:url sourceApplication:sourceApplication]; } //iOS 9 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options { return [self.viewController handleOpenURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]]; }Note
AirServiceKitonly handles its specific URLs it recognises and is interested in, if your application also makes use of URL schemes you can check the return value from this method.Declaration
Objective-C
- (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication;Swift
func handleOpenURL(_ url: Any!, sourceApplication: Any!) -> Any!Parameters
urlThe URL provided from the
UIApplicationdelegatesourceApplicationThe NSString sourceApplication provided from the
UIApplicationdelegateReturn Value
A BOOL indicating whether
AirServiceKithas handled the URL or your application should manage it.
View on GitHub
AirServiceKitViewController Class Reference