getBestIdentifier method
获取最佳的设备标识符
根据平台返回最适合的设备标识符:
- Android: 优先返回 Android ID
- iOS: 优先返回 iOS Device ID
- 备选: 组合ID、设备指纹、安装UUID
Implementation
String? getBestIdentifier() {
// iOS 平台优先使用 iOS Device ID
if (iosDeviceID != null && iosDeviceID!.isNotEmpty) {
return iosDeviceID;
}
// Android 平台优先使用 Android ID
if (androidId != null && androidId!.isNotEmpty) {
return androidId;
}
// 备选1: 组合ID
if (combinedId != null && combinedId!.isNotEmpty) {
return combinedId;
}
// 备选2: 设备指纹
if (deviceFingerprint != null && deviceFingerprint!.isNotEmpty) {
return deviceFingerprint;
}
// 备选3: Keychain UUID (iOS)
if (keychainUUID != null && keychainUUID!.isNotEmpty) {
return keychainUUID;
}
// 备选4: 安装UUID
if (installUuid != null && installUuid!.isNotEmpty) {
return installUuid;
}
// 最后备选: IDFV (iOS)
if (idfv != null && idfv!.isNotEmpty) {
return idfv;
}
return null;
}