sharesharesdk无UI分享-点击直接跳转到分享

    xiaoxiao2021-03-31  291

    这里是无UI一个个分享的

    #import <ShareSDK/ShareSDK.h>

    #import <ShareSDKUI/ShareSDK+SSUI.h>

    #import <ShareSDKUI/SSUIShareActionSheetStyle.h>

    #import <ShareSDKConnector/ShareSDKConnector.h>

    #import <ShareSDK/ShareSDK+Base.h>

    #import <ShareSDKExtension/ShareSDK+Extension.h>

    #import <TencentOpenAPI/QQApiInterface.h>

    - (IBAction)firstClick:(id)sender {

        [selfgoShare:SSDKPlatformTypeSinaWeibo];

    }

    - (IBAction)secClick:(id)sender {

        [selfgoShare:SSDKPlatformSubTypeWechatSession];

    }

    - (IBAction)thirdClick:(id)sender {

        [selfgoShare:SSDKPlatformSubTypeWechatTimeline];

    }

    - (IBAction)fourthClick:(id)sender {

        [selfgoShare:SSDKPlatformSubTypeQQFriend];

    }

    #pragma mark UI分享

    - (void)goShare:(int)shareType{

        //    NSString *str =  [ShareSDK sdkVer];//3.5.0

        //    BOOL author = [ShareSDK hasAuthorized:SSDKPlatformSubTypeWechatSession];//NO

        

        //1、创建分享参数

        NSArray* imageArray =@[[UIImageimageNamed:@"学易车标"]];

        //(如果要分享网络图片,可以这样传iamge参数 images:@[@"http://mob.com/Assets/images/logo.png?v=20150320"]

        if (imageArray) {

            

            NSMutableDictionary *shareParams = [NSMutableDictionarydictionary];

            [shareParams SSDKSetupShareParamsByText:@"快速使用"

                                             images:imageArray

                                                url:[NSURLURLWithString:@"http://www.baidu.com"]

                                              title:@"学易车"

                                               type:SSDKContentTypeAuto];

            

            /*

             调用shareSDK的无UI分享类型,

             */

            [ShareSDKshare:shareType parameters:shareParamsonStateChanged:^(SSDKResponseState state,NSDictionary *userData, SSDKContentEntity *contentEntity,NSError *error) {

                

                NSLog(@"state=%lu",(unsignedlong)state);

                switch (state) {

                    caseSSDKResponseStateSuccess:

                    {

                        [selfcreatHttpRequst];

                        break;

                    }

                    caseSSDKResponseStateFail:

                    {

                        

                        NSLog(@"%ld",(long)error);

                        NSLog(@"%@",[errordescription]);

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

                        [selfcreatAlertViewWith:@"提示"Message:@"抱歉,您的分享失败了"];

                        break;

                    }

                    caseSSDKResponseStateCancel:

                    {

                        

                        [SVProgressHUDshowSuccessWithStatus:@"您已取消分享"];

                        break;

                    }

                    default:

                        break;

                }

            }];

            

        }

        

    }

    转载请注明原文地址: https://ju.6miu.com/read-665317.html

    最新回复(0)