Overview
Help pages, terms and privacy policies should open inside the app, not throw the user out to a browser. Network status decides whether to warn before streaming over mobile data. A fingerprint or Face ID check replaces typing a password on a shared device. KlugSystem covers all three with the system's own components.
The in-app browser is a Chrome Custom Tab on Android (no extra library needed) and SFSafariViewController on iOS, with your toolbar colour; your app is told when the user is back. Network status reports reachability and Wi-Fi versus mobile data and sends an event when it changes. Biometrics use BiometricPrompt on Android 9+ and LocalAuthentication on iOS; failures come with the same error codes on both platforms, so one handler works everywhere.
KlugSystem runs in the next release of the PetCam App, our proof of concept, for help pages, the mobile-data warning and confirming a pet-station logout.
Features
- In-app browser: Chrome Custom Tab (Android) / SFSafariViewController (iOS), toolbar colour, closed event
- Network: reachable, Wi-Fi or mobile data, change events (ConnectivityManager / NWPathMonitor)
- Biometrics: fingerprint and Face ID / Touch ID with your reason text and cancel label
- Same error codes on both platforms (cancel, fallback, locked out, not enrolled)
- No third-party libraries on either platform
- isSupported check, so the same code runs on every platform
Supported platforms
Devices without a biometric sensor report canAuthenticate = false, so your app can fall back to the password.
Getting started
Add the extension to your application descriptor:
<extensions>
<extensionID>com.klug.system</extensionID>
</extensions>
Android: add USE_BIOMETRIC and ACCESS_NETWORK_STATE to the manifest additions. iOS: add NSFaceIDUsageDescription to the InfoAdditions.
Quick example
import com.klug.system.KlugSystem; var sys:KlugSystem = KlugSystem.getInstance(); // in-app browser sys.openBrowser( "https://your.site/help", 0xFFFFFF ); sys.addEventListener( KlugSystem.BROWSER_CLOSED, onBack ); // network if ( sys.isReachable() && sys.isWWAN() ) warnMobileData(); sys.addEventListener( KlugSystem.NETWORK_CHANGE, onNetwork ); sys.startNetworkWatch(); // biometrics if ( sys.canAuthenticate( KlugSystem.BIOMETRY_FINGERPRINT ) ) sys.authenticate( "Confirm to log out", "Cancel" ); sys.addEventListener( KlugSystem.AUTH_SUCCESS, onConfirmed ); sys.addEventListener( KlugSystem.AUTH_FAILED, onFailed ); // sys.lastAuthError: -2 cancel, -3 fallback
API overview
| KlugSystem.getInstance() | Returns the single instance. |
| openBrowser(url, toolbarColor) | Opens the in-app browser; BROWSER_CLOSED when the user is back. |
| isReachable() / isWWAN() | Online at all / on mobile data. |
| startNetworkWatch() / stopNetworkWatch() | NETWORK_CHANGE on every change. |
| canAuthenticate(type) | BIOMETRY_FINGERPRINT or BIOMETRY_FACE available and enrolled. |
| authenticate(reason, cancelLabel) | Shows the system prompt; AUTH_SUCCESS or AUTH_FAILED. |
| lastAuthError | Error of the last AUTH_FAILED: -2 cancel, -3 fallback, -4 system cancel, -8 locked out. |
| cancelAuthenticate() | Closes a running prompt. |
Requirements
| AIR SDK | 51.x (HARMAN) |
| iOS | iOS 13 or later |
| Android | Android 6 or later; biometrics Android 9 or later |
| Permissions | Android: USE_BIOMETRIC, ACCESS_NETWORK_STATE · iOS: NSFaceIDUsageDescription |