UMSocialPlatformConfig.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. * 授权,分享,UserProfile等操作的回调
  152. *
  153. * @param result 表示回调的结果
  154. * @param error 表示回调的错误码
  155. */
  156. typedef void (^UMSocialRequestCompletionHandler)(id result,NSError *error);
  157. /**
  158. * 授权,分享,UserProfile等操作的回调
  159. *
  160. * @param shareResponse 表示回调的结果
  161. * @param error 表示回调的错误码
  162. */
  163. typedef void (^UMSocialShareCompletionHandler)(id shareResponse,NSError *error);
  164. /**
  165. * 授权,分享,UserProfile等操作的回调
  166. *
  167. * @param authResponse 表示回调的结果
  168. * @param error 表示回调的错误码
  169. */
  170. typedef void (^UMSocialAuthCompletionHandler)(id authResponse,NSError *error);
  171. /**
  172. * 授权,分享,UserProfile等操作的回调
  173. *
  174. * @param userInfoResponse 表示回调的结果
  175. * @param error 表示回调的错误码
  176. */
  177. typedef void (^UMSocialGetUserInfoCompletionHandler)(id userInfoResponse,NSError *error);
  178. /**
  179. * 三方平台主动拉起app的回调
  180. *
  181. * @param userInfoResponse 表示回调的结果
  182. * @param error 表示回调的错误码
  183. */
  184. typedef void (^UMSocialLaunchFromPlatformCompletionHandler)(id userInfoResponse,NSError *error);
  185. /////////////////////////////////////////////////////////////////////////////
  186. //平台的失败错误码--start
  187. /////////////////////////////////////////////////////////////////////////////
  188. /**
  189. * U-Share返回错误类型
  190. */
  191. typedef NS_ENUM(NSInteger, UMSocialPlatformErrorType) {
  192. UMSocialPlatformErrorType_Unknow = 2000, // 未知错误
  193. UMSocialPlatformErrorType_NotSupport = 2001, // 没有配置-ObjC, 或则SDK版本不支持或则客户端版本不支持
  194. UMSocialPlatformErrorType_AuthorizeFailed = 2002, // 授权失败
  195. UMSocialPlatformErrorType_ShareFailed = 2003, // 分享失败
  196. UMSocialPlatformErrorType_RequestForUserProfileFailed = 2004, // 请求用户信息失败
  197. UMSocialPlatformErrorType_ShareDataNil = 2005, // 分享内容为空
  198. UMSocialPlatformErrorType_ShareDataTypeIllegal = 2006, // 分享内容不支持
  199. UMSocialPlatformErrorType_CheckUrlSchemaFail = 2007, // schemaurl fail
  200. UMSocialPlatformErrorType_NotInstall = 2008, // 应用未安装
  201. UMSocialPlatformErrorType_Cancel = 2009, // 取消操作
  202. UMSocialPlatformErrorType_NotNetWork = 2010, // 网络异常
  203. UMSocialPlatformErrorType_SourceError = 2011, // 第三方错误
  204. UMSocialPlatformErrorType_ProtocolNotOverride = 2013, // 对应的 UMSocialPlatformProvider的方法没有实现
  205. UMSocialPlatformErrorType_NotUsingHttps = 2014, // 没有用https的请求,@see UMSocialGlobal isUsingHttpsWhenShareContent
  206. };
  207. /** The domain name used for the UMSocialPlatformErrorType */
  208. extern NSString* const UMSocialPlatformErrorDomain;
  209. /////////////////////////////////////////////////////////////////////////////
  210. //平台的失败错误码--end
  211. /////////////////////////////////////////////////////////////////////////////
  212. /////////////////////////////////////////////////////////////////////////////
  213. //平台的特性--begin
  214. /////////////////////////////////////////////////////////////////////////////
  215. /**
  216. * 平台的特性枚举变量
  217. */
  218. typedef NS_OPTIONS(NSUInteger, UMSocialPlatformFeature)
  219. {
  220. UMSocialPlatformFeature_None = 0,
  221. //App
  222. UMSocialPlatformFeature_IsAppInstalled = 1 << 0,
  223. UMSocialPlatformFeature_IsCanOpenApp = 1 << 1,
  224. UMSocialPlatformFeature_IsAppApiSupport = 1 << 2,
  225. //Authorize
  226. UMSocialPlatformFeature_IsCanAuthorize = 1 << 10,
  227. UMSocialPlatformFeature_IsCanWebViewAuthorize = 1 << 11,
  228. //SSOShare
  229. UMSocialPlatformFeature_IsCanShare_Text = 1 << 22,
  230. UMSocialPlatformFeature_IsCanShare_Image = 1 << 23,
  231. UMSocialPlatformFeature_IsCanShare_Media = 1 << 24,
  232. UMSocialPlatformFeature_IsCanShare_TextAndImage = 1 << 25,
  233. UMSocialPlatformFeature_IsCanShare_TextAndMedia = 1 << 26,
  234. //mask
  235. UMSocialPlatformFeature_Mask = 0xFFFFFFFF,
  236. };
  237. /////////////////////////////////////////////////////////////////////////////
  238. //平台的特性--end
  239. /////////////////////////////////////////////////////////////////////////////
  240. /////////////////////////////////////////////////////////////////////////////
  241. //平台的类型--start
  242. /////////////////////////////////////////////////////////////////////////////
  243. typedef NS_ENUM(NSInteger,UMSocialPlatformType)
  244. {
  245. UMSocialPlatformType_UnKnown = -2,
  246. //预定义的平台
  247. UMSocialPlatformType_Predefine_Begin = -1,
  248. UMSocialPlatformType_Sina = 0, //新浪
  249. UMSocialPlatformType_WechatSession = 1, //微信聊天
  250. UMSocialPlatformType_WechatTimeLine = 2,//微信朋友圈
  251. UMSocialPlatformType_WechatFavorite = 3,//微信收藏
  252. UMSocialPlatformType_QQ = 4,//QQ聊天页面
  253. UMSocialPlatformType_Qzone = 5,//qq空间
  254. UMSocialPlatformType_TencentWb = 6,//腾讯微博
  255. UMSocialPlatformType_APSession = 7,//支付宝聊天页面
  256. UMSocialPlatformType_YixinSession = 8,//易信聊天页面
  257. UMSocialPlatformType_YixinTimeLine = 9,//易信朋友圈
  258. UMSocialPlatformType_YixinFavorite = 10,//易信收藏
  259. UMSocialPlatformType_LaiWangSession = 11,//点点虫(原来往)聊天页面
  260. UMSocialPlatformType_LaiWangTimeLine = 12,//点点虫动态
  261. UMSocialPlatformType_Sms = 13,//短信
  262. UMSocialPlatformType_Email = 14,//邮件
  263. UMSocialPlatformType_Renren = 15,//人人
  264. UMSocialPlatformType_Facebook = 16,//Facebook
  265. UMSocialPlatformType_Twitter = 17,//Twitter
  266. UMSocialPlatformType_Douban = 18,//豆瓣
  267. UMSocialPlatformType_KakaoTalk = 19,//KakaoTalk
  268. UMSocialPlatformType_Pinterest = 20,//Pinteres
  269. UMSocialPlatformType_Line = 21,//Line
  270. UMSocialPlatformType_Linkedin = 22,//领英
  271. UMSocialPlatformType_Flickr = 23,//Flickr
  272. UMSocialPlatformType_Tumblr = 24,//Tumblr
  273. UMSocialPlatformType_Instagram = 25,//Instagram
  274. UMSocialPlatformType_Whatsapp = 26,//Whatsapp
  275. UMSocialPlatformType_DingDing = 27,//钉钉
  276. UMSocialPlatformType_YouDaoNote = 28,//有道云笔记
  277. UMSocialPlatformType_EverNote = 29,//印象笔记
  278. UMSocialPlatformType_GooglePlus = 30,//Google+
  279. UMSocialPlatformType_Pocket = 31,//Pocket
  280. UMSocialPlatformType_DropBox = 32,//dropbox
  281. UMSocialPlatformType_VKontakte = 33,//vkontakte
  282. UMSocialPlatformType_FaceBookMessenger = 34,//FaceBookMessenger
  283. UMSocialPlatformType_Tim = 35,// Tencent TIM
  284. UMSocialPlatformType_Predefine_end = 999,
  285. //用户自定义的平台
  286. UMSocialPlatformType_UserDefine_Begin = 1000,
  287. UMSocialPlatformType_UserDefine_End = 2000,
  288. };
  289. /////////////////////////////////////////////////////////////////////////////
  290. //平台的类型--end
  291. /////////////////////////////////////////////////////////////////////////////
  292. //通过图片名称读取UMSocialSDKResources.bundle里的平台icon
  293. #define UMSocialPlatformIconWithName(name) [NSString stringWithFormat:@"UMSocialSDKResources.bundle/SnsPlatform/%@",name]
  294. ////通过图片名称读取UMSocialSDKResources.bundle/Buttons/中的图片
  295. #define UMSocialButtonImageWithName(name) [NSString stringWithFormat:@"UMSocialSDKResources.bundle/Buttons/%@",name]
  296. //
  297. /** 本地化 */
  298. #define UMLocalizedString(key,defaultValue) NSLocalizedStringWithDefaultValue(key,@"UMSocialLocalizable", [NSBundle mainBundle], defaultValue, nil)
  299. /**
  300. * 平台配置类
  301. */
  302. @interface UMSocialPlatformConfig : NSObject
  303. @property(nonatomic,strong)NSString* appKey;
  304. @property(nonatomic,strong)NSString* appSecret;
  305. @property(nonatomic,strong)NSString* redirectURL;
  306. /**
  307. * 根据平台类型获得平台名称
  308. *
  309. * @param platformType 平台类型
  310. * @see UMSocialPlatformType
  311. *
  312. * @return 返回对应的平台名称
  313. */
  314. + (NSString *)platformNameWithPlatformType:(UMSocialPlatformType)platformType;
  315. /**
  316. * 根据平台的类型返回对应平台的对象
  317. *
  318. * @param platformType 平台类型
  319. *
  320. * @return 返回对应的平台对象
  321. */
  322. + (id)platformHandlerWithPlatformType:(UMSocialPlatformType)platformType;
  323. /**
  324. * 创建错误类型
  325. *
  326. * @param errorType 平台类型
  327. * @param userInfo 用户的自定义信息userInfo
  328. *
  329. * @return 返回错误对象
  330. */
  331. + (NSError *)errorWithSocialErrorType:(UMSocialPlatformErrorType)errorType userInfo:(id)userInfo;
  332. @end
  333. /**
  334. * 云端授权/分享编辑页面配置类
  335. * 云端授权/分享页面目前适用于腾讯微博、豆瓣、人人的授权和分享编辑页面的自定义配置
  336. */
  337. @interface UMSocialCloudViewConfig : NSObject
  338. /**
  339. 授权页面
  340. */
  341. @property (nonatomic, strong) NSString *authViewTitle;
  342. @property (nonatomic, strong) UIColor *authViewTitleColor;
  343. @property( nonatomic, strong) UIColor *authViewNavBarColor;
  344. // button仅需改动title或image即可,touch事件内部触发
  345. @property (nonatomic, strong) UIButton *authViewCloseButton;
  346. @property (nonatomic, strong) NSString *editViewTitle;
  347. @property (nonatomic, strong) UIColor *editViewTitleColor;
  348. @property( nonatomic, strong) UIColor *editViewNavBarColor;
  349. // button仅需改动title或image即可,touch事件内部触发
  350. @property (nonatomic, strong) UIButton *editViewCloseButton;
  351. @property (nonatomic, strong) UIButton *editViewShareButton;
  352. + (instancetype)sharedInstance;
  353. @end