ShareSDK中微信分享類型限制:
SSDKContent *content = [SSDKContent contentWithNewsTitle:@"分享標題"
content:@"分享文本內容"
image:[UIImage screenshot]
url:@"https://yourdomain.com/placeholder" // 必須提供
type:SSDKContentTypeNews];
缺點:用戶點擊會跳轉到佔位鏈接,體驗一般。
// 1. 實現 SSDKCustomShareViewDelegate
// 2. 配置自定義分享視圖
SSDKPlatformShareViewConfig *config = [SSDKPlatformShareViewConfig defaultConfig];
config.customView = [[MyCustomShareView alloc] init];
config.shareType = SSDKContentTypeAuto;
// 3. 在回調中構建純圖文內容
- (void)customShareView:(UIView *)view didClickPlatform:(SSDKPlatformType)platformType {
SSDKContent *content = [SSDKContent contentWithText:@"文本"
images:@[screenshotImage]
url:nil // 可為nil
type:SSDKContentTypeAuto];
[ShareSDK share:SSDKPlatformTypeWechat parameters:content onStateChanged:^(SSDKResponseState state, id data, NSError *error) {
// 處理結果
}];
}
// 嘗試 Text 類型攜帶圖片 (視 SDK 版本而定)
SSDKContent *content = [SSDKContent contentWithText:@"分享文本"
images:@[screenshotImage]
url:nil
type:SSDKContentTypeText];
| ShareSDK版本 | 支持純圖文無鏈接 | 建議方案 |
|---|---|---|
| 3.x 早期 | 不支持 | 方案一 |
| 3.x 後期 | 部分支持 | 方案三優先嘗試 |
| 4.x+ | 支持自定義 | 方案二最佳 |
SSDKContentTypeText + images 數組 (最新版本通常支持)