IOS: third-party logon, sharing, and usage of umeng SDK, iossdk

Source: Internet
Author: User

IOS: third-party logon, sharing, and usage of umeng SDK, iossdk

# Import "UMSocial. h "# import" UMSocialWechatHandler. h "# import" UMSocialQQHandler. h "# import" UMSocialSinaHandler. h "// umeng statistics // umeng statistical analysis is a professional mobile application statistical analysis tool dedicated to providing developers with real-time and stable mobile application statistical analysis services, it helps developers better understand users, optimize products, and increase conversion rates. The umeng Statistical Analysis Client allows developers to conveniently view application data and learn the Application Operation Status anytime and anywhere. [MobClickstartWithAppkey: kUMengKeyreportPolicy: Role: nil]; // enable umeng statistics [MobClick setAppVersion: XcodeAppVersion]; [MobClick checkUpdate]; // UMSocialData setAppKey authorized by UMSocialData: kUMengKey]; // set AppId, set share url, by default use UMSocialWechatHandler setWXAppId: kWXAppID appSecret: kWXAppKey url: @ "http://www.yshow.net"]; // enable the SSO switch of Sina Weibo [UMSocialSinaHandler openSSOWithRedirectURL: @ "http://www.yshow.net"]; // set the Id of the app sharing to the QQ space, and the sharing url link [UMSocialQQHandler setQQWithAppId: kQQAppID appKey: kQQAppKey url: @ "http://www.yshow.net"]; // sets support using SSO authorization without a client [UMSocialQQHandler setSupportWebView: YES];/** jump back after Sina Weibo SSO authorization is handled here, and after the sharing is complete, jump back */-(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) annotation {return [UMSocialSnsService handleOpenURL: url wxApiDelegate: nil];}/** handle Sina Weibo SSO authorization to enter the Sina Weibo client and then go to the background, return the original application */-(void) applicationDidBecomeActive :( UIApplication *) application {[UMSocialSnsService applicationDidBecomeActive];}

# Import "UMSocial. h "// qq logon-(void) qqBtnClick :( UIButton *) btn {NSString * platformName = [Response getSnsPlatformString: Signature]; UMSocialSnsPlatform * snsPlatform = [Response token: UMShareToQQ]; snsPlatform. loginClickHandler (self, [UMSocialControllerService defaultControllerService], YES, ^ (UMSocialResponseEntity * response) {NSLog (@ "login response is % @", response ); // obtain the Weibo user name, uid, token, and other if (response. responseCode = Response) {UMSocialAccountEntity * snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey: platformName]; NSLog (@ "username is % @, uid is % @, token is % @, iconUrl is % @ ", snsAccount. userName, snsAccount. usid, snsAccount. accessToken, snsAccount. iconURL) ;}}) ;}// Sina login-(void) sinaBtnClick :( UIButton *) btn {NSString * platformName = [UMSocialSnsPlatformManager getSnsPlatformString: UMSocialSnsTypeSina]; UMSocialSnsPlatform * snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName: UMShareToSina]; snsPlatform. loginClickHandler (self, [UMSocialControllerService defaultControllerService], YES, ^ (UMSocialResponseEntity * response) {NSLog (@ "response is % @", response); if (response. responseCode = Response) {UMSocialAccountEntity * snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey: platformName]; NSLog (@ "==========%@", snsAccount. accessToken) ;}}) ;}// callback method-(void) didFinishGetUMSocialDataInViewController :( UMSocialResponseEntity *) response {if (response. viewControllerType = UMSViewControllerOauth) {NSLog (@ "didFinishOauthAndGetAccount response is % @", response );}}

// Share typedef enum {cmdqzone, cmdqqfriend, cmdweixinfriend, cmdqqwb, ShareSinaWB,} consumer mode; # import "UMSocialSnsService. h "# import" UMSocialSnsPlatformManager. h "# import" UMSocial. h "-(void) define footviewsurebtndidclick :( ys?footview *) view index :( adjust mode) index {NSString * shareText = @" wallpaper papehome. Http://www.wallPaper.com/social "; // share embedded text UIImage * shareImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey: self. sharedImgUrl]; // share the embedded image // If the callback is completed after the sharing is completed, set the delegate to self // @ param snsNames, the NSArray value is 'umsocialsnsplatformmanager. h' is a String constant of the platform name, including UMShareToSina, region, region, UMShareToDouban, UMShareToQzone, UMShareToEmail, UMShareToSms, and other [UMSocialSnsService identifier: self appKey: kUMengKey shareText: shareImage shareToSnsNames: @ [UMShareToQzone, UMShareToQQ, UMShareToWechatSession, UMShareToTencent, UMShareToSina] delegate: self]; return ;}// the callback after sharing is obtained-(void) done :( reply *) response {NSLog (@ "didFinishGetUMSocialDataInViewController with response is % @", response); // obtain the sending Result Based on 'responsecode'. if the sharing succeeds, if (response. responseCode = UMSResponseCodeSuccess) {// The Weibo platform name NSLog (@ "share to sns name is % @", [[response. data allKeys] objectAtIndex: 0]) ;}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.