Commit cfbfc73f176deb6f9f335527345f0f7847c88b39

Authored by 权海
1 parent 8e5a26f1

feat(ui):增加flutter激活标记,方便applehealth回调判断app是否是存活态

import 'dart:async';
import 'package:doublefeel_flutter/app/modules/friends/controllers/friend_trend_controller.dart';
import 'package:doublefeel_flutter/app/modules/friends/controllers/friends_controller.dart';
import 'package:doublefeel_flutter/core/constants/flutter_bridge_method_name.dart';
... ... @@ -44,6 +46,7 @@ class HomeController extends GetxController {
void onInit() {
super.onInit();
_mainChannel.setMethodCallHandler(_handleNativeMethodCall);
unawaited(_markAppActivated());
isFromOnboard = Get.arguments?['isFromOnboard'] ?? false;
SchedulerBinding.instance.addPostFrameCallback((_) async {
try {
... ... @@ -64,6 +67,15 @@ class HomeController extends GetxController {
});
}
Future<void> _markAppActivated() async {
try {
await _mainChannel
.invokeMethod<bool>(FlutterBridgeMethodName.appActivited);
} catch (error) {
debugPrint('[HomeController] app activation mark failed: $error');
}
}
@override
void onClose() {
_mainChannel.setMethodCallHandler(null);
... ...
... ... @@ -4,4 +4,5 @@ class FlutterBridgeMethodName {
static const handleFlutterUrl = 'handleFlutterUrl';
static const healthDataUpdated = 'healthDataUpdated';
static const uploadHealthData = 'uploadHealthData';
static const appActivited = 'appActivited';
}
... ...