Skip to content

6. Native Components

Mihail Varbanov edited this page Apr 15, 2022 · 2 revisions

RokwirePlugin provides access to the functionality that needs to be handled natively for Android and iOS because it is not supported by Flutter libraries and plugins. It uses MethodChannel to access the native implementations. It exposes the following APIs:

platformVersion

This is a test API that came with the default plugin created by Flutter. It returns the operating system version on the device.

createAndroidNotificationChannel

Creates an Android notification channel for local notifications that is provided to Firebase messaging library. This API is handled in the Android Native side only.

showNotification

Presents a local notification. Used to inform the user about asynchronous events when the application is inactive or resides in the background.

dismissSafariVC

Dismisses the current modal instance of SFSafariViewController. This API is handled in iOS Native side only. Used to dismiss the SFSafariViewController instance that remains on top of the screen after successful OIDC login in iOS.

getDeviceId

Returns a UUID that uniquely identifies the device. This value is preserved across application reinstallations.

getEncryptionKey

Similarly to getDeviceId this API initializes a block of memory with random data and stores it in the permanent device storage. Used to generate and store securely AES encryption keys.

launchApp

Launches external application by deep link URL.

launchAppSettings

Launches system settings application initialized to this application settings page.

locationServices

This API is a gateway to query authorization status and request permission to access device location services.

trackingServices

Similarly to locationServices this API is a gateway to query authorization status and request permission to track user activity in web browsers. This API is implemented only in iOS.

geoFence

This API is a gateway to access GeoFence native service. It is used to monitor whether the user is inside previously defined regions, as well as for BLE beacons ranging.

Android Native

RokwirePlugin

RokwirePlugin handles the simple APIs and provides gateway access to location, tracking and geofence services.

platformVersion

Dispatches the Android version number as defined in android.os.Build.VERSION.RELEASE.

createAndroidNotificationChannel

Creates a notification channel with the requested parameters (ID, name, description, importance) and registers it in the system notification manager. The Native side keeps an instance of this notification channel that is used when presenting notifications from showNotification API.

showNotification

Creates a local notification populated with the requested parameters (title, body). Uses the system notification manager to present the notification in the notification channel created by createAndroidNotificationChannel API.

dismissSafariVC

Not available in Android.

getDeviceId

Returns Settings.Secure.ANDROID_ID value formatted as UIUD.

getEncryptionKey

Returns a base 64 encoded string that contains a randomly generated block of memory stored in encrypted shared application preferences.

launchApp

Starts an activity identified by Intent.ACTION_VIEW deep link intent.

launchAppSettings

Starts settings activity identified by Settings.ACTION_APPLICATION_DETAILS_SETTINGS intent.

LocationServices

LocationServices manages application authorization for accessing location services. The “method” parameter takes the following values that determine the requested service:

queryStatus

Queries the current permission status from LocationManager or Secure Settings based on the device’s OS version.

requestPermission

Requests location services permission for ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION.

TrackingServices

Tracking services are not supported in Android.

GeofenceMonitor

GeofenceMonitor service is responsible for monitoring regions and ranging beacons.

Region Monitor

The service monitors if the device is in a specific region based on android internal GeofencingClient (for location regions) and BeaconManager (for beacon regions). For monitoring beacon regions, the services uses third party SDK: AltBeacon - Android Beacon Library. GeofenceMonitor begins to monitor regions on app startup. When a region is entered or exited, the service sends a notification to Flutter.

  • entering in region - geo_fence.regions.changed and geo_fence.regions.enter
  • exiting from region - geo_fence.regions.changed and geo_fence.regions.exit

Beacon Ranging

The service could start or stop to range beacons only if the device is inside the specified region. For ranging beacons, the service uses third party SDK Altbeacon. When a beacon is successfully ranged, the service send notification to flutter side - geo_fence.beacons.changed with the ranged beacons as parameters.

Utils

Str

Simple string utilities for null/empty checks and conversion of hexadecimal strings to byte array and vice versa.

Map

Utility class to access nested maps fields by path keys.

Base64

Utility class for encoding and decoding Base64 encoded strings.

AppSharedPrefs

Utility class for enhanced access to shared application preferences.

AppSecureSharedPrefs

Utility class for enhanced access to secure shared application preferences.

Beacons

Utility class for working with collections of ALT beacons.

iOS Native

RokwirePlugin

RokwirePlugin handles the simple APIs and provides gateway access to location, tracking and geofence services.

platformVersion

Dispatches the iOS version number as defined in UIDevice.systemVersion API.

createAndroidNotificationChannel

Not available in iOS

showNotification

Creates a notification request populated with the requested parameters (title, body, sound) and uses UNUserNotificationCenter to present the notification request.

dismissSafariVC

Gets the currently presented view controller and if it is an instance of SFSafariViewController dismisses it. Used for dismissing the OIDC login web panel after successful login.

getDeviceId

Returns a randomly generated UUID that is stored securely in the device keychain.

getEncryptionKey

Returns a base 64 encoded string that contains a randomly generated block of memory stored securely in the device keychain.

launchApp

Opens an URL identified by deep link parameter.

launchAppSettings

Opens an URL identified by UIApplicationOpenSettingsURLString.

LocationServices

LocationServices manages application authorization for accessing location services. The “method” parameter takes the following values that determine the requested service:

query

Queries the current authorization status from CLLocationManager without requesting any authorization.

request

Requests location services authorization from CLLocationManager.

TrackingServices

TrackingServices manage authorization for accessing tracking authorization. The “method” parameter takes the following values that determine the requested service:

query

Queries the current authorization status from ATTrackingManager without requesting any authorization.

request

Requests tracking authorization from ATTrackingManager.

RegionMonotor

The native iOS geofence service is handled in RegionMonitor class. It uses CLLocationManager for region monitor and beacon ranging. This service exposes the following APIs:

currentRegions

Queries the regions that the user is currently inside.

monitorRegions

Gets or sets the current set of regions to be monitored by the service.

startRangingBeaconsInRegion

Starts ranging for beacons in a regions.

stopRangingBeaconsInRegion

Stops ranging for beacons in a regions.

beaconsInRegion

Queries the currently detected beacons in a region.

The service fires the following notifications towards Flutter side:

onCurrentRegionsChanged

When the set of monitored regions the user is currently inside gets changed.

onEnterRegion

When the user enters a monitored region.

onExitRegion

When the user exits a monitored region.

onBeaconsInRegionChanged

Then the set of currently detected beacons in a beacon monitored region gets changed.

Utils

NSDictionary (RokwireTypedValue)

This is a NSDictionary extension for type safe access to dictionary fields. Used for type safe access of JSON object members.

NSString (RokwireJson)

This is a NSString extension for type safe parsing JSON strings.

NSObject (RokwireJson)

This is a NSObject extension for JSON data serialization to string..

Security (RokwireUtils)

Provides helpers to access the secure device storage.