最近做分享集成了友盟的分享模塊,分享頁面是自己做的沒有用友盟自己的,我的分享就是分享一個圖片,微信朋友可以分享,但是朋友圈分享時候直接彈出來個toast框說發(fā)送失敗,并且log也沒有任何錯誤打印,然后我就懵逼了去問友盟客服,客服服務簡直太差,我說一句話能等半個小時才回復我,而且回復的內(nèi)容并沒有什么卵用,最后經(jīng)過自己的一步一步調試找到了問題。
1.我沒有用友盟的分享頁面要分享就不能用??里面的方法,微信好友的分享方法
[UMSocialData defaultData].extConfig.wechatSessionData.title = @"給你看個好看很的圖片"; [UMSocialData defaultData].extConfig.wechatSessionData.wxMessageType = UMSocialWXMessageTypeImage; [UMSocialData defaultData].extConfig.wechatSessionData.fileData = UIImageJPEGRepresentation(photo.underlyingImage, 0.6); [[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatSession] content:@"這就是要給你看的圖片" image:photo.underlyingImage location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){ if (response.responseCode == UMSResponseCodeSuccess) { NSLog(@"分享成功!"); } }];
[UMSocialData defaultData].extConfig.wechatSessionData.fileData = UIImageJPEGRepresentation(photo.underlyingImage, 0.6);這個就是要設置分享的圖片的內(nèi)容,分享成功
可是我分享朋友圈也這么寫就有問題了,最后發(fā)現(xiàn)朋友圈的圖片不能放到這里。
朋友圈的圖片要放到下面postSNSWithTypes:方法里
[UMSocialData defaultData].extConfig.wechatTimelineData.title = @"給你看個好看很的圖片"; [UMSocialData defaultData].extConfig.wechatTimelineData.wxMessageType = UMSocialWXMessageTypeImage; [[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatTimeline] content:@"這就是要給你看的圖片" image:photo.underlyingImage location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){ if (response.responseCode == UMSResponseCodeSuccess) { NSLog(@"分享成功!"); } }];