iOS SDK Setup
To integrate AppsOnAir-AppSync iOS SDK to your iOS native Apps with Swift, SwiftUI or Objective-C, follow the below steps
Basic Requirements for Service Usage
Essential Setup
- Make sure to configure the App ID properly. For additional information Getting started
Import the AppsOnAir-AppSync iOS SDK into Your Xcode Project
Using CocoaPods
-
Make sure your current Xcode project is closed and in the project root, run
sudo gem install cocoapods. -
Now run
pod initfrom the terminal in your project directory. -
Open the newly created
Podfilewith the code editor you are preferring to open. -
Add the AppsOnAir dependency under your project target like below.
target 'your_project_name' do
#only copy below line and paste into your podfile
pod 'AppsOnAir-AppSync'
end
- Run the following commands on the terminal window of your project's directory.
pod repo update
pod install
- Now open the newly created
<project_name>.xcworkspacefile.
Add the AppSync Service Initialization Code and Usage
You can call initialization at your preference however, we recommend you to add initialization code in AppDelegate file's didFinishLaunchingWithOptions method as follows:
- Swift/SwiftUI:
import AppsOnAir_AppSync - Objective-C:
#import "AppsOnAir_AppSync-Swift.h"
- Swift
- Objective-C
- SwiftUI
AppDelegate.swift
import AppsOnAir_AppSync
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// AppSync Class instance create
let appsOnAirSyncService = AppSyncService.shared
// AppSync common services Initialization
appsOnAirSyncService.sync(directory: ["showNativeUI":false]) { appUpdateData in
// Write the code here when showNative UI is false
}
return true
}
// Remaining contents of your AppDelegate Class...
}
AppDelegate.m
#import "AppsOnAir_AppSync-Swift.h"
@interface AppDelegate ()
@property (nonatomic, strong) AppSyncService *appsOnAirSyncService;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// App Sync Class instance create
self.appsOnAirSyncService = [AppSyncService shared];
// Help to enable sync manager for app with directory for showNativeUi handling and completion method
[self.appsOnAirSyncService syncWithDirectory:@{@"showNativeUI":@NO} completion:^(NSDictionary * appUpdateData) {
// write code of custom UI
}];
return YES;
}
// Remaining contents of your AppDelegate Class...
end
YOUR_APP_NAME.swift
import SwiftUI
import AppsOnAir_AppSync
@main
struct YOUR_APP_NAME: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
// AppSync Class instance create
let appsOnAirSyncService = AppSyncService.shared
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Help to enable sync manager for app with directory for showNativeUi handling and completion method
appsOnAirSyncService.sync(directory: ["showNativeUI":false]) { appUpdateData in
// write code of custom UI
}
return true
}
// Remaining contents of your AppDelegate Class...
}
- sync method performs synchronization of app update data.
- The
directoryparameter accepts a dictionary of configuration options, including showNativeUI, which controls the display of the native update UI (set to true or false) - The
completionhandler receives the update data, allowing for custom handling and presentation of the update information through a personalized UI
Run App & Verify App Update and/or Maintenance Services
Run your app by using Xcode on iOS simulators or any physical device to make sure it builds correctly.
note
Note that to check the App Update and maintenance services are only configured from AppsOnAir portal.