iOS SDK Setup AppSync
To integrate AppsOnAir-AppSync iOS SDK to your iOS native Apps with Swift, SwiftUI or Objective-C, follow the below steps
Step 1. Basic Requirements for service usage
- Make sure to configure the API key properly. For additional information Getting started
Step 2. Import the AppsOnAir-AppSync iOS SDK into your Xcode Project
Using CocoaPods
2.1 Make sure your current Xcode project is closed and in the project root, run sudo gem install cocoapods
.
2.2 Now run pod init
from the terminal in your project directory.
2.3 Open the newly created Podfile
with the code editor you are preferring to open.
2.4 Add the AoA 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
2.5 Run the following commands on the terminal window of your project's directory.
pod repo update
pod install
2.6 Now open the newly created <project_name>.xcworkspace
file.
Step 3. 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
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...
}
#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
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...
}
Properties Information
sync(directory: NSDictionary = ["showNativeUI": true],completion: @escaping (NSDictionary) -> () = { _ in })
- This method performs synchronization of app update data.
- The
directory
parameter accepts a dictionary of configuration options, including showNativeUI, which controls the display of the native update UI (set to true or false) - The
completion
handler receives the update data, allowing for custom handling and presentation of the update information through a personalized UI
Step 4. Run your App and Setup your app update and/or its maintenance services
Run your app by using Xcode on iOS simulators or any physical device to make sure it builds correctly.