接入微信分享 SDK 并配置 Universal Link。
集成 WechatOpenSDK、www.zhifly.cn/suixinkan/ 通用链接与邀请页分享能力,附带 AASA 部署文件与单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
59
suixinkan/Core/WeChat/WeChat.md
Normal file
59
suixinkan/Core/WeChat/WeChat.md
Normal file
@ -0,0 +1,59 @@
|
||||
# WeChat 模块业务逻辑
|
||||
|
||||
## 模块职责
|
||||
|
||||
WeChat 模块封装微信 Open SDK 的注册、Universal Link 回跳与分享能力。当前仅接入分享(文本、网页、图片),不调用微信支付 API。
|
||||
|
||||
## 配置
|
||||
|
||||
- `WeChatConfig`:AppID、Universal Link、AASA 部署参考信息
|
||||
- `Info.plist`:URL Scheme(AppID)、`LSApplicationQueriesSchemes`
|
||||
- `suixinkan.entitlements`:`applinks:www.zhifly.cn`
|
||||
|
||||
### Universal Link
|
||||
|
||||
- 地址:`https://www.zhifly.cn/suixinkan/`(必须以 `/` 结尾)
|
||||
- 运维需在 `https://www.zhifly.cn/.well-known/apple-app-site-association` 部署 AASA 文件
|
||||
- 示例见 [`docs/apple-app-site-association.example.json`](../../docs/apple-app-site-association.example.json)
|
||||
|
||||
### 微信开放平台
|
||||
|
||||
移动应用开发信息需填写:
|
||||
|
||||
| 字段 | 值 |
|
||||
|------|-----|
|
||||
| iOS Bundle ID | `com.yuanzhixiang.suixinkan` |
|
||||
| Universal Links | `https://www.zhifly.cn/suixinkan/` |
|
||||
|
||||
## 核心类型
|
||||
|
||||
| 类型 | 职责 |
|
||||
|------|------|
|
||||
| `WeChatManager` | SDK 注册、URL/UL 回调、`WXApiDelegate` 分享结果 |
|
||||
| `WeChatShareService` | 对外分享 API:`shareText` / `shareWebPage` / `shareImage` |
|
||||
| `WeChatShareSheet` | SwiftUI 分享面板(好友/朋友圈/系统兜底) |
|
||||
| `WeChatThumbImageProcessor` | 缩略图压缩至 32KB 以内 |
|
||||
|
||||
## 回调链路
|
||||
|
||||
1. 启动:`AppDelegate.didFinishLaunching` → `WeChatManager.registerIfNeeded()`
|
||||
2. URL Scheme:`AppDelegate.openURL` + `suixinkanApp.onOpenURL`
|
||||
3. Universal Link:`AppDelegate.continueUserActivity` + `suixinkanApp.onContinueUserActivity`
|
||||
|
||||
## 业务接入
|
||||
|
||||
邀请页 `PhotographerInviteView` 通过 `WeChatShareSheet` 分享邀请链接。
|
||||
|
||||
后续举报、排队二维码等入口可复用 `WeChatShareService`。
|
||||
|
||||
## 真机验收
|
||||
|
||||
1. Safari 访问 `https://www.zhifly.cn/suixinkan/test`,下拉应出现打开 App 入口
|
||||
2. 邀请页点击「分享」→ 微信好友/朋友圈,首次可能出现「正在连接」属正常
|
||||
3. 未安装微信时走系统分享兜底
|
||||
|
||||
## 上线前
|
||||
|
||||
- 替换 `WeChatConfig.appID` 与 Info.plist URL Scheme
|
||||
- 确认开放平台 Universal Link 与代码一致
|
||||
- 确认 AASA 文件可公网 HTTPS 访问
|
||||
Reference in New Issue
Block a user