UMSocialPlatformConfig.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. //
  2. // UMSocialPlatformConfig.h
  3. // UMSocialSDK
  4. //
  5. // Created by 张军华 on 16/8/5.
  6. // Copyright © 2016年 dongjianxiong. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. /**
  11. 新浪微博
  12. */
  13. extern NSString *const UMSPlatformNameSina;
  14. /**
  15. 腾讯微博
  16. */
  17. extern NSString *const UMSPlatformNameTencentWb;
  18. /**
  19. 钉钉
  20. */
  21. extern NSString *const UMSPlatformNameDingDing;
  22. /**
  23. 人人网
  24. */
  25. extern NSString *const UMSPlatformNameRenren;
  26. /**
  27. 豆瓣
  28. */
  29. extern NSString *const UMSPlatformNameDouban;
  30. /**
  31. QQ空间
  32. */
  33. extern NSString *const UMSPlatformNameQzone;
  34. /**
  35. 邮箱
  36. */
  37. extern NSString *const UMSPlatformNameEmail;
  38. /**
  39. 短信
  40. */
  41. extern NSString *const UMSPlatformNameSms;
  42. /**
  43. 微信好友
  44. */
  45. extern NSString *const UMSPlatformNameWechatSession;
  46. /**
  47. 微信朋友圈
  48. */
  49. extern NSString *const UMSPlatformNameWechatTimeline;
  50. /**
  51. 微信收藏
  52. */
  53. extern NSString *const UMSPlatformNameWechatFavorite;
  54. /**
  55. 支付宝好友
  56. */
  57. extern NSString *const UMSPlatformNameAPSession;
  58. /**
  59. 手机QQ
  60. */
  61. extern NSString *const UMSPlatformNameQQ;
  62. /**
  63. Tencent Tim
  64. */
  65. extern NSString *const UMSPlatformNameTim;
  66. /**
  67. Facebook
  68. */
  69. extern NSString *const UMSPlatformNameFacebook;
  70. /**
  71. Twitter
  72. */
  73. extern NSString *const UMSPlatformNameTwitter;
  74. /**
  75. 易信好友
  76. */
  77. extern NSString *const UMSPlatformNameYXSession;
  78. /**
  79. 易信朋友圈
  80. */
  81. extern NSString *const UMSPlatformNameYXTimeline;
  82. /**
  83. 来往好友
  84. */
  85. extern NSString *const UMSPlatformNameLWSession;
  86. /**
  87. 来往朋友圈
  88. */
  89. extern NSString *const UMSPlatformNameLWTimeline;
  90. /**
  91. 分享到Instragram
  92. */
  93. extern NSString *const UMSPlatformNameInstagram;
  94. /**
  95. 分享到Whatsapp
  96. */
  97. extern NSString *const UMSPlatformNameWhatsapp;
  98. /**
  99. 分享到Line
  100. */
  101. extern NSString *const UMSPlatformNameLine;
  102. /**
  103. 分享到Tumblr
  104. */
  105. extern NSString *const UMSPlatformNameTumblr;
  106. /**
  107. 领英
  108. */
  109. extern NSString *const UMSPlatformNameLinkedin;
  110. /**
  111. 分享到Pinterest
  112. */
  113. extern NSString *const UMSPlatformNamePinterest;
  114. /**
  115. 分享到KakaoTalk
  116. */
  117. extern NSString *const UMSPlatformNameKakaoTalk;
  118. /**
  119. 分享到Flickr
  120. */
  121. extern NSString *const UMSPlatformNameFlickr;
  122. /**
  123. * 有道云笔记
  124. */
  125. extern NSString *const UMSPlatformNameYouDaoNote;
  126. /**
  127. * 印象笔记
  128. */
  129. extern NSString *const UMSPlatformNameEverNote;
  130. /**
  131. * google+
  132. */
  133. extern NSString *const UMSPlatformNameGooglePlus;
  134. /**
  135. * Pocket
  136. */
  137. extern NSString *const UMSPlatformNamePocket;
  138. /**
  139. * dropbox
  140. */
  141. extern NSString *const UMSPlatformNameDropBox;
  142. /**
  143. * vkontakte
  144. */
  145. extern NSString *const UMSPlatformNameVKontakte;
  146. /**
  147. * FaceBookMessenger
  148. */
  149. extern NSString *const UMSPlatformNameFaceBookMessenger;
  150. /**
  151. * WechatWork
  152. */
  153. extern NSString *const UMSPlatformNameWechatWork;
  154. /**
  155. * DouYin
  156. */
  157. extern NSString *const UMSPlatformNameDouYin;
  158. /**
  159. * 授权,分享,UserProfile等操作的回调
  160. *
  161. * @param result 表示回调的结果
  162. * @param error 表示回调的错误码
  163. */
  164. typedef void (^UMSocialRequestCompletionHandler)(id result,NSError *error);
  165. /**
  166. * 授权,分享,UserProfile等操作的回调
  167. *
  168. * @param shareResponse 表示回调的结果
  169. * @param error 表示回调的错误码
  170. */
  171. typedef void (^UMSocialShareCompletionHandler)(id shareResponse,NSError *error);
  172. /**
  173. * 授权,分享,UserProfile等操作的回调
  174. *
  175. * @param authResponse 表示回调的结果
  176. * @param error 表示回调的错误码
  177. */
  178. typedef void (^UMSocialAuthCompletionHandler)(id authResponse,NSError *error);
  179. /**
  180. * 授权,分享,UserProfile等操作的回调
  181. *
  182. * @param userInfoResponse 表示回调的结果
  183. * @param error 表示回调的错误码
  184. */
  185. typedef void (^UMSocialGetUserInfoCompletionHandler)(id userInfoResponse,NSError *error);
  186. /**
  187. * 三方平台主动拉起app的回调
  188. *
  189. * @param userInfoResponse 表示回调的结果
  190. * @param error 表示回调的错误码
  191. */
  192. typedef void (^UMSocialLaunchFromPlatformCompletionHandler)(id userInfoResponse,NSError *error);
  193. /////////////////////////////////////////////////////////////////////////////
  194. //平台的失败错误码--start
  195. /////////////////////////////////////////////////////////////////////////////
  196. /**
  197. * U-Share返回错误类型
  198. */
  199. typedef NS_ENUM(NSInteger, UMSocialPlatformErrorType) {
  200. UMSocialPlatformErrorType_Unknow = 2000, // 未知错误
  201. UMSocialPlatformErrorType_NotSupport = 2001, // 没有配置-ObjC, 或则SDK版本不支持或则客户端版本不支持
  202. UMSocialPlatformErrorType_AuthorizeFailed = 2002, // 授权失败
  203. UMSocialPlatformErrorType_ShareFailed = 2003, // 分享失败
  204. UMSocialPlatformErrorType_RequestForUserProfileFailed = 2004, // 请求用户信息失败
  205. UMSocialPlatformErrorType_ShareDataNil = 2005, // 分享内容为空
  206. UMSocialPlatformErrorType_ShareDataTypeIllegal = 2006, // 分享内容不支持
  207. UMSocialPlatformErrorType_CheckUrlSchemaFail = 2007, // schemaurl fail
  208. UMSocialPlatformErrorType_NotInstall = 2008, // 应用未安装
  209. UMSocialPlatformErrorType_Cancel = 2009, // 取消操作
  210. UMSocialPlatformErrorType_NotNetWork = 2010, // 网络异常
  211. UMSocialPlatformErrorType_SourceError = 2011, // 第三方错误
  212. UMSocialPlatformErrorType_ProtocolNotOverride = 2013, // 对应的 UMSocialPlatformProvider的方法没有实现
  213. UMSocialPlatformErrorType_NotUsingHttps = 2014, // 没有用https的请求,@see UMSocialGlobal isUsingHttpsWhenShareContent
  214. };
  215. /** The domain name used for the UMSocialPlatformErrorType */
  216. extern NSString* const UMSocialPlatformErrorDomain;
  217. /////////////////////////////////////////////////////////////////////////////
  218. //平台的失败错误码--end
  219. /////////////////////////////////////////////////////////////////////////////
  220. /////////////////////////////////////////////////////////////////////////////
  221. //平台的特性--begin
  222. /////////////////////////////////////////////////////////////////////////////
  223. /**
  224. * 平台的特性枚举变量
  225. */
  226. typedef NS_OPTIONS(NSUInteger, UMSocialPlatformFeature)
  227. {
  228. UMSocialPlatformFeature_None = 0,
  229. //App
  230. UMSocialPlatformFeature_IsAppInstalled = 1 << 0,
  231. UMSocialPlatformFeature_IsCanOpenApp = 1 << 1,
  232. UMSocialPlatformFeature_IsAppApiSupport = 1 << 2,
  233. //Authorize
  234. UMSocialPlatformFeature_IsCanAuthorize = 1 << 10,
  235. UMSocialPlatformFeature_IsCanWebViewAuthorize = 1 << 11,
  236. //SSOShare
  237. UMSocialPlatformFeature_IsCanShare_Text = 1 << 22,
  238. UMSocialPlatformFeature_IsCanShare_Image = 1 << 23,
  239. UMSocialPlatformFeature_IsCanShare_Media = 1 << 24,
  240. UMSocialPlatformFeature_IsCanShare_TextAndImage = 1 << 25,
  241. UMSocialPlatformFeature_IsCanShare_TextAndMedia = 1 << 26,
  242. //mask
  243. UMSocialPlatformFeature_Mask = 0xFFFFFFFF,
  244. };
  245. /////////////////////////////////////////////////////////////////////////////
  246. //平台的特性--end
  247. /////////////////////////////////////////////////////////////////////////////
  248. /////////////////////////////////////////////////////////////////////////////
  249. //平台的类型--start
  250. /////////////////////////////////////////////////////////////////////////////
  251. typedef NS_ENUM(NSInteger,UMSocialPlatformType)
  252. {
  253. UMSocialPlatformType_UnKnown = -2,
  254. //预定义的平台
  255. UMSocialPlatformType_Predefine_Begin = -1,
  256. UMSocialPlatformType_Sina = 0, //新浪
  257. UMSocialPlatformType_WechatSession = 1, //微信聊天
  258. UMSocialPlatformType_WechatTimeLine = 2,//微信朋友圈
  259. UMSocialPlatformType_WechatFavorite = 3,//微信收藏
  260. UMSocialPlatformType_QQ = 4,//QQ聊天页面
  261. UMSocialPlatformType_Qzone = 5,//qq空间
  262. UMSocialPlatformType_TencentWb = 6,//腾讯微博
  263. UMSocialPlatformType_APSession = 7,//支付宝聊天页面
  264. UMSocialPlatformType_YixinSession = 8,//易信聊天页面
  265. UMSocialPlatformType_YixinTimeLine = 9,//易信朋友圈
  266. UMSocialPlatformType_YixinFavorite = 10,//易信收藏
  267. UMSocialPlatformType_LaiWangSession = 11,//点点虫(原来往)聊天页面
  268. UMSocialPlatformType_LaiWangTimeLine = 12,//点点虫动态
  269. UMSocialPlatformType_Sms = 13,//短信
  270. UMSocialPlatformType_Email = 14,//邮件
  271. UMSocialPlatformType_Renren = 15,//人人
  272. UMSocialPlatformType_Facebook = 16,//Facebook
  273. UMSocialPlatformType_Twitter = 17,//Twitter
  274. UMSocialPlatformType_Douban = 18,//豆瓣
  275. UMSocialPlatformType_KakaoTalk = 19,//KakaoTalk
  276. UMSocialPlatformType_Pinterest = 20,//Pinteres
  277. UMSocialPlatformType_Line = 21,//Line
  278. UMSocialPlatformType_Linkedin = 22,//领英
  279. UMSocialPlatformType_Flickr = 23,//Flickr
  280. UMSocialPlatformType_Tumblr = 24,//Tumblr
  281. UMSocialPlatformType_Instagram = 25,//Instagram
  282. UMSocialPlatformType_Whatsapp = 26,//Whatsapp
  283. UMSocialPlatformType_DingDing = 27,//钉钉
  284. UMSocialPlatformType_YouDaoNote = 28,//有道云笔记
  285. UMSocialPlatformType_EverNote = 29,//印象笔记
  286. UMSocialPlatformType_GooglePlus = 30,//Google+
  287. UMSocialPlatformType_Pocket = 31,//Pocket
  288. UMSocialPlatformType_DropBox = 32,//dropbox
  289. UMSocialPlatformType_VKontakte = 33,//vkontakte
  290. UMSocialPlatformType_FaceBookMessenger = 34,//FaceBookMessenger
  291. UMSocialPlatformType_Tim = 35,// Tencent TIM
  292. UMSocialPlatformType_WechatWork = 36,//企业微信
  293. UMSocialPlatformType_DouYin = 37,//抖音
  294. UMSocialPlatformType_Predefine_end = 999,
  295. //用户自定义的平台
  296. UMSocialPlatformType_UserDefine_Begin = 1000,
  297. UMSocialPlatformType_UserDefine_End = 2000,
  298. };
  299. /////////////////////////////////////////////////////////////////////////////
  300. //平台的类型--end
  301. /////////////////////////////////////////////////////////////////////////////
  302. //通过图片名称读取UMSocialSDKResources.bundle里的平台icon
  303. #define UMSocialPlatformIconWithName(name) [NSString stringWithFormat:@"UMSocialSDKResources.bundle/SnsPlatform/%@",name]
  304. ////通过图片名称读取UMSocialSDKResources.bundle/Buttons/中的图片
  305. #define UMSocialButtonImageWithName(name) [NSString stringWithFormat:@"UMSocialSDKResources.bundle/Buttons/%@",name]
  306. //
  307. /** 本地化 */
  308. #define UMLocalizedString(key,defaultValue) NSLocalizedStringWithDefaultValue(key,@"UMSocialLocalizable", [NSBundle mainBundle], defaultValue, nil)
  309. /**
  310. * 平台配置类
  311. */
  312. @interface UMSocialPlatformConfig : NSObject
  313. @property(nonatomic,strong)NSString* appKey;
  314. @property(nonatomic,strong)NSString* appSecret;
  315. @property(nonatomic,strong)NSString* redirectURL;
  316. /**
  317. * 根据平台类型获得平台名称
  318. *
  319. * @param platformType 平台类型
  320. * @see UMSocialPlatformType
  321. *
  322. * @return 返回对应的平台名称
  323. */
  324. + (NSString *)platformNameWithPlatformType:(UMSocialPlatformType)platformType;
  325. /**
  326. * 根据平台的类型返回对应平台的对象
  327. *
  328. * @param platformType 平台类型
  329. *
  330. * @return 返回对应的平台对象
  331. */
  332. + (id)platformHandlerWithPlatformType:(UMSocialPlatformType)platformType;
  333. /**
  334. * 创建错误类型
  335. *
  336. * @param errorType 平台类型
  337. * @param userInfo 用户的自定义信息userInfo
  338. *
  339. * @return 返回错误对象
  340. */
  341. + (NSError *)errorWithSocialErrorType:(UMSocialPlatformErrorType)errorType userInfo:(id)userInfo;
  342. @end
  343. /**
  344. * 云端授权/分享编辑页面配置类
  345. * 云端授权/分享页面目前适用于腾讯微博、豆瓣、人人的授权和分享编辑页面的自定义配置
  346. */
  347. @interface UMSocialCloudViewConfig : NSObject
  348. /**
  349. 授权页面
  350. */
  351. @property (nonatomic, strong) NSString *authViewTitle;
  352. @property (nonatomic, strong) UIColor *authViewTitleColor;
  353. @property( nonatomic, strong) UIColor *authViewNavBarColor;
  354. // button仅需改动title或image即可,touch事件内部触发
  355. @property (nonatomic, strong) UIButton *authViewCloseButton;
  356. @property (nonatomic, strong) NSString *editViewTitle;
  357. @property (nonatomic, strong) UIColor *editViewTitleColor;
  358. @property( nonatomic, strong) UIColor *editViewNavBarColor;
  359. // button仅需改动title或image即可,touch事件内部触发
  360. @property (nonatomic, strong) UIButton *editViewCloseButton;
  361. @property (nonatomic, strong) UIButton *editViewShareButton;
  362. + (instancetype)sharedInstance;
  363. @end