Background service support on Android (#215)
* - Added support for BLE scanning from background services on Android. - Enhanced `PermissionHandler` to be activity-aware, allowing silent success for already granted permissions when no activity is available. - Updated README with best practices for requesting permissions in foreground before background operations. * Simplify implementation
This commit is contained in:
@@ -209,7 +209,10 @@ class UniversalBlePigeonChannel extends UniversalBlePlatform {
|
||||
}
|
||||
|
||||
Future<void> _ensureInitialized(PlatformConfig? platformConfig) async {
|
||||
// Check bluetooth availability on Apple and Android
|
||||
// Request permissions on Apple and Android
|
||||
// On Android: If activity is available, requests permissions if needed.
|
||||
// If activity is not available (e.g., ForegroundTask), succeeds
|
||||
// if permissions are already granted, fails otherwise.
|
||||
if (defaultTargetPlatform == TargetPlatform.android ||
|
||||
defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
|
||||
Reference in New Issue
Block a user