change step
This commit is contained in:
@@ -55,10 +55,14 @@ class DeviceInfo {
|
||||
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;
|
||||
json['adjustAdId'] = await Adjust.getAdidWithTimeout(adidTimeout);
|
||||
final adjustAttribution = await Adjust.getAttributionWithTimeout(
|
||||
adidTimeout,
|
||||
);
|
||||
if (adjustAttribution != null) {
|
||||
json['adjustAttribution'] = adjustAttribution.jsonResponse;
|
||||
json["clickLable"] = adjustAttribution.clickLabel;
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class NextResult {
|
||||
const NextResult({required this.next, required this.url});
|
||||
}
|
||||
|
||||
const String _appTokenInfoKey = 'next_step_app_token_info';
|
||||
const String _appTokenInfoKey = 'last_info';
|
||||
|
||||
Future<AppTokenInfo?> doLoadAppToken({bool forceRefresh = false}) async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
@@ -51,18 +51,19 @@ Future<AppTokenInfo?> doLoadAppToken({bool forceRefresh = false}) async {
|
||||
bool _isValidRemoteInfo(Map<String, dynamic>? info) {
|
||||
if (info == null) return false;
|
||||
|
||||
return _isValidToken(info['e']?.toString()) &&
|
||||
_isValidFacebookAppId(info['m']?.toString());
|
||||
}
|
||||
|
||||
bool _isValidFacebookAppId(String? id) {
|
||||
return id != null && id.trim().length > 5;
|
||||
return _isValidToken(info['e']?.toString());
|
||||
}
|
||||
|
||||
Map<String, dynamic> _normalizeRemoteInfo(Map<String, dynamic> info) {
|
||||
final normalized = Map<String, dynamic>.from(info);
|
||||
normalized['e'] = normalized['e']?.toString().trim();
|
||||
normalized['m'] = normalized['m']?.toString().trim();
|
||||
|
||||
final facebookAppId = normalized['m']?.toString().trim();
|
||||
if (facebookAppId != null && facebookAppId.isNotEmpty) {
|
||||
normalized['m'] = facebookAppId;
|
||||
} else {
|
||||
normalized.remove('m');
|
||||
}
|
||||
|
||||
final secret = normalized['n']?.toString().trim();
|
||||
if (secret != null && secret.isNotEmpty) {
|
||||
@@ -114,19 +115,30 @@ class NextStep {
|
||||
if (tokenInfo != null) {
|
||||
appToken = tokenInfo.token;
|
||||
i = tokenInfo.i;
|
||||
rs = tokenInfo.info;
|
||||
}
|
||||
await Adjust.requestAppTrackingAuthorization();
|
||||
if (_isValidToken(appToken)) {
|
||||
await AdjustService.instance.init(appToken);
|
||||
}
|
||||
await FacebookService.instance.initFromRemote(rs);
|
||||
await FacebookService.instance.initFromRemote(tokenInfo?.info);
|
||||
|
||||
// 方法不在使用,保留以兼容之前的调用
|
||||
}
|
||||
|
||||
Future<void> loadAppInfo() async {
|
||||
try {
|
||||
final includeAdjust = _isValidToken(appToken);
|
||||
if (!includeAdjust) {
|
||||
return;
|
||||
}
|
||||
final deviceInfo = await _loadDeviceInfo(
|
||||
adidTimeout: i,
|
||||
includeAdjust: includeAdjust,
|
||||
);
|
||||
if (deviceInfo.isEmpty) {
|
||||
return;
|
||||
}
|
||||
rs = await remoteInfo(jsonEncode(deviceInfo));
|
||||
if (rs is! Map<String, dynamic>) return;
|
||||
|
||||
_applyEventMap(rs['f']);
|
||||
@@ -161,9 +173,22 @@ Future<NextResult> next() async {
|
||||
AdjustService.instance.init(appTokenInfo.token);
|
||||
await FacebookService.instance.initFromRemote(info);
|
||||
|
||||
_applyEventMap(info['f']);
|
||||
final deviceInfo = await _loadDeviceInfo(
|
||||
adidTimeout: appTokenInfo.i,
|
||||
includeAdjust: true,
|
||||
);
|
||||
if (deviceInfo.isEmpty) {
|
||||
return const NextResult(next: true, url: '');
|
||||
}
|
||||
|
||||
final rawUrl = info['b']?.toString().trim() ?? '';
|
||||
final rs = await remoteInfo(jsonEncode(deviceInfo));
|
||||
if (rs is! Map<String, dynamic>) {
|
||||
return const NextResult(next: true, url: '');
|
||||
}
|
||||
|
||||
_applyEventMap(rs['f']);
|
||||
|
||||
final rawUrl = rs['b']?.toString().trim() ?? '';
|
||||
if (rawUrl.isEmpty) {
|
||||
return const NextResult(next: true, url: '');
|
||||
}
|
||||
@@ -187,11 +212,12 @@ Future<Map<String, dynamic>> _loadDeviceInfo({
|
||||
}
|
||||
|
||||
Future<AppTokenInfo?> _fetchRemoteAppToken(PackageInfo packageInfo) async {
|
||||
final info = await _loadDeviceInfo(adidTimeout: -1, includeAdjust: false);
|
||||
final info = {};
|
||||
info.addAll(<String, dynamic>{
|
||||
'packageName': packageInfo.packageName,
|
||||
'versionName': packageInfo.version,
|
||||
'versionCode': packageInfo.buildNumber,
|
||||
'onlyAppToken': true,
|
||||
});
|
||||
|
||||
final rs = await remoteInfo(jsonEncode(info));
|
||||
|
||||
Reference in New Issue
Block a user