集成微信sdk,可以使用
pod 'WechatOpenSDK'
初始化sdk
BOOL result = [WXApi registerApp:KWXAPPID universalLink:KWXUniversalLinks];
if (result == NO) {
NSLog(@"registerApp:KWXAPPID == %d",result);
}
使用微信sdk,注册成功后可以分享多媒体消息和文本消息
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
//发送多媒体消息
req.bText = NO;
/*
WXSceneSession = 0, < 聊天界面
WXSceneTimeline = 1, < 朋友圈
WXSceneFavorite = 2, < 收藏
WXSceneSpecifiedSession = 3, < 指定联系人
WXSceneState = 4, < 状态
*/
req.scene = WXSceneSession;
//生成多媒体消息内容
WXMediaMessage *message = [WXMediaMessage message];
// 标题
message.title = @"标题";
// 描述
message.description = @"描述";
// 缩略图
[message setThumbImage:[UIImage imageNamed:@"imagename"]];
WXWebpageObject *webPageObject = [WXWebpageObject object];
webPageObject.webpageUrl = @"https://www.baidu.com";
message.mediaObject = webPageObject;
req.message = message;
//发送消息
[WXApi sendReq:req completion:^(BOOL success) {
DLog(@"分享成功。%d",success);
}];