UMSocialMessageObject.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. //
  2. // UMSocialMessageObject.h
  3. // SocialSDK
  4. //
  5. // Created by umeng on 16/4/22.
  6. // Copyright © 2016年 dongjianxiong. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. @interface UMSocialMessageObject : NSObject
  11. /**
  12. * 文本标题
  13. * @disucss v6.0.3版本后增加的一个字段,
  14. * @disucss 该字段目前只有Tumblr平台会使用到。
  15. * @discuss 该字段以后会在需要文本title字段中扩展,具体请参看官方文档。
  16. */
  17. @property (nonatomic,copy)NSString* title;
  18. /**
  19. * text 文本内容
  20. * @note 非纯文本分享文本
  21. */
  22. @property (nonatomic, copy) NSString *text;
  23. /**
  24. * 分享的所媒体内容对象
  25. */
  26. @property (nonatomic, strong) id shareObject;
  27. /**
  28. * 其他相关参数,见相应平台说明
  29. */
  30. @property (nonatomic, strong) NSDictionary *moreInfo;
  31. + (UMSocialMessageObject *)messageObject;
  32. + (UMSocialMessageObject *)messageObjectWithMediaObject:(id)mediaObject;
  33. @end
  34. @interface UMShareObject : NSObject
  35. /**
  36. * 标题
  37. * @note 标题的长度依各个平台的要求而定
  38. */
  39. @property (nonatomic, copy) NSString *title;
  40. /**
  41. * 描述
  42. * @note 描述内容的长度依各个平台的要求而定
  43. */
  44. @property (nonatomic, copy) NSString *descr;
  45. /**
  46. * 缩略图 UIImage或者NSData类型或者NSString类型(图片url)
  47. */
  48. @property (nonatomic, strong) id thumbImage;
  49. /**
  50. * @param title 标题
  51. * @param descr 描述
  52. * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
  53. *
  54. */
  55. + (id)shareObjectWithTitle:(NSString *)title
  56. descr:(NSString *)descr
  57. thumImage:(id)thumImage;
  58. + (void)um_imageDataWithImage:(id)image completion:(void (^)(NSData *image))completion;
  59. #pragma mark - 6.0.3新版本的函数
  60. + (void)um_imageDataWithImage:(id)image withCompletion:(void (^)(NSData *imageData,NSError* error))completion;
  61. @end
  62. @interface UMShareImageObject : UMShareObject
  63. /** 分享单个图片(支持UIImage,NSdata以及图片链接Url NSString类对象集合)
  64. * @note 图片大小根据各个平台限制而定
  65. */
  66. @property (nonatomic, retain) id shareImage;
  67. /** 分享图片数组,支持 UIImage、NSData 类型
  68. * @note 仅支持分享到:
  69. * 微博平台,最多可分享9张图片
  70. * QZone平台,最多可分享20张图片
  71. */
  72. @property (nonatomic, copy) NSArray *shareImageArray;
  73. /**
  74. * 用户可以传入包含PHAsset的array
  75. * @note 目前仅支持抖音(抖音现在强制用photos里面的localIdentifier来做分享)
  76. * @note 增加抖音平台6.9.9(不含6.9.9)以上版本新增字段
  77. */
  78. @property (nonatomic, copy) NSArray *shareAssetsArray;
  79. /**
  80. * @param title 标题
  81. * @param descr 描述
  82. * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
  83. *
  84. */
  85. + (UMShareImageObject *)shareObjectWithTitle:(NSString *)title
  86. descr:(NSString *)descr
  87. thumImage:(id)thumImage;
  88. @end
  89. @interface UMShareMusicObject : UMShareObject
  90. /** 音乐网页的url地址
  91. * @note 长度不能超过10K
  92. */
  93. @property (nonatomic, retain) NSString *musicUrl;
  94. /** 音乐lowband网页的url地址
  95. * @note 长度不能超过10K
  96. */
  97. @property (nonatomic, retain) NSString *musicLowBandUrl;
  98. /** 音乐数据url地址
  99. * @note 长度不能超过10K
  100. */
  101. @property (nonatomic, retain) NSString *musicDataUrl;
  102. /**音乐lowband数据url地址
  103. * @note 长度不能超过10K
  104. */
  105. @property (nonatomic, retain) NSString *musicLowBandDataUrl;
  106. /**
  107. * @param title 标题
  108. * @param descr 描述
  109. * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
  110. *
  111. */
  112. + (UMShareMusicObject *)shareObjectWithTitle:(NSString *)title
  113. descr:(NSString *)descr
  114. thumImage:(id)thumImage;
  115. @end
  116. @interface UMShareVideoObject : UMShareObject
  117. /**
  118. 视频网页的url
  119. @warning 不能为空且长度不能超过255
  120. */
  121. @property (nonatomic, strong) NSString *videoUrl;
  122. /**
  123. 视频lowband网页的url
  124. @warning 长度不能超过255
  125. */
  126. @property (nonatomic, strong) NSString *videoLowBandUrl;
  127. /**
  128. 视频数据流url
  129. @warning 长度不能超过255
  130. */
  131. @property (nonatomic, strong) NSString *videoStreamUrl;
  132. /**
  133. 视频lowband数据流url
  134. @warning 长度不能超过255
  135. */
  136. @property (nonatomic, strong) NSString *videoLowBandStreamUrl;
  137. /**
  138. 视频数据
  139. @note 企业微信使用
  140. @note 6.9.9(不含6.9.9)抖音使用
  141. */
  142. @property (nonatomic, strong) NSData *videoData;
  143. @property (nonatomic, strong) NSString *videoName;
  144. /**
  145. * 用户可以传入包含从Photo里面获取的PHAsset的array
  146. * @note 目前仅支持抖音(抖音现在强制用photos里面的localIdentifier来做分享)
  147. * @note 增加抖音平台6.9.9(不含6.9.9)以上版本新增字段
  148. */
  149. @property (nonatomic, copy) NSArray *shareAssetsArray;
  150. /**
  151. * @param title 标题
  152. * @param descr 描述
  153. * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
  154. *
  155. */
  156. + (UMShareVideoObject *)shareObjectWithTitle:(NSString *)title
  157. descr:(NSString *)descr
  158. thumImage:(id)thumImage;
  159. @end
  160. @interface UMShareWebpageObject : UMShareObject
  161. /** 网页的url地址
  162. * @note 不能为空且长度不能超过10K
  163. */
  164. @property (nonatomic, retain) NSString *webpageUrl;
  165. /**
  166. * @param title 标题
  167. * @param descr 描述
  168. * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
  169. *
  170. */
  171. + (UMShareWebpageObject *)shareObjectWithTitle:(NSString *)title
  172. descr:(NSString *)descr
  173. thumImage:(id)thumImage;
  174. @end
  175. /*! @brief 分享消息中的邮件分享对象
  176. *
  177. * @see UMSocialMessageObject
  178. */
  179. @interface UMShareEmailObject : UMShareObject
  180. /**
  181. * 主题
  182. */
  183. @property (nonatomic, strong) NSString *subject;
  184. /**
  185. * 接收人
  186. */
  187. @property (nonatomic, strong) NSArray *toRecipients;
  188. /**
  189. * 抄送人
  190. */
  191. @property (nonatomic, strong) NSArray *ccRecipients;
  192. /**
  193. * 密送人
  194. */
  195. @property (nonatomic, strong) NSArray *bccRecipients;
  196. /**
  197. * 文本内容
  198. */
  199. @property (nonatomic, copy) NSString *emailContent;
  200. /**
  201. * 图片,最好是本地图片(UIImage,或者NSdata)
  202. */
  203. @property (nonatomic, strong) id emailImage;
  204. /**
  205. * 发送图片的类型 @see MIME
  206. * 默认 "image/ *"
  207. */
  208. @property (nonatomic, copy) NSString* emailImageType;
  209. /**
  210. * 发送图片的名字
  211. * 默认 "um_share_image.png"
  212. */
  213. @property (nonatomic, copy) NSString* emailImageName;
  214. /**
  215. * 文件(NSData)
  216. */
  217. @property (nonatomic, strong) NSData *emailSendData;
  218. /**
  219. * 文件格式
  220. * @see MIME
  221. * 默认 "text/ *"
  222. */
  223. @property (nonatomic, copy) NSString *fileType;
  224. /**
  225. * 文件名,(例如图片 imageName.png, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题)
  226. * 默认 "um_share_file.txt"
  227. */
  228. @property (nonatomic, copy) NSString *fileName;
  229. @end
  230. /*! @brief 分享消息中的短信分享对象
  231. *
  232. * @see UMSocialMessageObject
  233. * @discuss UMShareSmsObject只能发送的附件是图片!!!!
  234. * 如果发送其他的文件的话,虽然能在短信界面显示发送的文件,但是会发送不成功
  235. */
  236. @interface UMShareSmsObject : UMShareObject
  237. /**
  238. * 接收人
  239. */
  240. @property (nonatomic, strong) NSArray *recipients;
  241. /**
  242. * 主题
  243. */
  244. @property (nonatomic, strong) NSString *subject;
  245. /**
  246. * 文本内容
  247. */
  248. @property (nonatomic, copy) NSString *smsContent;
  249. /**
  250. * 图片
  251. */
  252. @property (nonatomic, strong) id smsImage;//UIImage对象必填
  253. @property (nonatomic, copy) NSString *imageType;//图片格式必填,必须指定数据格式,如png图片格式应传入@"png"
  254. @property (nonatomic, copy) NSString *imageName;//图片 例如 imageName.png, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题)
  255. #pragma mark - 以下字段为非图片的属性
  256. /**
  257. * 文件数据(NSData)
  258. * 必填
  259. */
  260. @property (nonatomic, strong) NSData *smsSendData;
  261. /**
  262. * 文件格式
  263. * 必填,必须指定数据格式,如png图片格式应传入@"txt"
  264. */
  265. @property (nonatomic, copy) NSString *fileType;
  266. /**
  267. * 文件名,(例如图片 fileName.txt, 文件名后要跟文件后缀名,否则没法识别,导致类似图片不显示的问题)
  268. */
  269. @property (nonatomic, copy) NSString *fileName;
  270. /**
  271. * 文件地址url(http:// or file:// ...../fileName.txt)
  272. */
  273. @property (nonatomic, copy) NSString *fileUrl;
  274. @end
  275. /**
  276. * 表情的类
  277. * 表请的缩略图数据请存放在UMShareEmotionObject中
  278. * 注意:emotionData和emotionURL成员不能同时为空,若同时出现则取emotionURL
  279. */
  280. @interface UMShareEmotionObject : UMShareObject
  281. /**
  282. * 表情数据,如GIF等
  283. * @note 微信的话大小不能超过10M
  284. */
  285. @property (nonatomic, strong) NSData *emotionData;
  286. /**
  287. * @param title 标题
  288. * @param descr 描述
  289. * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
  290. *
  291. */
  292. + (UMShareEmotionObject *)shareObjectWithTitle:(NSString *)title
  293. descr:(NSString *)descr
  294. thumImage:(id)thumImage;
  295. @end
  296. #pragma mark - UMSAppExtendObject
  297. /*! @brief 多媒体消息中包含的App扩展数据对象
  298. *
  299. * 第三方程序向微信终端发送包含UMShareExtendObject的多媒体消息,
  300. * 微信需要处理该消息时,会调用该第三方程序来处理多媒体消息内容。
  301. * @note url,extInfo和fileData不能同时为空
  302. * @see UMShareObject
  303. */
  304. @interface UMShareExtendObject : UMShareObject
  305. /** 若第三方程序不存在,微信终端会打开该url所指的App下载地址
  306. * @note 长度不能超过10K
  307. */
  308. @property (nonatomic, retain) NSString *url;
  309. /** 第三方程序自定义简单数据,微信终端会回传给第三方程序处理
  310. * @note 长度不能超过2K
  311. */
  312. @property (nonatomic, retain) NSString *extInfo;
  313. /** App文件数据,该数据发送给微信好友,微信好友需要点击后下载数据,微信终端会回传给第三方程序处理
  314. * @note 大小不能超过10M
  315. */
  316. @property (nonatomic, retain) NSData *fileData;
  317. @end
  318. #pragma mark - UMFileObject
  319. /*! @brief 多媒体消息中包含的文件数据对象
  320. *
  321. * @see UMShareObject
  322. */
  323. @interface UMShareFileObject : UMShareObject
  324. /** 文件后缀名
  325. * @note 长度不超过64字节
  326. */
  327. @property (nonatomic, retain) NSString *fileExtension;
  328. /** 文件真实数据内容
  329. * @note 大小不能超过10M
  330. */
  331. @property (nonatomic, retain) NSData *fileData;
  332. /** 文件的名字(不包含后缀)
  333. * @note 长度不超过64字节
  334. */
  335. @property (nonatomic, retain) NSString *fileName;
  336. @end
  337. #pragma mark - UMMiniProgramObject
  338. typedef NS_ENUM(NSUInteger, UShareWXMiniProgramType){
  339. UShareWXMiniProgramTypeRelease = 0, //**< 正式版 */
  340. UShareWXMiniProgramTypeTest = 1, //**< 开发版 */
  341. UShareWXMiniProgramTypePreview = 2, //**< 体验版 */
  342. };
  343. /*! @brief 多媒体消息中包含 分享微信小程序的数据对象
  344. *
  345. * @see UMShareObject
  346. */
  347. @interface UMShareMiniProgramObject : UMShareObject
  348. /**
  349. 低版本微信网页链接
  350. */
  351. @property (nonatomic, strong) NSString *webpageUrl;
  352. /**
  353. 小程序username
  354. */
  355. @property (nonatomic, strong) NSString *userName;
  356. /**
  357. 小程序页面的路径
  358. */
  359. @property (nonatomic, strong) NSString *path;
  360. /**
  361. 小程序新版本的预览图 128k
  362. */
  363. @property (nonatomic, strong) NSData *hdImageData;
  364. /**
  365. 分享小程序的版本(正式,开发,体验)
  366. 正式版 尾巴正常显示
  367. 开发版 尾巴显示“未发布的小程序·开发版”
  368. 体验版 尾巴显示“未发布的小程序·体验版”
  369. */
  370. @property (nonatomic, assign) UShareWXMiniProgramType miniProgramType;
  371. /**
  372. 是否使用带 shareTicket 的转发
  373. */
  374. @property (nonatomic, assign) BOOL withShareTicket;
  375. @end
  376. /*! @brief 移动应用直接跳转到小程序
  377. *
  378. * @see UMShareObject
  379. */
  380. @interface UMShareLaunchMiniProgramObject : UMShareObject
  381. /** 小程序username */
  382. @property (nonatomic, copy) NSString *userName;
  383. /** 小程序页面的路径
  384. * @attention 不填默认拉起小程序首页
  385. */
  386. @property (nonatomic, copy, nullable) NSString *path;
  387. /**
  388. 分享小程序的版本(正式,开发,体验)
  389. */
  390. @property (nonatomic, assign) UShareWXMiniProgramType miniProgramType;
  391. /** ext信息
  392. * @attention json格式
  393. */
  394. @property (nonatomic, copy, nullable) NSString *extMsg;
  395. /** extDic
  396. * @attention 字典,可存放图片等比较大的数据
  397. */
  398. @property (nonatomic, copy, nullable) NSDictionary *extDic;
  399. @end
  400. /*! @brief UMShareObject的包装类
  401. *
  402. * @see 目前用于企业微信的分享
  403. */
  404. @interface UMShareObjectWrapper:NSObject
  405. /**
  406. * name 名字
  407. */
  408. @property (nonatomic, copy) NSString *name;
  409. /**
  410. * date 时间
  411. */
  412. @property (nonatomic, copy) NSDate *date;
  413. /**
  414. * avatarUrl 头像url
  415. * avatarData 头像的NSData数据
  416. */
  417. @property (nonatomic, copy, nullable) NSString *avatarUrl;
  418. @property (nonatomic, copy, nullable) NSData *avatarData;
  419. /**
  420. * avatarUrl 头像url
  421. * avatarData 头像的NSData数据
  422. */
  423. @property (nonatomic, retain) UMShareObject *shareObject;
  424. /**
  425. * 其他相关参数
  426. */
  427. @property (nonatomic, strong) NSDictionary *moreInfo;
  428. @end
  429. @interface UMShareTextObjectForGroup : UMShareObject
  430. @property(nonatomic,copy,nullable) NSString* text;
  431. @end
  432. @interface UMSocialMessageObjectGroup : UMSocialMessageObject
  433. @end