2024-01-27 16:05:17 +08:00
|
|
|
|
import 'dart:async';
|
2024-08-19 11:01:37 +08:00
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
import 'dart:io';
|
2024-05-18 14:57:02 +08:00
|
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2024-01-27 16:05:17 +08:00
|
|
|
|
import 'package:flutter/services.dart';
|
2024-09-29 13:47:50 +08:00
|
|
|
|
import 'package:flutter_bugly/flutter_bugly.dart';
|
2024-05-18 14:57:02 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2024-08-27 11:08:44 +08:00
|
|
|
|
import 'package:path/path.dart' as path;
|
2025-01-21 15:12:13 +08:00
|
|
|
|
import 'package:provider/provider.dart';
|
2024-03-09 13:51:42 +08:00
|
|
|
|
import 'package:star_lock/flavors.dart';
|
2025-04-07 14:31:26 +08:00
|
|
|
|
import 'package:star_lock/login/login/starLock_login_logic.dart';
|
2025-04-16 17:59:21 +08:00
|
|
|
|
import 'package:star_lock/login/register/entity/checkIP_entity.dart';
|
2024-06-05 14:21:14 +08:00
|
|
|
|
import 'package:star_lock/mine/about/debug/debug_tool.dart';
|
|
|
|
|
|
import 'package:star_lock/network/api_provider.dart';
|
|
|
|
|
|
import 'package:star_lock/network/api_repository.dart';
|
2024-11-28 14:57:49 +08:00
|
|
|
|
import 'package:star_lock/network/start_chart_api.dart';
|
2025-01-23 14:30:31 +08:00
|
|
|
|
import 'package:star_lock/talk/starChart/handle/impl/debug_Info_model.dart';
|
|
|
|
|
|
import 'package:star_lock/talk/starChart/status/appLifecycle_observer.dart';
|
2025-11-29 14:45:42 +08:00
|
|
|
|
import 'package:star_lock/tools/NativeInteractionTool.dart';
|
2025-04-16 17:59:21 +08:00
|
|
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
2024-05-18 18:25:39 +08:00
|
|
|
|
import 'package:star_lock/tools/bugly/bugly_tool.dart';
|
2025-07-02 17:11:39 +08:00
|
|
|
|
import 'package:star_lock/tools/callkit_handler.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
import 'package:star_lock/tools/device_info_service.dart';
|
2025-04-08 14:34:59 +08:00
|
|
|
|
import 'package:star_lock/tools/eventBusEventManage.dart';
|
2025-04-07 14:31:26 +08:00
|
|
|
|
import 'package:star_lock/tools/jverify_one_click_login.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
import 'package:star_lock/tools/platform_info_services.dart';
|
2025-11-29 14:45:42 +08:00
|
|
|
|
import 'package:star_lock/tools/push/message_management.dart';
|
2025-02-10 09:45:36 +08:00
|
|
|
|
import 'package:star_lock/tools/push/notification_service.dart';
|
2024-06-15 13:35:23 +08:00
|
|
|
|
import 'package:star_lock/tools/push/xs_jPhush.dart';
|
2024-08-27 11:08:44 +08:00
|
|
|
|
import 'package:star_lock/tools/storage.dart';
|
2025-04-16 17:59:21 +08:00
|
|
|
|
import 'package:star_lock/translations/current_locale_tool.dart';
|
2024-05-18 14:57:02 +08:00
|
|
|
|
import 'package:star_lock/translations/trans_lib.dart';
|
2025-11-29 14:45:42 +08:00
|
|
|
|
import 'package:star_lock/tools/remote_unlock_coordinator.dart';
|
2024-05-18 14:57:02 +08:00
|
|
|
|
|
2025-01-10 14:39:47 +08:00
|
|
|
|
import 'apm/apm_helper.dart';
|
2024-05-18 14:57:02 +08:00
|
|
|
|
import 'app.dart';
|
2024-01-27 16:05:17 +08:00
|
|
|
|
import 'app_settings/app_settings.dart';
|
2023-08-02 09:22:39 +08:00
|
|
|
|
import 'tools/store_service.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
2024-01-27 16:05:17 +08:00
|
|
|
|
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
|
|
|
|
|
FutureOr<void> main() async {
|
2024-09-29 13:47:50 +08:00
|
|
|
|
FlutterBugly.postCatchedException(() async {
|
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2024-05-03 18:30:45 +08:00
|
|
|
|
|
2024-12-23 17:12:42 +08:00
|
|
|
|
// 创建并注册 AppLifecycleObserver(用于程序是否进入后台的监听)
|
|
|
|
|
|
AppLifecycleObserver appLifecycleObserver = AppLifecycleObserver();
|
|
|
|
|
|
WidgetsBinding.instance.addObserver(appLifecycleObserver);
|
|
|
|
|
|
|
2025-02-10 09:45:36 +08:00
|
|
|
|
// await ApmHelper.instance.initApp();
|
2024-09-29 13:47:50 +08:00
|
|
|
|
await _setCommonServices();
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
2024-09-29 13:47:50 +08:00
|
|
|
|
// 设置国际化信息
|
|
|
|
|
|
await _initTranslation();
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
2024-09-29 13:47:50 +08:00
|
|
|
|
final bool isLogin = await getLoginStatus();
|
|
|
|
|
|
if (isLogin) {
|
|
|
|
|
|
await privacySDKInitialization();
|
2024-06-05 14:21:14 +08:00
|
|
|
|
}
|
2024-06-01 13:35:03 +08:00
|
|
|
|
|
2024-09-29 13:47:50 +08:00
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
|
|
final bool? openDeBug = await Storage.getBool(isOpenDeBug);
|
|
|
|
|
|
if (openDeBug == true) {
|
|
|
|
|
|
DeBug.showFloatWidget();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-01-22 13:55:43 +08:00
|
|
|
|
|
2025-08-15 13:51:11 +08:00
|
|
|
|
// 如果是ios则初始化获取到voip token
|
|
|
|
|
|
// 上报时判断是否属于国内用户,国内用户不上报token 既不触发callkit
|
2025-07-09 11:23:46 +08:00
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
|
CallKitHandler.setupListener();
|
|
|
|
|
|
String? token = await CallKitHandler.getVoipToken();
|
|
|
|
|
|
print('获取到的VoIP Token: $token');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-20 09:05:30 +08:00
|
|
|
|
runApp(MyApp(isLogin: isLogin));
|
2024-09-29 13:47:50 +08:00
|
|
|
|
});
|
2023-10-12 11:24:41 +08:00
|
|
|
|
|
2024-01-27 16:05:17 +08:00
|
|
|
|
if (AppPlatform.isAndroid) {
|
2024-05-18 14:57:02 +08:00
|
|
|
|
const SystemUiOverlayStyle systemUiOverlayStyle =
|
2024-09-29 13:47:50 +08:00
|
|
|
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
2023-10-12 11:24:41 +08:00
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
|
|
|
|
|
}
|
2024-08-19 11:01:37 +08:00
|
|
|
|
|
|
|
|
|
|
// checkChinese();
|
2023-07-10 17:50:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 设置国际化信息
|
2024-08-29 18:13:00 +08:00
|
|
|
|
Future<void> _initTranslation() async => TranslationLoader.loadTranslation();
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
// 设置包名服务设备信息
|
2024-06-05 14:21:14 +08:00
|
|
|
|
Future<void> _setCommonServices() async {
|
2023-07-10 17:50:31 +08:00
|
|
|
|
await Get.putAsync(() => StoreService().init());
|
2024-06-05 14:21:14 +08:00
|
|
|
|
Get.put(ApiProvider());
|
2024-11-28 14:57:49 +08:00
|
|
|
|
Get.put(StartChartApi());
|
2024-06-05 14:21:14 +08:00
|
|
|
|
Get.put(ApiRepository(Get.find<ApiProvider>()));
|
2024-03-28 09:51:30 +08:00
|
|
|
|
if (F.isLite) {
|
2024-03-09 13:51:42 +08:00
|
|
|
|
//上架审核注释 获取设备信息
|
|
|
|
|
|
// await Get.putAsync(() => DeviceInfoService().init());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await Get.putAsync(() => DeviceInfoService().init());
|
|
|
|
|
|
}
|
2023-11-16 10:04:38 +08:00
|
|
|
|
}
|
2024-06-05 14:21:14 +08:00
|
|
|
|
|
|
|
|
|
|
//关于隐私协议的初始化
|
|
|
|
|
|
Future<void> privacySDKInitialization() async {
|
2025-01-10 14:39:47 +08:00
|
|
|
|
ApmHelper.instance.initSdk();
|
2024-06-05 16:13:56 +08:00
|
|
|
|
await Get.putAsync(() => PlatformInfoService().init());
|
2024-06-05 14:21:14 +08:00
|
|
|
|
await BuglyTool.init();
|
2024-06-25 10:44:26 +08:00
|
|
|
|
// 初始化JPush服务
|
|
|
|
|
|
final XSJPushProvider jpushProvider = XSJPushProvider();
|
|
|
|
|
|
await jpushProvider.initJPushService();
|
2025-02-10 14:05:09 +08:00
|
|
|
|
NotificationService().init(); // 初始化通知服务
|
2025-11-29 14:45:42 +08:00
|
|
|
|
RemoteUnlockCoordinator.init();
|
|
|
|
|
|
NativeInteractionTool().setupPushReceiver();
|
|
|
|
|
|
final Map<String, dynamic>? push =
|
|
|
|
|
|
await NativeInteractionTool().getPendingPush();
|
|
|
|
|
|
if(push != null) {
|
|
|
|
|
|
print('哈哈: $push');
|
|
|
|
|
|
if(push.isNotEmpty) {
|
|
|
|
|
|
// do something
|
|
|
|
|
|
MessageManagement.shuntingBus(push);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-05 14:21:14 +08:00
|
|
|
|
}
|