fix:第一轮跑

This commit is contained in:
jingyun committed 2026-08-24 19:07:31 +08:00
1 parent e834ec7586
commit 33235f450b
56 files changed
+4357 -210

No files matched your search

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -8,9 +10,13 @@ import 'package:video_player/video_player.dart';
import '../../../common/config/app_h5_urls.dart';
import '../../../common/services/device_header_service.dart';
import '../../../common/push/umeng_push_service.dart';
import '../../../common/push/notification_permission.dart';
import '../../../common/privacy/umeng_privacy_consent.dart';
import '../../../common/theme/jinzhi_theme.dart';
import '../../../common/widgets/adaptive.dart';
import '../../../common/router/app_router.dart';
import '../../../common/tracking/umeng_service.dart';
class PrivacyConsentPage extends StatefulWidget {
const PrivacyConsentPage({super.key});
@@ -47,12 +53,46 @@ class _PrivacyConsentPageState extends State<PrivacyConsentPage> {
Future<void> _agree() async {
await DeviceHeaderService.to.markPrivacyAgreed();
await DeviceHeaderService.to.ensureInitialized();
if (mounted) context.go(AppRoutes.assets);
if (mounted) {
context.go(AppRoutes.assets);
WidgetsBinding.instance.addPostFrameCallback((_) {
_completePostConsentInitialization();
});
}
}
Future<void> _completePostConsentInitialization() async {
// Consent navigation must never depend on an optional native SDK. The
// calls below still run in order, but failures are retried by normal app
// startup instead of trapping the user on the consent page.
try {
await UmengPrivacyConsent.submitGranted();
await UmengService.initIfAllowed();
await UmengPushService.startIfAllowed();
} catch (_) {}
}
Future<void> _enter() async {
await DeviceHeaderService.to.markIosStartupSeen();
if (mounted) context.go(AppRoutes.assets);
if (!mounted) return;
// 首屏跳转与可选 SDK 调用严格解耦。原生初始化、ATT 或网络问题都不得
// 阻断“立即进入”。
context.go(AppRoutes.assets);
WidgetsBinding.instance.addPostFrameCallback((_) {
unawaited(_completeIosPostEnterInitialization());
});
}
Future<void> _completeIosPostEnterInitialization() async {
// iOS 不展示 Android 顶部说明;这里在可见首页后直接请求系统通知授权。
// U-Push 注册保留,供 APNs token/友盟通道建立使用。
try {
await NotificationPermission.requestFromSettings();
} catch (_) {}
try {
await UmengService.requestTrackingAuthorizationIfNeeded();
await UmengPushService.startIfAllowed();
} catch (_) {}
}
@override