MOB iOS platform integration by third-party sharing, custom UI

I. Introduction

  A few years ago I wrote a similar blog, always someone to ask, the code is very old, just last week made a treasure micro-channel payment and payment, so today spend a little time to sort out the next piece of code, integrating the latest MobSDK.

  Why MOB platform?

  Official website: https://www.mob.com/mobService/sharesdk

  A: For the mobile client, third-party sharing and landing are the basic functions, but the popular three-way too much APP, micro letter, QQ, Sina microblogging, Taobao, easy to believe, if the United States did not integrate a shot ,,, special share going to integrate a APP, for developers unfriendly this way, and the role of MOB is that it will integrate all of the basic third-party platform, you can selectively choose when integrated mob want to integrate which several platforms.

    Moreover, mob platform supports double-ended.

Second, integration

  1, integrated directly cocopods it (I am here just to share QQ and micro-channel, and if the project which integrates a micro-channel pay, then, to choose the micro-channel version of the simple integration)

# 主模块(必须)
  pod 'mob_sharesdk'
  pod 'mob_sharesdk/ShareSDKExtension'
  pod 'mob_sharesdk/ShareSDKPlatforms/QQ'
  pod 'mob_sharesdk/ShareSDKPlatforms/WeChat_Lite'

  Note: I am here only integrated micro letters and QQ sharing module, for other modules of their choice

# 平台SDK模块其他平台,按需添加
pod 'mob_sharesdk/ShareSDKPlatforms/RenRen'
pod 'mob_sharesdk/ShareSDKPlatforms/AliPaySocial'
pod 'mob_sharesdk/ShareSDKPlatforms/Kakao'
pod 'mob_sharesdk/ShareSDKPlatforms/Yixin'
pod 'mob_sharesdk/ShareSDKPlatforms/Facebook'
pod 'mob_sharesdk/ShareSDKPlatforms/Messenger'
pod 'mob_sharesdk/ShareSDKPlatforms/Copy'
pod 'mob_sharesdk/ShareSDKPlatforms/Evernote'
pod 'mob_sharesdk/ShareSDKPlatforms/GooglePlus'
pod 'mob_sharesdk/ShareSDKPlatforms/Instagram'
pod 'mob_sharesdk/ShareSDKPlatforms/Instapaper'
pod 'mob_sharesdk/ShareSDKPlatforms/Line'
pod 'mob_sharesdk/ShareSDKPlatforms/Mail'
pod 'mob_sharesdk/ShareSDKPlatforms/SMS'
pod 'mob_sharesdk/ShareSDKPlatforms/WhatsApp'
pod 'mob_sharesdk/ShareSDKPlatforms/MeiPai'
pod 'mob_sharesdk/ShareSDKPlatforms/DingTalk'
under'mob_sharesdk/ShareSDKPlatforms/YouTube'
pod 'mob_sharesdk/ShareSDKPlatforms/Twitter'
pod 'mob_sharesdk/ShareSDKPlatforms/Dropbox'
pod 'mob_sharesdk/ShareSDKPlatforms/DingTalk'
pod 'mob_sharesdk/ShareSDKPlatforms/CMCC'
pod 'mob_sharesdk/ShareSDKPlatforms/Telegram'
pod 'mob_sharesdk/ShareSDKPlatforms/Reddit'
pod 'mob_sharesdk/ShareSDKPlatforms/DouBan'
pod 'mob_sharesdk/ShareSDKPlatforms/Flickr'
pod 'mob_sharesdk/ShareSDKPlatforms/KaiXin'
pod 'mob_sharesdk/ShareSDKPlatforms/LinkedIn'
pod 'mob_sharesdk/ShareSDKPlatforms/MingDao'
pod 'mob_sharesdk/ShareSDKPlatforms/Pinterest'
pod 'mob_sharesdk/ShareSDKPlatforms/Pocket'
pod 'mob_sharesdk/ShareSDKPlatforms/Print'
pod 'mob_sharesdk/ShareSDKPlatforms/TencentWeibo'
pod 'mob_sharesdk/ShareSDKPlatforms/Tumblr'
pod 'mob_sharesdk/ShareSDKPlatforms/VKontakte'
pod 'mob_sharesdk/ShareSDKPlatforms/YouDaoNote'
pod 'mob_sharesdk/ShareSDKPlatforms/ESurfing'
pod 'mob_sharesdk/ShareSDKPlatforms/FacebookAccount'

  2, registration

  2.1, first add two parameters, MOBAppkey and MOBAppSecret two fields in the plist file inside.

 

  2.2, in which the relevant registration method didFinishLaunchingWithOptions platform

