Background monitoring on Android
lukaspili opened this issue · comments
Users implementing background monitoring are required to subclass FlutterApplication on the Android side:
class App : FlutterApplication() {
override fun onCreate() {
super.onCreate()
BeaconsPlugin.init(this, object : BeaconsPlugin.BackgroundMonitoringCallback {
override fun onBackgroundMonitoringEvent(event: BackgroundMonitoringEvent): Boolean {
// callback when a monitoring event is detected in background
// start flutter activity, or do something else custom in java/kotlin
val intent = Intent(this@App, MainActivity::class.java)
startActivity(intent)
return true
}
})
}
}
Once alarm_manager is fixed (flutter/flutter#17566), this library will expose a similar API: a callback purely written in Dart on the Flutter side.