这是shareSDK iOS文档的地址http://wiki.mob.com/ios简洁版快速集成/,整个shareSDK需要添加的静态包和添加的文件都有说明,我主要说一下我在开发中遇到的一些问题。
1.在腾讯、新浪的官方申请appKey和appSecret的时候,申请的项目必须在腾讯和新浪的官方审核通过,因为没有通过审核,我们在编写代码的时候就不能用appKey和appSecret进行开发。
2.新浪微博SDK需要在项目的Build Settings中的Other Linker Flags添加”-ObjC”。
3.QQ开发在URL Types中添加QQ的AppID,其格式为:”QQ” + AppId的16进制。
//第三方登录(QQ、微信、新浪)
/*
* 设置ShareSDK的appKey,如果尚未在ShareSDK官网注册过App,请移步 到http://mob.com/login登录后台进行应用注册,
* 在将生成的AppKey传入到此方法中。
* 方法中的第二个第三个参数为需要连接社交平台SDK时触发,
* 在此事件中写入连接代码。第四个参数则为配置本地社交平台时触发,根据返回的平台类型来配置平台信息。
* 如果您使用的时服务端托管平台信息时,第二、四项参数可以传入nil,第三项参数则根据服务端托管平台来决定要连接的社交SDK。
*/
[ShareSDK registerApp:@""
activePlatforms:@[
@(SSDKPlatformTypeSinaWeibo),
@(SSDKPlatformTypeWechat),
@(SSDKPlatformTypeQQ)]
onImport:^(SSDKPlatformType platformType)
{
switch (platformType)
{
case SSDKPlatformTypeSinaWeibo:
[ShareSDKConnector connectWeibo:[WeiboSDK class]];
break;
case SSDKPlatformTypeQQ:
[ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]];
break;
case SSDKPlatformTypeWechat:
[ShareSDKConnector connectWeChat:[WXApi class]];
break;
default:
break;
}
}
onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)
{
switch (platformType)
{
case SSDKPlatformTypeSinaWeibo:
[appInfo SSDKSetupSinaWeiboByAppKey:@"appKey" appSecret:@"appSecret" redirectUri:@"http://open.weibo.com/" authType:SSDKAuthTypeBoth];
break;
case SSDKPlatformTypeQQ:
[appInfo SSDKSetupQQByAppId:@"" appKey:@"" authType:SSDKAuthTypeSSO];
break;
case SSDKPlatformTypeWechat:
[appInfo SSDKSetupWeChatByAppId:@"" appSecret:@""];
break;
default:
break;
}
}];
//分享具体的参数作用我没有写,在shareSDK中介绍的非常详细了,如果分享没有图片,url的内置链接就不能起到作用。
NSMutableDictionary *shareParams = [NSMutableDictionary new];
//新浪分享
[shareParams SSDKSetupSinaWeiboShareParamsByText:@"" title:@"" image:@"" url:@"" latitude:@"" longitude:@"" objectID:@"" type:@""];
//微信分享
[shareParams SSDKSetupWeChatParamsByText:@"" title:@"" url:@"" thumbImage:@"" image:@"" musicFileURL:@"" extInfo:@"" fileData:@"" emoticonData:@"" type:@"" forPlatformSubType:@""];
//QQ分享
[shareParams SSDKSetupQQParamsByText:@"" title:@"" url:@"" thumbImage:@"" image:@"" type:@"" forPlatformSubType:@""];
//短信分享(记得开始的时候注册)
[shareParams SSDKSetupSMSParamsByText:@"" title:@"" images:nil attachments:nil recipients:nil type:SSDKContentTypeText];
**短信分享可能出现卡死的问题,可能和使用了IQKeyboardManager第三方框架有关系,只要关闭键盘弹出就没有问题了。
[[IQKeyboardManager sharedManager] setEnable:NO];//注意加
[ShareSDK share:SSDKPlatformTypeSMS parameters:shareParams onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
[[IQKeyboardManager sharedManager] setEnable:YES];//注意加
if (state == SSDKResponseStateSuccess) {
[[[UIApplication sharedApplication].delegate window] makeToast:@"分享成功" duration:2 position:@"center"];
}else{
[[[UIApplication sharedApplication].delegate window] makeToast:@"分享失败" duration:2 position:@"center"];
}
}];
//邮件分享
[shareParams SSDKSetupMailParamsByText:@"" title:@"" images:@"" attachments:nil recipients:nil ccRecipients:nil bccRecipients:nil type:SSDKContentTypeAuto];
网友评论
[shareParams SSDKSetupMailParamsByText:@"" title:@"" images:@"" attachments:nil recipients:nil ccRecipients:nil bccRecipients:nil type:SSDKContentTypeAuto];
你的邮件分享如果加入附件怎么加