Search code examples
dartbackgroundbeaconscanning

is it possible to run Scan Beacon when app is Killed


Hello I'm new developer so i need some help Now. I was Bullied app doing Brodcast and Scan Beacon i used flutter_beacon 0.3.0
and for Brodcast i use beacon_broadcast 0.2.1 its working good for Advertising and Scan event when app is Background,but when app is kill or i remove app from list Running applications the Scan and Brodcast not Working Now My Question is How to running code scan and Brodcast when app is killed or Finished ???


Solution

  • Yes, it is absolutely possible to resume beacon scanning on both Android and iOS after an app is killed. But the specifics of how you do this are different between iOS and Android. Further, the use of non-native development frameworks like FlutterBeacon make things more complicated as the documentation is not as complete for this use case.

    While I am not an expert on FlutterBeacon, I am the lead developer on the underlying Android Beacon Library which it uses under the hood. I am also very familiar with how iOS CoreLocation works (which it also uses under the hood.)

    In general here are the rules to get apps to detect after being killed:

    iOS:

    • Start beacon monitoring (not just ranging) in the didFinishLaunching method of the AppDelegate
    • Obtain ALWAYS Location permission
    • After the app is killed it will be re-launched in the background when all beacons disappear or the first beacon appears in a monitored region.

    Android:

    • Start beacon monitoring in the onCreate method of an Android application class using RegionBootstrap. See here for a discussion on the FlutterBeacon github
    • Obtain BACKGROUND_LOCATION permission from the user.
    • On Android 8+, your app should restart within 25 minutes of being killed and give you a callback to the BootstrapNotifier methods as appropriate.