UMSocialConfig.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. //
  2. // UMSConfigManager.h
  3. // SocialSDK
  4. //
  5. // Created by Jiahuan Ye on 12-9-15.
  6. // Copyright (c) umeng.com All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "UMSocialDataService.h"
  10. #ifndef __IPHONE_6_0
  11. typedef enum {
  12. UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
  13. UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
  14. UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
  15. UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
  16. UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
  17. UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
  18. UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
  19. } UIInterfaceOrientationMask;
  20. #endif
  21. typedef enum {
  22. UMSocialiToastPositionTop = 1000001, //提示位置在屏幕上部
  23. UMSocialiToastPositionBottom, //提示位置在屏幕下部
  24. UMSocialiToastPositionCenter //提示位置在屏幕中间
  25. } UMSocialiToastPosition;
  26. /**
  27. SDK样式主题
  28. */
  29. typedef enum {
  30. UMSocialThemeBlack, //黑色主题
  31. UMSocialThemeWhite //白色主题
  32. } UMSocialTheme;
  33. /**
  34. 设置分享列表页面的Block类型
  35. @param ref 分享列表绘图所用的CGContext对象
  36. @param backgroundView 分享列表的背景图片
  37. @param label 平台文字
  38. */
  39. typedef void (^UMGridViewConfig)(CGContextRef ref, UIImageView *backgroundView, UILabel *label) ;
  40. /**
  41. 设置导航栏的样式的Block类型
  42. @param bar 导航栏
  43. @param closeButton 关闭按钮
  44. @param backButton 返回按钮
  45. @param postButton 发送按钮
  46. @param refreshButton 刷新按钮
  47. @param navigationItem 所在UINavigationController的navigationItem,可以改变相应的标题
  48. */
  49. typedef void (^UMNavigationBarConfig)(UINavigationBar *bar,
  50. UIButton *closeButton,
  51. UIButton *backButton,
  52. UIButton *postButton,
  53. UIButton *refreshButton,
  54. UINavigationItem * navigationItem);
  55. /**
  56. 设置TableViewCell的样式
  57. @param cell UITableViewCell
  58. @param viewControllerType 页面类型
  59. */
  60. typedef void (^UMTableViewCellConfig)(UITableViewCell *cell,UMSViewControllerType viewControllerType);
  61. /**
  62. SDK设置类,负责改变SDK功能配置
  63. */
  64. @interface UMSocialConfig : NSObject
  65. /**
  66. *是否显示loading状态图
  67. */
  68. @property (nonatomic, assign) BOOL hiddenLoadingHUD;
  69. /**
  70. *是否显示状态提示框
  71. */
  72. @property (nonatomic, assign) BOOL hiddenStatusTip;
  73. /**
  74. * 设置分享web url是否转换成回流的url, 默认为NO
  75. */
  76. @property (nonatomic, assign) BOOL isGetInverseFlowUrl;
  77. /**
  78. * 设定分享次数的统计在分享操作之前or之后
  79. * @default YES(分享成功跳转回app后进行统计)
  80. * @discuss
  81. 1、分享跳转app前进行统计,不会出现分享后‘留在app’时没统计上,但若在目标app分享之前取消了分享操作,计数会比实际多计一次。
  82. 2、分享完成并跳转后统计(默认),这个是在‘返回我的app’后进行统计,可能因’留在app‘没返回而没统计上。
  83. */
  84. @property (nonatomic, assign) BOOL statisticsAfterShareEventReturned;
  85. + (UMSocialConfig *)shareInstance;
  86. /**
  87. 设置显示的sns平台类型
  88. @param platformNames 在`UMSocialSnsPlatformManager.h`定义的UMShareToSina、UMShareToTencent、UMShareToQzone、UMShareToRenren、UMShareToDouban、UMShareToEmail、UMShareToSms组成的NSArray
  89. */
  90. + (void)setSnsPlatformNames:(NSArray *)platformNames;
  91. /**
  92. 设置sdk所有页面需要支持屏幕方向.
  93. @param interfaceOrientations 一个bit map(位掩码),ios 6定义的`UIInterfaceOrientationMask`
  94. */
  95. + (void)setSupportedInterfaceOrientations:(UIInterfaceOrientationMask)interfaceOrientations;
  96. /**
  97. 设置社会化组件UI主题,现在有黑色和白色两种
  98. @param theme UI主题
  99. */
  100. + (void) setTheme:(UMSocialTheme)theme;
  101. /**
  102. 设置分享列表页面,Block对象的形参包括有绘制当前线条的CGContex指针,icon背景视图
  103. 例如下面写法
  104. ```
  105. [UMSocialConfig setShareGridViewTheme:^(CGContextRef ref, UIImageView *backgroundView,UILabel *label){
  106. //改变线颜色和线宽
  107. CGContextSetRGBStrokeColor(ref, 0, 0, 0, 1.0);
  108. CGContextSetLineWidth(ref, 1.0);
  109. //改变背景颜色
  110. backgroundView.backgroundColor = [UIColor blackColor];
  111. //添加背景图片
  112. UIImageView *imageView = [[UIImageView alloc] initWithFrame:backgroundView.frame];
  113. imageView.image = [UIImage imageNamed:@"share_bg.png"];
  114. [backgroundView addSubview:imageView];
  115. backgroundView.backgroundColor = [UIColor clearColor];
  116. //改变文字标题的文字颜色
  117. label.textColor = [UIColor blueColor];
  118. //隐藏文字
  119. label.hidden = YES;
  120. }];
  121. ```
  122. @param gridViewConfig 设置分享列表样式的block对象
  123. */
  124. +(void)setShareGridViewTheme:(UMGridViewConfig)gridViewConfig;
  125. /**
  126. 设置导航栏,包括导航栏的UINavigationBar,返回按钮,关闭按钮,发送按钮,刷新按钮和中间的UINavigationItem的样式
  127. 例如下面写法:
  128. ```
  129. [UMSocialConfig setNavigationBarConfig:^(UINavigationBar *bar,
  130. UIButton *closeButton,
  131. UIButton *backButton,
  132. UIButton *postButton,
  133. UIButton *refreshButton,
  134. UINavigationItem * navigationItem){
  135. UIImage * backgroundImage = [UIImage imageNamed:@"UMSocialSDKResourcesNew.bundle/OtherTheme/UMS_nav_bar_bg"];
  136. if ([bar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
  137. [bar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
  138. }
  139. bar.titleTextAttributes = nil;
  140. }];
  141. ```
  142. @param navigationConfig 设置导航栏样式的block对象
  143. navigationConfig 是一个Block对象,传入的参数包括:
  144. @param bar 导航栏
  145. @param closeButton 关闭按钮
  146. @param backButton 返回按钮
  147. @param postButton 发送按钮
  148. @param refreshButton 刷新按钮
  149. @param navigationItem 所在UINavigationController的navigationItem,可以改变相应的标题
  150. */
  151. +(void)setNavigationBarConfig:(UMNavigationBarConfig)navigationConfig;
  152. /**
  153. 设置分享列表页,个人中心页面等的UITableViewCell的样式
  154. @param tableViewCellConfig UITableViewCell的样式配置Block
  155. @param cell UITableViewCell
  156. @param viewControllerType 页面类型
  157. */
  158. +(void)setTableViewCellConfig:(UMTableViewCellConfig)tableViewCellConfig;
  159. /**
  160. 设置分享完成时“发送完成”或者分享错误等提示
  161. @param isHidden 是否隐藏该提示
  162. @param toastPosition 提示的位置,可以设置成在屏幕上部、中间、下部
  163. */
  164. +(void)setFinishToastIsHidden:(BOOL)isHidden position:(UMSocialiToastPosition)toastPosition;
  165. /**
  166. 设置官方微博账号,设置之后可以在授权页面有关注微博的选项,默认勾选,授权之后用户即关注官方微博,仅支持腾讯微博
  167. @param weiboUids 腾讯微博的key是`UMShareToTenc`,值是官方微博的uid,例如`[UMSocialConfig setFollowWeiboUids:[NSDictionary dictionaryWithObjectsAndKeys:@"yourSinaUid",UMShareToTenc,nil]];`
  168. */
  169. + (void)setFollowWeiboUids:(NSDictionary *)weiboUids;
  170. /**
  171. 设置新增加`UMSocialSnsPlatform`对象
  172. @param snsPlatformArray `UMSocialSnsPlatform`组成的数组对象
  173. */
  174. + (void)addSocialSnsPlatform:(NSArray *)snsPlatformArray;
  175. /**
  176. 设置页面的背景颜色
  177. @param defaultColor 设置页面背景颜色
  178. */
  179. + (void)setDefaultColor:(UIColor *)defaultColor;
  180. /**
  181. 设置iPad页面的大小
  182. @param size 页面大小
  183. */
  184. + (void)setBoundsSizeForiPad:(CGSize)size;
  185. /**
  186. 设置分享编辑页面是否等待完成之后再关闭页面还是立即关闭,如果设置成YES,就是等待分享完成之后再关闭,否则立即关闭。
  187. 2.2版本前默认等待分享完成之后再关闭。
  188. 2.2版本之后默认设置成立即关闭页面
  189. @param shouldShareSynchronous 是否同步分享
  190. */
  191. + (void)setShouldShareSynchronous:(BOOL)shouldShareSynchronous;
  192. /**
  193. 设置评论页面是否出现分享按钮,默认出现
  194. */
  195. + (void)setShouldCommentWithShare:(BOOL)shouldCommentWithShare;
  196. /**
  197. 设置评论页面是否出现分享地理位置信息的按钮,默认出现
  198. */
  199. + (void)setShouldCommentWithLocation:(BOOL)shouldCommentWithLocation;
  200. /** Deprecated API, Use [UMSocialConfig showPlatformWhenNotInstall:nil];
  201. 显示所有平台,某些平台例如微信和QQ,需要安装客户端才能分享,若没有安装客户端情况下不显示这些平台
  202. */
  203. //+ (void)showAllPlatform:(BOOL)showAllPlatform;
  204. /** Deprecated API, Use [UMSocialConfig hiddenNotInstallPlatforms:nil];
  205. 指定显示没有安装客户端的平台,默认需要客户端的分享平台不显示。
  206. 传nil则显示所有平台。
  207. @param showPlatforms 指定要显示的平台
  208. */
  209. + (void)showNotInstallPlatforms:(NSArray *)showPlatforms;
  210. /**
  211. 隐藏指定没有安装客户端的平台。
  212. @param hiddenPlatforms 指定要隐藏的平台,传nil则隐藏所有没有安装客户端的平台
  213. */
  214. + (void)hiddenNotInstallPlatforms:(NSArray *)hiddenPlatforms;
  215. @property (nonatomic, assign) BOOL forCocos2dx;
  216. /** deprecated API, Use ''[UMSocialSinaHandler openSSOWithRedirectURL:@"http://sns.whalecloud.com/sina2/callback"];''
  217. 设置是否支持新浪微博SSO,默认不支持
  218. @param supportSinaSSO 设置是否支持新浪微博SSO
  219. @param appRedirectUrl 设置授权回调地址,此授权回调地址必须和你在新浪应用后台填写的回调地址一致,否则不能授权
  220. 如果在新浪微博后台绑定我们的回调地址“http://sns.whalecloud.com/sina2/callback”,这里可以传nil
  221. */
  222. //+ (void)setSupportSinaSSO:(BOOL)supportSinaSSO appRedirectUrl:(NSString *)appRedirectUrl;
  223. /** deprecated API, Use ''[UMSocialQQHandler shareToQQWithAppId:@"100424468" url:@"http://www.umeng.com/social"];''
  224. 设置手机QQ的app_Id和微信图文分享用到的url地址
  225. @param app_Id 手机QQ的AppId
  226. @param url 手机QQ图文分享web类型,用到的url地址,如果传nil,默认使用http://www.umeng.com/social
  227. @param classes 载入QQ互联 SDK,用到的两个类
  228. */
  229. //+ (void)setQQAppId:(NSString *)app_Id url:(NSString *)url importClasses:(NSArray *)classes;
  230. /**deprecated API, Use ''[UMSocialQQHandler setSupportQzoneSSO:YES];''
  231. 设置支持Qzone的SSO授权
  232. @param supportQzoneSSO Qzone支持SSO
  233. @param classes 载入QQ互联 SDK,用到的两个类
  234. */
  235. //+ (void)setSupportQzoneSSO:(BOOL)supportQzoneSSO importClasses:(NSArray *)classes;
  236. /**deprecated API
  237. 设置是否使用QQ互联的SDK来分享
  238. @param useQQSDK 是否使用QQ互联的SDK来分享
  239. @param classes 载入QQ互联 SDK,用到的两个类
  240. */
  241. //+ (void)setShareQzoneWithQQSDK:(BOOL)useQQSDK url:(NSString *)urlString importClasses:(NSArray *)classes;
  242. /**
  243. *隐藏loading状态框
  244. */
  245. + (void)hiddenLoadingHUD:(BOOL)isHiden;
  246. /**
  247. *隐藏状态提示框
  248. */
  249. + (void)hiddenStatusTip:(BOOL)isHiden;;
  250. /**
  251. * 设置分享web url是否转换成回流的url, 默认为NO
  252. */
  253. + (void)webUrlShareGetInverseFlowUrl:(BOOL)isGetInverseFlowUrl;
  254. @end