iOS:友盟SDK第三方登入 分享及友盟統計的使用

來源:互聯網
上載者:User

標籤:

本文轉載至 http://www.it165.net/pro/html/201503/37101.htmlTag標籤:第三方  
    • view sourceprint?01.#import "UMSocial.h"02.#import "UMSocialWechatHandler.h"03.#import "UMSocialQQHandler.h"04.#import "UMSocialSinaHandler.h"05. 06.//友盟統計07.//友盟統計分析是一款專業的行動裝置 App統計分析工具,致力於為開發人員提供即時、穩定的行動裝置 App統計分析服務,協助開發人員更好地瞭解使用者、最佳化產品以及提升轉化率。友盟統計分析用戶端,可以方便開發人員查看應用資料,隨時隨地掌握應用的運營狀態。08.[MobClickstartWithAppkey:kUMengKeyreportPolicy:SEND_ON_EXITchannelId:nil];/////開啟友盟統計09.[MobClick setAppVersion:XcodeAppVersion];10.[MobClick checkUpdate];11. 12. 13.//友盟授權14.[UMSocialData setAppKey:kUMengKey];15.//設定AppId,設定分享url,預設使用友盟的網址16.[UMSocialWechatHandler setWXAppId:kWXAppID appSecret:kWXAppKey url:@"http://www.yshow.net"];17.//開啟新浪微博的SSO開關18.[UMSocialSinaHandler openSSOWithRedirectURL:@"http://www.yshow.net"];19.//設定分享到<a href="http://www.it165.net/qq/qqkj/" target="_blank" class="keylink">QQ空間</a>的應用Id,和分享url 連結20.[UMSocialQQHandler setQQWithAppId:kQQAppID appKey:kQQAppKey url:@"http://www.yshow.net"];21.//設定支援沒有用戶端情況下使用SSO授權22.[UMSocialQQHandler setSupportWebView:YES];23. 24./**25.這裡處理新浪微博SSO授權之後跳回來,和分享完成之後跳回來26.*/27.- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation28.{29.return  [UMSocialSnsService handleOpenURL:url wxApiDelegate:nil];30.}31. 32./**33.這裡處理新浪微博SSO授權進入新浪微部落格戶端後進入後台,再返回原來應用34.*/35.- (void)applicationDidBecomeActive:(UIApplication *)application36.{37.[UMSocialSnsService  applicationDidBecomeActive];38.}
      view sourceprint?01.#import "UMSocial.h"02.//<a href="http://www.it165.net/qq/" target="_blank" class="keylink">qq</a>登入03.- (void)<a href="http://www.it165.net/qq/" target="_blank" class="keylink">qq</a>BtnClick:(UIButton *)btn04.{05.NSString *platformName = [UMSocialSnsPlatformManager getSnsPlatformString:UMSocialSnsTypeMobileQQ];06.UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToQQ];07.snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){08.NSLog(@"login response is %@",response);09.//擷取微博使用者名稱、uid、token等10.if (response.responseCode == UMSResponseCodeSuccess) {11.UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:platformName];12.NSLog(@"username is %@, uid is %@, token is %@,iconUrl is %@",snsAccount.userName,snsAccount.usid,snsAccount.accessToken,snsAccount.iconURL);13.}14.});15.}16.//新浪登入17.- (void)sinaBtnClick:(UIButton *)btn18.{19.NSString *platformName = [UMSocialSnsPlatformManager getSnsPlatformString:UMSocialSnsTypeSina];20.UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];21.snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){22.NSLog(@"response is %@",response);23.if (response.responseCode == UMSResponseCodeSuccess) {24.UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:platformName];25.NSLog(@"=========%@",snsAccount.accessToken);26.}27.});28.}29. 30.//實現回調方法31.-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response32.{33.if (response.viewControllerType == UMSViewControllerOauth) {34.NSLog(@"didFinishOauthAndGetAccount response is %@",response);35.}36.}
      view sourceprint?01.//分享02.typedef enum03.{04.ShareQZone,05.ShareQQFriend,06.ShareWeiXinFriend,07.ShareQQWB,08.ShareSinaWB,09.}ShareMode;10. 11.#import "UMSocialSnsService.h"12.#import "UMSocialSnsPlatformManager.h"13.#import "UMSocial.h"14. 15.- (void)shareFootViewSureBtnDidClick:(YSShareFootView *)view index:(ShareMode)index16.{17.NSString *shareText = @"wallpaper papehome。 http://www.wallPaper.com/social";             //分享內嵌文字18.UIImage *shareImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:self.sharedImgUrl];          //分享內嵌圖片19. 20.//如果得到分享完成回調,需要設定delegate為self21.// @param snsNames 你要分享到的sns平台類型,該NSArray值是`UMSocialSnsPlatformManager.h`定義的平台名的字串常量,有UMShareToSina,UMShareToTencent,UMShareToRenren,UMShareToDouban,UMShareToQzone,UMShareToEmail,UMShareToSms等22. 23.[UMSocialSnsService presentSnsIconSheetView:self appKey:kUMengKey shareText:shareText shareImage:shareImage shareToSnsNames:@[UMShareToQzone,UMShareToQQ,UMShareToWechatSession,UMShareToTencent,UMShareToSina] delegate:self];24.return;25.}26. 27.//下面得到分享完成的回調28.-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response29.{30.NSLog(@"didFinishGetUMSocialDataInViewController with response is %@",response);31.//根據`responseCode`得到發送結果,如果分享成功32.if(response.responseCode == UMSResponseCodeSuccess)33.{34.//得到分享到的微博平台名35.NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);

iOS:友盟SDK第三方登入 分享及友盟統計的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.