NLDClient-yudde/Tool/sdk_packages/DeviceHelper_iOS/README.md

31 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# DeviceIdentifiers.m
用于向 iOS (Xcode) 原生层请求获取设备广告标识符 (IDFA) 与供应商标识符 (IDFV) 的 Unity 桥接脚本。
---
## 注意点
- IDFA (广告标识符) —— 异步获取
*授权弹窗:获取 IDFA 必须调起 iOS 系统原生的 AppTrackingTransparency 弹窗,只有在用户主动允许追踪后才可获取真实 IDFA。
* 异步回调:由于需要等待用户交互,此过程为异步操作。
* 回调目标:获取结果会通过 UnitySendMessage 传递给 Unity。请务必确保 Unity 场景中存在名为 GameLauncher 的 GameObject,并已挂载接收回调的方法。
- IDFV (供应商标识符) —— 同步获取
* 直接获取:IDFV 为设备厂商 ID,无需经过用户授权弹窗,可直接在调用时同步获取并返回结果。
- 自动触发机制 (App 启动即弹窗)
* 默认行为:代码内实现了 onAppDidBecomeActive 监听。App 每次启动并进入活跃状态时,将自动调起 IDFA 请求弹窗。
* 修改建议:若项目业务逻辑不需要在 App 刚启动时就弹出授权框(例如需要延迟到特定关卡或场景再弹),请在源码中手动删除或注释掉 onAppDidBecomeActive 相关的监听与函数体。
## Xcode 工程配置须知 (重要)
- 添加系统库:
在 Xcode -> Target -> Build Phases -> Link Binary With Libraries 中,添加以下框架:
* AdSupport.framework
* AppTrackingTransparency.framework
- 配置隐私描述:
在 Info.plist 中必须添加跟踪权限的用途描述,否则弹窗无法显示且会导致应用崩溃或拒审:
* Key: Privacy - Tracking Usage Description (NSUserTrackingUsageDescription)
* Value: (请填写向用户解释为何需要追踪的文案)