KahunaControlAppBootup is written in Swift
To run the example project, clone the repo, and run pod install from the Example directory first.
In order to access this feature of app boot up, you need to have Kahuna Logcamp Id
KahunaControlAppBootup is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'KahunaControlAppBootup', '~> 1.0'New development will happen exclusively on the master/Swift 3 branch.
let shared = AppBootupHandler.sharedInstance
shared.initServerBaseURL(serverBaseURL: kLogCampBaseURL)Note: Add import KahunaControlAppBootup into respected file
shared.isAppTypeProduction(flag: true)Note: Default value for production = false
shared.initAllAppBootupKeysWithViewController(appId: logCampId, viewController: rootViewController)OR
shared.initAllAppBootupKeysWithViewController(appId: logCampId, viewController: rootViewController, checkFreeSpace: true)Note: Default value for checkFreeSpace = false
Detect an app to boot or not in a device based on that apply app version, os version and free space.
- Default View managed in a alert by library based on action.
shared.checkForRemoteUpdate()- Custom View managed based on action managed by an app.
shared.checkForRemoteUpdateByCustomView { (success, jsonObject) in
if success && jsonObject is KahunaAppBootup {
let kahunaAppBooup = jsonObject as! KahunaAppBootup
print(kahunaAppBooup.action)
print(kahunaAppBooup.message)
print(kahunaAppBooup.title)
print(kahunaAppBooup.url)
}
}Note: When success == true and jsonObject is KahunaAppBootup then we need to perform check actions and show message with title
- Action BLOCK -> Restrict User to use an app by showing title and message in a alert.
- Action WARNING -> Prompt message in an alert to User with title.
- Action REDIRECT_TO_APPSTORE -> Prompt message in an alert to User with title and click ok then redirect to app store to update an app version.
- Action REDIRECT_TO_SETTINGS -> Prompt message in an alert to User with title and click ok then redirect to device settings to update an os version.
- Action REDIRECT_TO_URL -> Prompt message in an alert to User with title and click install then redirect to respective url to update an app version.
Note: Call setupRemoteUpdate in didFinishLaunchingWithOptions method
func setupRemoteUpdate() {
let shared = AppBootupHandler.sharedInstance
shared.initServerBaseURL(serverBaseURL: kLogCampBaseURL)
if let rootViewController = self.window?.rootViewController {
shared.initAllAppBootupKeysWithViewController(appId: logCampId, viewController: rootViewController)
#if DEVELOPMENT
shared.isAppTypeProduction(flag: false)
#else
shared.isAppTypeProduction(flag: true)
#endif
}
}Note: Call checkForRemoteUpdate in applicationWillEnterForeground method
func checkForRemoteUpdate(splashScreen: UIImageView? = nil) {
if CheckConnectivity.hasConnectivity() {
let shared = AppBootupHandler.sharedInstance
if let rootViewController = self.window?.rootViewController {
shared.initAllAppBootupKeysWithViewController(appId: logCampId, viewController: rootViewController)
AppBootupHandler.sharedInstance.checkForRemoteUpdate { (success, jsonObject) in
if let splashScreenView = splashScreen {
DispatchQueue.main.async {
splashScreenView.removeFromSuperview()
MBProgressHUD.hideAllHUDs(for: self.window, animated: true)
}
}
}
}
} else {
if let splashScreenView = splashScreen {
DispatchQueue.main.async {
splashScreenView.removeFromSuperview()
MBProgressHUD.hideAllHUDs(for: self.window, animated: true)
}
}
}
}siddharthchopra, siddharth.chopra@kahunasystems.com
KahunaControlAppBootup is available under the MIT license. See the LICENSE file for more info.
