Resetting the license cache#
In LUNA ID for Android#
To reset the license cache:
- Call the
LunaID.resetLicenseCache(context)
method. - Restart your app. LUNA ID will reinitialize and generate a fresh license cache.
In LUNA ID for iOS#
We recommend that you reset license cache when you update your app. To do this:
1․ Create the LCLunaConfiguration.resetLicenseCache()
function to check the application version and reset the license cache:
import Foundation
func checkAndResetLicenseCache() {
let currentAppVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
let savedAppVersion = UserDefaults.standard.string(forKey: "AppVersion")
if currentAppVersion != savedAppVersion {
LCLunaConfiguration.resetLicenseCache()
UserDefaults.standard.set(currentAppVersion, forKey: "AppVersion")
}
}
2․ Call this function when the application starts:
- With UIKit in the AppDelegate.swift file:
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
checkAndResetLicenseCache()
...
return true
}
}
- With SwiftUI in the App.swift file:
@main
struct YourApp: App {
init() {
checkAndResetLicenseCache()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}