Commit cfbfc73f176deb6f9f335527345f0f7847c88b39
1 parent
8e5a26f1
feat(ui):增加flutter激活标记,方便applehealth回调判断app是否是存活态
Showing
2 changed files
with
13 additions
and
0 deletions
| 1 | +import 'dart:async'; | ||
| 2 | + | ||
| 1 | import 'package:doublefeel_flutter/app/modules/friends/controllers/friend_trend_controller.dart'; | 3 | import 'package:doublefeel_flutter/app/modules/friends/controllers/friend_trend_controller.dart'; |
| 2 | import 'package:doublefeel_flutter/app/modules/friends/controllers/friends_controller.dart'; | 4 | import 'package:doublefeel_flutter/app/modules/friends/controllers/friends_controller.dart'; |
| 3 | import 'package:doublefeel_flutter/core/constants/flutter_bridge_method_name.dart'; | 5 | import 'package:doublefeel_flutter/core/constants/flutter_bridge_method_name.dart'; |
| @@ -44,6 +46,7 @@ class HomeController extends GetxController { | @@ -44,6 +46,7 @@ class HomeController extends GetxController { | ||
| 44 | void onInit() { | 46 | void onInit() { |
| 45 | super.onInit(); | 47 | super.onInit(); |
| 46 | _mainChannel.setMethodCallHandler(_handleNativeMethodCall); | 48 | _mainChannel.setMethodCallHandler(_handleNativeMethodCall); |
| 49 | + unawaited(_markAppActivated()); | ||
| 47 | isFromOnboard = Get.arguments?['isFromOnboard'] ?? false; | 50 | isFromOnboard = Get.arguments?['isFromOnboard'] ?? false; |
| 48 | SchedulerBinding.instance.addPostFrameCallback((_) async { | 51 | SchedulerBinding.instance.addPostFrameCallback((_) async { |
| 49 | try { | 52 | try { |
| @@ -64,6 +67,15 @@ class HomeController extends GetxController { | @@ -64,6 +67,15 @@ class HomeController extends GetxController { | ||
| 64 | }); | 67 | }); |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 70 | + Future<void> _markAppActivated() async { | ||
| 71 | + try { | ||
| 72 | + await _mainChannel | ||
| 73 | + .invokeMethod<bool>(FlutterBridgeMethodName.appActivited); | ||
| 74 | + } catch (error) { | ||
| 75 | + debugPrint('[HomeController] app activation mark failed: $error'); | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + | ||
| 67 | @override | 79 | @override |
| 68 | void onClose() { | 80 | void onClose() { |
| 69 | _mainChannel.setMethodCallHandler(null); | 81 | _mainChannel.setMethodCallHandler(null); |
| @@ -4,4 +4,5 @@ class FlutterBridgeMethodName { | @@ -4,4 +4,5 @@ class FlutterBridgeMethodName { | ||
| 4 | static const handleFlutterUrl = 'handleFlutterUrl'; | 4 | static const handleFlutterUrl = 'handleFlutterUrl'; |
| 5 | static const healthDataUpdated = 'healthDataUpdated'; | 5 | static const healthDataUpdated = 'healthDataUpdated'; |
| 6 | static const uploadHealthData = 'uploadHealthData'; | 6 | static const uploadHealthData = 'uploadHealthData'; |
| 7 | + static const appActivited = 'appActivited'; | ||
| 7 | } | 8 | } |
-
Please register or login to post a comment