// Share Share Register 
    [ShareSDK registPlatforms: ^ (* SSDKRegister platformsRegister) { // register QQ, QQ space 
        [platformsRegister setupQQWithAppId: @ " 101 831 632 " AppKey: @ "Key " ]; 
    }]; 
    
    [ShareSDK registPlatforms: ^ (* SSDKRegister platformsRegister) { // register micro-channel circle of friends 
        [platformsRegister setupWeChatWithAppId: WeiXinPayKey appsecret: @ " Key " universalLink: WeiXinLinks]; 
    }];

  2.3, the info - Add> URL Types inside schemes, micro-letters and QQ, for example, is divided into QQ QQ QQ session and space, of the AppID QQ, the format: "QQ" + AppId hexadecimal (if appId conversion of hexadecimal less than 8 bits at a leading zero, such conversion is: 5FB8B52, as the final fill: QQ05FB8B52 Note: letter converted to uppercase) hex conversion method: echo 'ibase = 10 ; obase = 16; 801312852 '| bc, which is the QQ 801312852 AppID

 

  Note: this is a bit cumbersome, careful to point

  2.4 configured whitelist

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>wechat</string>
        <string>weixin</string>
        <string>weixinULAPI</string>
        <string>sinaweibohd</string>
        <string>sinaweibo</string>
        <string>sinaweibosso</string>
        <string>weibosdk</string>
        <string>weibosdk2.5</string>
        <string>mqqapi</string>
        <string>mqq</string>
        <string>mqqOpensdkSSoLogin</string>
        <string>mqqconnect</string>
        <string>mqqopensdkdataline</string>
        <string>mqqopensdkgrouptribeshare</string>
        <string>mqqopensdkfriend</string>
        <string>mqqopensdkapi</string>
        <string>mqqopensdkapiV2</string>
        <string>mqqopensdkapiV3</string>
        <string>mqqopensdkapiV4</string>
        <string>mqzoneopensdk</string>
        <string>wtloginmqq</string>
        <string>wtloginmqq2</string>
        <string>mqqwpa</string>
        <string>mqzone</string>
        <string>mqzonev2</string>
        <string>mqzoneshare</string>
        <string>wtloginqzone</string>
        <string>mqzonewx</string>
        <string>mqzoneopensdkapiV2</string>
        <string>mqzoneopensdkapi19</string>
        <string>mqzoneopensdkapi</string>
        <string>mqqbrowser</string>
        <string>mttbrowser</string>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
        <string>twitter</string>
        <string>twitterauth</string>
        <string>JChatPro</string>
    </array>

  Note: plist file directly into the inside just fine.

  3, call

  Due to our side uses a custom UI, so calling enlarge vary, directly on the bar code

//点击分享
- (void)userClickShareBtnAction {
    BYShareALertView *shareView = [[BYShareALertView alloc] initWithAlert];
    [shareView showAlert];
    NSMutableDictionary *parameters = [NSMutableDictionary new];
    NSString *byText = :@"分享内容";
    shareView.clickShareBtnBlock = ^(NSInteger tag) {
        switch (tag) {
            case 100:
                //微信
                [parameters SSDKSetupShareParamsByText:byText
                                                ImagesRF Royalty Free: @ [[UIImage imageNamed: @ " Blink " ]] 
                                                   url: [NSURL URLWithString: @ " www.baidu.com " ] 
                                                 title: @ " share the title " 
                                                  of the type: SSDKContentTypeWebPage]; 
                [Self shareWithParameters: the Parameters withShareType: SSDKPlatformSubTypeWechatSession] ; 

                BREAK ;
             Case  101 :
                 // micro-channel circle of friends 
                [parameters SSDKSetupShareParamsByText: byText 
                                                ImagesRF Royalty Free: @ [[UIImage imageNamed: @ " Blink " ]]
                                                   url:[NSURL URLWithString:@"www.baidu.com"]
                                                 title:@"分享标题"
                                                  type:SSDKContentTypeWebPage];
                [self shareWithParameters:parameters withShareType:SSDKPlatformSubTypeWechatTimeline];

                break;
            case 102:
                //QQ
                [parameters SSDKSetupShareParamsByText:byText
                                                images:@[[UIImage imageNamed:@"APPicon"]]
                                                   url:[NSURL URLWithString:@"www.baidu.com"]
                                                 title:@"分享标题"
                                                  type:SSDKContentTypeWebPage];
                [self shareWithParameters:parameters withShareType:SSDKPlatformSubTypeQQFriend];

                break;
            case 103:
                //QQ空间
                [parameters SSDKSetupShareParamsByText:byText
                                                images:@[[UIImage imageNamed:@"APPicon"]]
                                                   url:[NSURL URLWithString:@"http://www.baidu.com"]
                                                 title:@"分享标题"
                                                  type:SSDKContentTypeWebPage];
                [self shareWithParameters:parameters withShareType:SSDKPlatformSubTypeQZone];

                break;
            default:
                break;
        }
    };
}

- (void) shareWithParameters: (NSMutableDictionary * ) dict withShareType: (SSDKPlatformType) type {
    [ShareSDK Share: type Parameters: dict onStateChanged: (State == ^ (SSDKResponseState State, the userData NSDictionary *, * contentEntity SSDKContentEntity, the NSError * error) {
         IF (State == SSDKResponseStateSuccess) { 
            [kKeyWindow makeToast: @ " sharing success " ]; 
        } the else  IF (State == SSDKResponseStateFail) { 
            [kKeyWindow makeToast: @ " does not detect a failure of sharing clients " ]; 
        } the else  IF SSDKResponseStateCancel) { 
            [kKeyWindow makeToast: @ " sharing canceled " ]; 
        } 
    }]; 

}

  Note: in case the situation failed to share, please first check APPID from QQ and micro-channel, Key These parameters are correct.

Third, the summary

  Overall still very simple, the key is QQ micro letter of the relevant Key not apply.

  Next time integrate third-party landed under it, in fact very much the same, calling different methods to obtain picture and nickname Bale.

 

Guess you like

Origin www.cnblogs.com/qiyiyifan/p/11967260.html