提示信息
# 同伴 App — 阿里云 SDK 接入(AlicloudFeedback + APM)
> EMAS 平台:用户反馈 + 性能监控
---
## 一、阿里云 EMAS 配置参数
| 参数 | 值 |
|------|-----|
| App Key (iOS) | `335670805` |
| App Secret (iOS) | `7e54b6689c624b37a3d90b99756397bf` |
| APM RSA Secret | `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCz7QxpbvkauiclVzuTxX5JRinn2eLlam1QUwz2csVxfk8gIX65uf9mAvTVxaIA4mbA1coE+rnYUhyD9F7icw0q9wjgv2SJPLyIUxrog9skdFLkPXbw5IQlECFdfnZA7MKJojh0cYDxC+8YbUq9BUUthxAQuIWf0VuWAPnWbajmRwIDAQAB` |
---
## 二、AlicloudFeedback(用户反馈)
### 2.1 Pod 配置
```ruby
# 需要阿里云私有 Specs 仓库
source 'https://github.com/aliyun/aliyun-specs.git'
pod 'AlicloudFeedback', '~> 3.3'
```
### 2.2 初始化
```swift
// 在 PrivacyService.initSDKs() 中调用(用户同意隐私协议后)
import YWFeedbackFMWK
func initFeedback() {
// AlicloudFeedback 使用 EMAS 统一初始化
// App Key 和 App Secret 通过 AliyunEmasServices-Info.plist 或代码注入
}
```
### 2.3 AliyunEmasServices-Info.plist
在项目根目录创建 `AliyunEmasServices-Info.plist`:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>emas.appKey</key>
<string>335670805</string>
<key>emas.appSecret</key>
<string>7e54b6689c624b37a3d90b99756397bf</string>
<key>emas.bundleId</key>
<string>com.tongban.app</string>
</dict>
</plist>
```
### 2.4 打开反馈页面
```swift
// FeedbackService.swift
import YWFeedbackFMWK
enum FeedbackService {
/// 打开用户反馈页面
@MainActor
static func openFeedback() {
guard let kit = YWFeedbackKit(appKey: "335670805") else { return }
kit.makeFeedbackViewController { viewController, error in
guard let vc = viewController, error == nil else {
print("反馈页面创建失败: \(error?.localizedDescription ?? "")")
return
}
vc.title = "意见反馈"
UIApplication.topViewController?.navigationController?.pushViewController(vc, animated: true)
}
}
/// 获取未读反馈数
static func getUnreadCount() async -> Int {
guard let kit = YWFeedbackKit(appKey: "335670805") else { return 0 }
return await withCheckedContinuation { continuation in
kit.getUnreadCount { count, error in
continuation.resume(returning: error == nil ? Int(count) : 0)
}
}
}
}
```
### 2.5 自定义反馈页面样式
```swift
extension FeedbackService {
/// 配置反馈页面外观
static func configureAppearance(kit: YWFeedbackKit) {
let customUI = kit.defaultCustomUISetting()
customUI?.navigationBarBackground = AppColors.primary
customUI?.navigationBarTitleColor = .white
customUI?.sendButtonBackground = AppColors.primary
}
}
```
---
## 三、隐私合规时序
```
用户同意隐私协议
│
└── PrivacyService.initSDKs()
│
├── 1. IOSSecuritySuite 安全检测
├── 2. OpenIM SDK 初始化
├── 3. 微信 SDK 注册
├── 4. AlicloudFeedback 初始化 ← 此处
└── 5. 支付宝(调用时初始化,无需提前)
```
> **重要**:阿里云 SDK 会采集设备信息(UTDID 等),必须在用户同意隐私协议后才能初始化。
---
## 四、CocoaPods 安装注意
### 4.1 首次安装
```bash
# 添加阿里云私有仓库
pod repo add AliyunRepo https://github.com/aliyun/aliyun-specs.git
# 安装
cd /path/to/同伴
pod install
```
### 4.2 常见问题
| 问题 | 解决方案 |
|------|----------|
| `Unable to find a specification for AlicloudFeedback` | 确保已添加阿里云 source 并执行 `pod repo update AliyunRepo` |
| UTDID 符号重复 | 使用 `AlipaySDK_No_UTDID` 替代 `AlipaySDK-iOS` |
| 编译架构报错 | 确保 `Build Settings > Excluded Architectures` 模拟器排除 `arm64`(如使用非 XCFramework) |
### 4.3 依赖关系
```
AlicloudFeedback (~> 3.3)
├── AlicloudUTDID
├── CoreTelephony.framework
├── SystemConfiguration.framework
├── CoreMotion.framework
├── libz.tbd
└── libsqlite3.0.tbd
```