mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-19 17:05:33 +10:00
fix foreground service and add notification nav
wraps MaterialApp in WithForegroundService to keep alive when swiped away persists last connected device and clears on manual disconnect to allow reconnect after kill added lifecycle tracking to iOS and keep android notification alive with heartbeat add notification navigation change screen tests to be less brittle address PR commnets
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import 'prefs_manager.dart';
|
||||
|
||||
class LastDeviceStore {
|
||||
static const _prefKeyLastDeviceId = 'bg_last_device_id';
|
||||
static const _prefKeyLastDeviceName = 'bg_last_device_name';
|
||||
|
||||
Future<void> persistLastDevice(
|
||||
String deviceId,
|
||||
String deviceDisplayName,
|
||||
) async {
|
||||
final prefs = PrefsManager.instance;
|
||||
await prefs.setString(_prefKeyLastDeviceId, deviceId);
|
||||
await prefs.setString(_prefKeyLastDeviceName, deviceDisplayName);
|
||||
}
|
||||
|
||||
String? getPersistedDeviceId() {
|
||||
final prefs = PrefsManager.instance;
|
||||
final deviceId = prefs.getString(_prefKeyLastDeviceId);
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
String? getPersistedDeviceName() {
|
||||
final prefs = PrefsManager.instance;
|
||||
final displayName = prefs.getString(_prefKeyLastDeviceName);
|
||||
return displayName;
|
||||
}
|
||||
|
||||
Future<void> clearPersistedDevice() async {
|
||||
final prefs = PrefsManager.instance;
|
||||
await prefs.remove(_prefKeyLastDeviceId);
|
||||
await prefs.remove(_prefKeyLastDeviceName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user