From 67d8df48ae71567dfd0ae4cad2a8d84241356c68 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 5 Jun 2026 16:08:28 +0800 Subject: [PATCH] update version --- lib/adjust/adjust_service.dart | 4 +- lib/screens/loading_screen.dart | 155 ++++++++++++++++---------------- lib/utils/device_info.dart | 16 +++- lib/utils/next_setp.dart | 24 ++--- lib/utils/report.dart | 2 +- pubspec.yaml | 2 +- 6 files changed, 107 insertions(+), 96 deletions(-) diff --git a/lib/adjust/adjust_service.dart b/lib/adjust/adjust_service.dart index 8fe6146..233637a 100644 --- a/lib/adjust/adjust_service.dart +++ b/lib/adjust/adjust_service.dart @@ -51,9 +51,7 @@ class AdjustService { final config = AdjustConfig(appToken, environment); config.isCostDataInAttributionEnabled = true; - - await Adjust.requestAppTrackingAuthorization(); - + config.attributionCallback = (AdjustAttribution a) async { debugPrint('Adjust attribution: ${a.toString()}'); ReportService.I.attribution = a; diff --git a/lib/screens/loading_screen.dart b/lib/screens/loading_screen.dart index f404e5a..b441d67 100644 --- a/lib/screens/loading_screen.dart +++ b/lib/screens/loading_screen.dart @@ -1,21 +1,21 @@ import 'dart:async'; -import 'dart:collection'; -import 'dart:convert'; +// import 'dart:collection'; +// import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../adjust/adjust_service.dart'; -import '../utils/aes_decrypt.dart'; +// import '../adjust/adjust_service.dart'; +// import '../utils/aes_decrypt.dart'; import '../utils/next_setp.dart'; import '../utils/report.dart'; const String _webLoginTokenKey = 'assammzeeeass'; const int _maxWebViewProgressShowCount = 1; -const String bridgeInjectScript = - r'''lRpL+9TjSWvxRtAeNe3FCf8MtDcHDybBZ18LVDHp06Glxe6ITkTNRyyJqAPwbxuFOY6i0vsxF+6h8YzBBeq8A0I3Zye5I2Rk/TC3mCFBgZan0VNutDEJfdHIK/BdDKFWAbx6fxAZGvBM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BnASZ5mskHGrGPn7Gu9xjmyASQndAW+VZuerDRs4Mo6dzRzeU8nKOD14N376joNgbXk6W4IcpEEmT7K/l5GqTsTFZyMfbrRwWOIIvc+29zAP+ugl8M6lt8Yhu37H/GDKU5OAh/eC159fTPNRvNVRLAUotkxUeYsf3k2j2GbNmd0Yd5eRGHCixQqGbcSuHnRdcmYe7UYv69TpE/c4tedsRB3KFUqGiEfHMpHFpMFuTsd0BvN1VvZ27h3mA478luSEITqHlqQ6vf0l5TZBkX+FFKlejqSVGLNFCfQ8cXiIEda4ReygZISfUJjLUrevTvfL7Zqmxhei2GXFgCf/k71ubFeqZbrWoRSakoJ+YgkBkuEE2PrxYrKIirB1qmSV9fmMtC/1QxaAjLvrkL+LKYZpyYX+yFkA43SK674L8hNAbqohqdbhgPd7lIz3SrPZ+4su1BTS4+yS2khB71uQn/BP3WrNFz5bcIsL'''; Future launchURL( String url, { LaunchMode mode = LaunchMode.externalApplication, @@ -69,20 +69,21 @@ class _LoadingScreenState extends State Timer? _webViewHideTimer; URLRequest? _initialUrlRequest; - late final UnmodifiableListView _initialUserScripts; + // late final UnmodifiableListView _initialUserScripts; int _webViewReloadNonce = 0; @override void initState() { super.initState(); // AudioManager.instance.playBgm(); - _initialUserScripts = UnmodifiableListView([ - UserScript( - source: _decryptScript(), - injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START, - forMainFrameOnly: true, - ), - ]); + // _initialUserScripts = UnmodifiableListView([ + // UserScript( + // source: _decryptScript(), + // injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START, + // forMainFrameOnly: true, + // ), + // ]); + ReportService.I.reportInstall(); _startSmoothProgress(); _bootstrap(); @@ -356,59 +357,59 @@ class _LoadingScreenState extends State } } - Future _handleWebMessage(String raw) async { - try { - final rs = jsonDecode(raw); - if (rs is! Map) return; + // Future _handleWebMessage(String raw) async { + // try { + // final rs = jsonDecode(raw); + // if (rs is! Map) return; - final type = rs['type'] as String?; - if (type == null || type.isEmpty) return; + // final type = rs['type'] as String?; + // if (type == null || type.isEmpty) return; - if (type == 'event') { - final event = rs['event'] as String?; - if (event == null || event.isEmpty) { - return; - } - final params = rs['params'] as String?; - var parseParams = {}; - if (params != null && params.isNotEmpty) { - try { - parseParams = jsonDecode(params) as Map; - } catch (_) {} - } - debugPrint('WebView event: $event'); - if (event == "openWindow") { - final url = parseParams['url'] ?? ''; - if (url.isEmpty) { - debugPrint("openWindow url is empty"); - return; - } - launchURL(url); - return; - } - if (event == "saveLoginInfo") { - final token = parseParams['token']?.toString().trim() ?? ''; - if (token.isNotEmpty) { - final prefs = await SharedPreferences.getInstance(); - await prefs.setString(_webLoginTokenKey, token); - } - return; - } - AdjustService.instance.trackEventWithName(event, parseParams); - } - } catch (_) {} - } + // if (type == 'event') { + // final event = rs['event'] as String?; + // if (event == null || event.isEmpty) { + // return; + // } + // final params = rs['params'] as String?; + // var parseParams = {}; + // if (params != null && params.isNotEmpty) { + // try { + // parseParams = jsonDecode(params) as Map; + // } catch (_) {} + // } + // debugPrint('WebView event: $event'); + // if (event == "openWindow") { + // final url = parseParams['url'] ?? ''; + // if (url.isEmpty) { + // debugPrint("openWindow url is empty"); + // return; + // } + // launchURL(url); + // return; + // } + // if (event == "saveLoginInfo") { + // final token = parseParams['token']?.toString().trim() ?? ''; + // if (token.isNotEmpty) { + // final prefs = await SharedPreferences.getInstance(); + // await prefs.setString(_webLoginTokenKey, token); + // } + // return; + // } + // AdjustService.instance.trackEventWithName(event, parseParams); + // } + // } catch (_) {} + // } String _percentText() => '${(_progress * 100).round()}%'; - String _decryptScript() { - return AesDecrypt.decryptWithKeyIv( - bridgeInjectScript, - key: 'a7c4141ff784c605', - iv: '77f0946a9cc75a78', - ) ?? - ''; - } + // String _decryptScript() { + // return AesDecrypt.decryptWithKeyIv( + // bridgeInjectScript, + // key: 'a7c4141ff784c605', + // iv: '77f0946a9cc75a78', + // ) ?? + // ''; + // } @override Widget build(BuildContext context) { @@ -516,21 +517,21 @@ class _LoadingScreenState extends State mediaPlaybackRequiresUserGesture: false, allowsInlineMediaPlayback: true, ), - initialUserScripts: _initialUserScripts, - onWebViewCreated: (controller) async { - controller.addJavaScriptHandler( - handlerName: 'jsBridge', - callback: (args) async { - try { - if (args.isEmpty) return null; - final raw = args.first; - if (raw == null) return null; - await _handleWebMessage(raw.toString()); - } catch (_) {} - return null; - }, - ); - }, + // initialUserScripts: _initialUserScripts, + // onWebViewCreated: (controller) async { + // controller.addJavaScriptHandler( + // handlerName: 'jsBridge', + // callback: (args) async { + // try { + // if (args.isEmpty) return null; + // final raw = args.first; + // if (raw == null) return null; + // await _handleWebMessage(raw.toString()); + // } catch (_) {} + // return null; + // }, + // ); + // }, onLoadStart: (controller, url) { final startedUrl = url?.toString(); if (startedUrl != null && startedUrl.isNotEmpty) { diff --git a/lib/utils/device_info.dart b/lib/utils/device_info.dart index 1c3fe4c..625f6de 100644 --- a/lib/utils/device_info.dart +++ b/lib/utils/device_info.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:adjust_sdk/adjust.dart'; import 'package:flutter/foundation.dart'; import 'package:uuid/uuid.dart'; import 'package:android_id/android_id.dart'; @@ -18,10 +19,10 @@ class DeviceInfo { Future> deviceInfo({ int adidTimeout = -1, bool includeInstallReferrer = false, + bool includeAdjust = true, }) async { final Map json = {}; - try { adidTimeout = getTimeOut(adidTimeout); final packageInfo = await PackageInfo.fromPlatform(); @@ -44,15 +45,24 @@ class DeviceInfo { json["model"] = androidInfo.model; json["device"] = androidInfo.device; json["androidId"] = await getAndroidId(); - } else if (Platform.isIOS) { final iosInfo = await devicePlugin.iosInfo; json["osVersion"] = iosInfo.systemVersion; json["model"] = iosInfo.model; json["device"] = iosInfo.modelName; json["androidId"] = iosInfo.identifierForVendor; + json['idfv'] = iosInfo.identifierForVendor; + try { + json['idfa'] = await Adjust.getIdfa(); + if (includeAdjust) { + json['adjustAdId'] = await Adjust.getAdid(); + final adjustAttribution = await Adjust.getAttribution(); + json['adjustAttribution'] = adjustAttribution.jsonResponse; + json["clickLable"] = adjustAttribution.clickLabel; + } + } catch (_) {} + debugPrint("$iosInfo"); - } if (includeInstallReferrer) { diff --git a/lib/utils/next_setp.dart b/lib/utils/next_setp.dart index 4176a18..93e57a4 100644 --- a/lib/utils/next_setp.dart +++ b/lib/utils/next_setp.dart @@ -75,17 +75,25 @@ class NextStep { static final NextStep I = NextStep._(); Future loadAppToken() async { - await Adjust.requestAppTrackingAuthorization(); + final tokenInfo = await doLoadAppToken(); + if (tokenInfo != null) { + appToken = tokenInfo.token; + } + await Adjust.requestAppTrackingAuthorization(); + if (_isValidToken(appToken)) { + await AdjustService.instance.init(appToken); + } + // 方法不在使用,保留以兼容之前的调用 } Future loadAppInfo() async { try { - final deviceInfo = await _loadDeviceInfo(adidTimeout: i); + bool includeAdjust = _isValidToken(appToken); + final deviceInfo = await _loadDeviceInfo(adidTimeout: i,includeAdjust: includeAdjust); if (deviceInfo.isEmpty) { return; } - rs = await remoteInfo(jsonEncode(deviceInfo)); } catch (e) { debugPrint("loadAppInfo error $e"); @@ -97,11 +105,6 @@ class NextStep { if (rs is! Map) { return ""; } - final token = rs['e']?.toString().trim(); - if (token != null && _isValidToken(token)) { - AdjustService.instance.init(token); - } - _applyEventMap(rs['f']); final rawUrl = rs['b']?.toString().trim() ?? ''; _j = parseInfo(rs['j']); return rawUrl; @@ -113,7 +116,6 @@ class NextStep { Future next() async { try { - final appTokenInfo = await doLoadAppToken(); if (appTokenInfo == null || !_isValidToken(appTokenInfo.token)) { return const NextResult(next: true, url: ''); @@ -146,8 +148,8 @@ Future next() async { } } -Future> _loadDeviceInfo({required int adidTimeout}) async { - return await DeviceInfo.I.deviceInfo(adidTimeout: adidTimeout); +Future> _loadDeviceInfo({required int adidTimeout,bool includeAdjust = true}) async { + return await DeviceInfo.I.deviceInfo(adidTimeout: adidTimeout,includeAdjust: includeAdjust); } Future _fetchRemoteAppToken(PackageInfo packageInfo) async { diff --git a/lib/utils/report.dart b/lib/utils/report.dart index 6cde4b1..ebdcf02 100644 --- a/lib/utils/report.dart +++ b/lib/utils/report.dart @@ -85,7 +85,7 @@ class ReportService { String eventName, Map? params, ) async { - final deviceInfo = await DeviceInfo.I.deviceInfo(); + final deviceInfo = await DeviceInfo.I.deviceInfo(includeAdjust: false); Map reportData = { 'event': eventName, 'params': params ?? {}, diff --git a/pubspec.yaml b/pubspec.yaml index 75f212d..9268558 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 +version: 1.0.1+2 environment: sdk: ^3.11.4