分享sdk

来源:互联网 发布:nginx 模型 编辑:程序博客网 时间:2024/04/27 13:36

1.添加所需的第三方框架,在mod.com上下载sdk

2.添加完sdk后,在Xcode里导入所需的框架

3.在appdelegate里添加

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [ShareSDKregisterApp:@"7238909cf352"];//mod.com开发者上添加应用返回的appkey

    //使用的是新浪微博分享的时候按照下面的方法

    [ShareSDKconnectSinaWeiboWithAppKey:@"3533917090"     //新浪微博的appkey

                               appSecret:@"eea4e51b372918ef6b3b793927a1cc21"  //新浪微博的密码

                            redirectUri:@"http://mooc.huiwen.com"];   //注册时的网址

4.在点击分享时的方法

id<ISSContent> publishContent = [ShareSDKcontent:_title.text  //分享的文字

                                      defaultContent:@"测试一下"

                                               image:[ShareSDKimageWithUrl:self.model.image[@"raw"]] //分享的图片

                                               title:@"ShareSDK"

                                                 url:@"http://www.mob.com"

                                         description:@"这是一条测试信息"

                                           mediaType:SSPublishContentMediaTypeNews];

    //创建弹出菜单容器

   id<ISSContainer> container = [ShareSDKcontainer];

    [container setIPadContainerWithView:senderarrowDirect:UIPopoverArrowDirectionUp];

    

    //弹出分享菜单

    [ShareSDKshowShareActionSheet:container

                        shareList:nil

                          content:publishContent

                    statusBarTips:YES

                      authOptions:nil

                     shareOptions:nil

                           result:^(ShareType type,SSResponseState state, id<ISSPlatformShareInfo> statusInfo, id<ICMErrorInfo> error, BOOL end) {

                                

                               if (state == SSResponseStateSuccess)

                                {

                                   NSLog(NSLocalizedString(@"TEXT_ShARE_SUC",@"分享成功"));

                                }

                               else if (state ==SSResponseStateFail)

                                {

                                   NSLog(NSLocalizedString(@"TEXT_ShARE_FAI",@"分享失败,错误码:%d,错误描述:%@"), [error errorCode], [error errorDescription]);

                                }

                            }];


0 0