ShareSDKUnity3DBridge.m 175 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717
  1. //
  2. // ShareSDKUnity3DBridge.m
  3. // Unity-iPhone
  4. //
  5. // Created by 陈 剑东 on 15/7/28.
  6. // Copyright (c) 2015年 mob. All rights reserved.
  7. //
  8. #import "ShareSDKUnity3DBridge.h"
  9. #import <ShareSDK/ShareSDK.h>
  10. #import <ShareSDK/ShareSDK+Base.h>
  11. #import <ShareSDKExtension/ShareSDK+Extension.h>
  12. #import <ShareSDKExtension/SSDKFriendsPaging.h>
  13. #import <ShareSDKUI/ShareSDK+SSUI.h>
  14. #import <ShareSDKExtension/SSEShareHelper.h>
  15. #import <ShareSDKConnector/ShareSDKConnector.h>
  16. #import <ShareSDKConfigFile/ShareSDK+XML.h>
  17. #import <MOBFoundation/MOBFJson.h>
  18. #import <MOBFoundation/MOBFRegex.h>
  19. #import <MOBFoundation/MOBFDevice.h>
  20. #define __SHARESDK_WECHAT__
  21. #define __SHARESDK_QQ__
  22. #define __SHARESDK_SINA_WEIBO__
  23. #define __SHARESDK_RENREN__
  24. #define __SHARESDK_KAKAO__
  25. #define __SHARESDK_YIXIN__
  26. #define __SHARESDK_FACEBOOK_MSG__
  27. #define __SHARESDK_ALIPAYSOCIAL__
  28. #define __SHARESDK_DINGTALK__
  29. #ifdef __SHARESDK_WECHAT__
  30. #import "WXApi.h"
  31. #endif
  32. #ifdef __SHARESDK_QQ__
  33. #import <TencentOpenAPI/TencentOAuth.h>
  34. #import <TencentOpenAPI/QQApiInterface.h>
  35. #endif
  36. #ifdef __SHARESDK_SINA_WEIBO__
  37. #import "WeiboSDK.h"
  38. #endif
  39. #ifdef __SHARESDK_RENREN__
  40. #import <RennSDK/RennSDK.h>
  41. #endif
  42. #ifdef __SHARESDK_KAKAO__
  43. #import <KakaoOpenSDK/KakaoOpenSDK.h>
  44. #endif
  45. #ifdef __SHARESDK_YIXIN__
  46. #import "YXApi.h"
  47. #endif
  48. #ifdef __SHARESDK_FACEBOOK_MSG__
  49. #import <FBSDKMessengerShareKit/FBSDKMessengerShareKit.h>
  50. #endif
  51. #ifdef __SHARESDK_ALIPAYSOCIAL__
  52. #import "APOpenAPI.h"
  53. #endif
  54. #ifdef __SHARESDK_DINGTALK__
  55. #import <DTShareKit/DTOpenAPI.h>
  56. #endif
  57. static UIView *_refView = nil;
  58. #if defined (__cplusplus)
  59. extern "C" {
  60. #endif
  61. /**
  62. * @brief 配置SDK并初始化
  63. *
  64. * @param appKey ShareSDK的AppKey
  65. * @param configInfo 配置信息
  66. */
  67. extern void __iosShareSDKRegisterAppAndSetPltformsConfig (void *appKey, void*configInfo);
  68. /**
  69. * 用户授权
  70. *
  71. * @param reqID 流水号
  72. * @param platType 平台类型
  73. * @param observer 观察回调对象名称
  74. */
  75. extern void __iosShareSDKAuthorize (int reqID, int platType, void *observer);
  76. /**
  77. * @brief 取消用户授权
  78. *
  79. * @param platType 平台类型
  80. */
  81. extern void __iosShareSDKCancelAuthorize (int platType);
  82. /**
  83. * @brief 判断用户是否授权
  84. *
  85. * @param platType 平台类型
  86. *
  87. * @return YES 表示已经授权,NO 表示尚未授权
  88. */
  89. extern bool __iosShareSDKHasAuthorized (int platType);
  90. /**
  91. * @brief 检测是否安装客户端
  92. *
  93. * @param platType 平台类型
  94. *
  95. * @return YES 表示已经安装,NO 表示尚未安装
  96. */
  97. extern bool __iosShareSDKIsClientInstalled (int platType);
  98. /**
  99. * @brief 获取用户信息
  100. *
  101. * @param reqID 流水号
  102. * @param platType 平台类型
  103. * @param observer 观察回调对象名称
  104. */
  105. extern void __iosShareSDKGetUserInfo (int reqID, int platType, void *observer);
  106. /**
  107. * @brief 分享内容
  108. *
  109. * @param reqID 流水号
  110. * @param platType 平台类型
  111. * @param content 分享内容
  112. * @param observer 观察回调对象名称
  113. */
  114. extern void __iosShareSDKShare (int reqID, int platType, void *content, void *observer);
  115. /**
  116. * @brief 一键分享内容
  117. *
  118. * @param reqID 流水号
  119. * @param platTypes 平台类型列表
  120. * @param content 分享内容
  121. * @param observer 观察回调对象名称
  122. */
  123. extern void __iosShareSDKOneKeyShare (int reqID, void *platTypes, void *content, void *observer);
  124. /**
  125. * @brief 显示分享菜单
  126. *
  127. * @param reqID 流水号
  128. * @param platTypes 平台类型列表
  129. * @param content 分享内容
  130. * @param x 弹出菜单的箭头的横坐标,仅用于iPad
  131. * @param y 弹出菜单的箭头的纵坐标,仅用于iPad
  132. * @param observer 观察回调对象名称
  133. */
  134. extern void __iosShareSDKShowShareMenu (int reqID, void *platTypes, void *content, int x, int y, void *observer);
  135. /**
  136. * @brief 显示分享编辑界面
  137. *
  138. * @param reqID 流水号
  139. * @param platType 平台类型
  140. * @param content 分享内容
  141. * @param observer 观察回调对象名称
  142. */
  143. extern void __iosShareSDKShowShareView (int reqID, int platType, void *content, void *observer);
  144. /**
  145. * @brief 获取授权用户好友列表
  146. *
  147. * @param reqID 流水号
  148. * @param platType 平台类型
  149. * @param count 单页好友数量
  150. * @param page 页码/游标cusor
  151. * @param observer 观察回调对象名称
  152. */
  153. extern void __iosShareSDKGetFriendsList (int reqID, int platType, int count , int page, void *observer);
  154. /**
  155. * @brief 获取授权信息
  156. *
  157. * @param platType 平台类型
  158. * @param observer 观察回调对象名称
  159. */
  160. extern const char* __iosShareSDKGetCredential (int platType);
  161. /**
  162. * @brief 关注/添加好友
  163. *
  164. * @param platType 平台类型
  165. * @param observer 观察回调对象名称
  166. */
  167. extern void __iosShareSDKFollowFriend (int reqID, int platType, void *account, void *observer);
  168. /**
  169. * @brief 根据配置文件分享
  170. *
  171. * @param reqID 流水号
  172. * @param contentName 配置文件节点标识
  173. * @param customHashtable 自定义字段表
  174. * @param platType 平台类型
  175. * @param observer 观察回调对象名称
  176. */
  177. extern void __iosShareSDKShareWithContentName(int reqID,
  178. int platType,
  179. void *contentName,
  180. void *customHashtable,
  181. void *observer);
  182. /**
  183. * @brief 根据配置文件展示分享菜单
  184. *
  185. * @param reqID 流水号
  186. * @param contentName 配置文件节点标识
  187. * @param customHashtable 自定义字段表
  188. * @param platTypes 平台类型列表
  189. * @param x 弹出菜单的箭头的横坐标,仅用于iPad
  190. * @param y 弹出菜单的箭头的纵坐标,仅用于iPad
  191. * @param observer 观察回调对象名称
  192. */
  193. extern void __iosShareSDKShowShareMenuWithContentName(int reqID,
  194. void *contentName,
  195. void *customHashtable,
  196. void *platTypes,
  197. int x,
  198. int y,
  199. void *observer);
  200. /**
  201. * @brief 根据配置文件展示分享编辑界面
  202. *
  203. * @param reqID 流水号
  204. * @param contentName 配置文件节点标识
  205. * @param customHashtable 自定义字段表
  206. * @param platType 平台类型
  207. * @param observer 观察回调对象名称
  208. */
  209. extern void __iosShareSDKShowShareViewWithContentName(int reqID,
  210. int platType,
  211. void *contentName,
  212. void *customHashtable,
  213. void *observer);
  214. #if defined (__cplusplus)
  215. }
  216. #endif
  217. #if defined (__cplusplus)
  218. extern "C" {
  219. #endif
  220. NSMutableDictionary *__parseWithHashtable (void*configInfo)
  221. {
  222. NSString *confCs = [NSString stringWithCString:configInfo encoding:NSUTF8StringEncoding];
  223. NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[MOBFJson objectFromJSONString:confCs]];
  224. return dic;
  225. }
  226. SSDKPlatformType __convertContentType(NSInteger type)
  227. {
  228. switch (type)
  229. {
  230. case 0:
  231. return SSDKContentTypeAuto;
  232. case 1:
  233. return SSDKContentTypeText;
  234. case 2:
  235. return SSDKContentTypeImage;
  236. case 4:
  237. return SSDKContentTypeWebPage;
  238. case 5:
  239. return SSDKContentTypeAudio;
  240. case 6:
  241. return SSDKContentTypeVideo;
  242. case 7:
  243. return SSDKContentTypeApp;
  244. case 8:
  245. return SSDKContentTypeFile;
  246. case 9:
  247. return SSDKContentTypeImage;
  248. default:
  249. return SSDKContentTypeText;
  250. }
  251. }
  252. void __setWechatParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  253. {
  254. NSString *text = nil;
  255. NSString *title = nil;
  256. NSString *url = nil;
  257. NSString *thumbImg = nil;
  258. NSString *image = nil;
  259. NSString *musicFileUrl = nil;
  260. NSString *extInfo = nil;
  261. NSData *fileData = nil;
  262. NSData *emoData = nil;
  263. NSString *sourceFileExtension = nil;
  264. NSData *sourceFileData = nil;
  265. SSDKContentType type = SSDKContentTypeText;
  266. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  267. {
  268. text = [value objectForKey:@"text"];
  269. }
  270. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  271. {
  272. title = [value objectForKey:@"title"];
  273. }
  274. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  275. {
  276. url = [value objectForKey:@"url"];
  277. }
  278. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  279. {
  280. thumbImg = [value objectForKey:@"thumbImageUrl"];
  281. }
  282. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  283. {
  284. image = [value objectForKey:@"imageUrl"];
  285. }
  286. if ([[value objectForKey:@"musicUrl"] isKindOfClass:[NSString class]])
  287. {
  288. musicFileUrl = [value objectForKey:@"musicUrl"];
  289. }
  290. if ([[value objectForKey:@"extInfoPath"] isKindOfClass:[NSString class]])
  291. {
  292. extInfo = [value objectForKey:@"extInfoPath"];
  293. }
  294. if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
  295. {
  296. fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"filePath"]];
  297. }
  298. if ([[value objectForKey:@"emotionPath"] isKindOfClass:[NSString class]])
  299. {
  300. emoData = [NSData dataWithContentsOfFile:[value objectForKey:@"emotionPath"]];
  301. }
  302. if ([[value objectForKey:@"sourceFileExtension"] isKindOfClass:[NSString class]])
  303. {
  304. sourceFileExtension = [value objectForKey:@"sourceFileExtension"];
  305. }
  306. if ([[value objectForKey:@"sourceFilePath"] isKindOfClass:[NSString class]])
  307. {
  308. sourceFileData = [NSData dataWithContentsOfFile:[value objectForKey:@"sourceFilePath"]];
  309. }
  310. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  311. {
  312. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  313. }
  314. [params SSDKSetupWeChatParamsByText:text
  315. title:title
  316. url:[NSURL URLWithString:url]
  317. thumbImage:thumbImg
  318. image:image
  319. musicFileURL:[NSURL URLWithString:musicFileUrl]
  320. extInfo:extInfo
  321. fileData:fileData
  322. emoticonData:emoData
  323. sourceFileExtension:sourceFileExtension
  324. sourceFileData:sourceFileData
  325. type:type
  326. forPlatformSubType:subType];
  327. }
  328. void __setQQParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  329. {
  330. NSString *text = nil;
  331. NSString *title = nil;
  332. NSString *url = nil;
  333. NSString *thumbImg = nil;
  334. NSString *image = nil;
  335. SSDKContentType type = SSDKContentTypeText;
  336. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  337. {
  338. text = [value objectForKey:@"text"];
  339. }
  340. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  341. {
  342. title = [value objectForKey:@"title"];
  343. }
  344. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  345. {
  346. url = [value objectForKey:@"url"];
  347. }
  348. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  349. {
  350. thumbImg = [value objectForKey:@"thumbImageUrl"];
  351. }
  352. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  353. {
  354. image = [value objectForKey:@"imageUrl"];
  355. }
  356. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  357. {
  358. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  359. }
  360. [params SSDKSetupQQParamsByText:text
  361. title:title
  362. url:[NSURL URLWithString:url]
  363. thumbImage:thumbImg
  364. image:image
  365. type:type
  366. forPlatformSubType:subType];
  367. }
  368. void __setYixinParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  369. {
  370. NSString *text = nil;
  371. NSString *title = nil;
  372. NSString *url = nil;
  373. NSString *thumbImg = nil;
  374. NSString *image = nil;
  375. NSString *musicFileURL = nil;
  376. NSString *extInfo = nil;
  377. NSString *fileDataPath = nil;
  378. NSString *comment = nil;
  379. NSString *toUserId = nil;
  380. SSDKContentType type = SSDKContentTypeText;
  381. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  382. {
  383. text = [value objectForKey:@"text"];
  384. }
  385. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  386. {
  387. title = [value objectForKey:@"title"];
  388. }
  389. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  390. {
  391. url = [value objectForKey:@"url"];
  392. }
  393. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  394. {
  395. thumbImg = [value objectForKey:@"thumbImageUrl"];
  396. }
  397. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  398. {
  399. image = [value objectForKey:@"imageUrl"];
  400. }
  401. if ([[value objectForKey:@"musicUrl"] isKindOfClass:[NSString class]])
  402. {
  403. musicFileURL = [value objectForKey:@"musicUrl"];
  404. }
  405. if ([[value objectForKey:@"extInfoPath"] isKindOfClass:[NSString class]])
  406. {
  407. extInfo = [value objectForKey:@"extInfoPath"];
  408. }
  409. if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
  410. {
  411. fileDataPath = [value objectForKey:@"filePath"];
  412. }
  413. if ([[value objectForKey:@"comment"] isKindOfClass:[NSString class]])
  414. {
  415. comment = [value objectForKey:@"comment"];
  416. }
  417. if ([[value objectForKey:@"toUserID"] isKindOfClass:[NSString class]])
  418. {
  419. toUserId = [value objectForKey:@"toUserID"];
  420. }
  421. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  422. {
  423. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  424. }
  425. [params SSDKSetupYiXinParamsByText:text
  426. title:title
  427. url:[NSURL URLWithString:url]
  428. thumbImage:thumbImg
  429. image:image
  430. musicFileURL:[NSURL URLWithString:musicFileURL]
  431. extInfo:extInfo
  432. fileData:fileDataPath
  433. comment:comment
  434. toUserId:toUserId
  435. type:type
  436. forPlatformSubType:subType];
  437. }
  438. void __setKakaoParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  439. {
  440. NSString *text = nil;
  441. NSMutableArray *images = [NSMutableArray array];
  442. NSString *title = nil;
  443. NSString *url = nil;
  444. NSString *permission = nil;
  445. BOOL enableShare;
  446. CGFloat imageWidth;
  447. CGFloat imageHeight;
  448. NSString *appButtonTitle = nil;
  449. NSDictionary *androidExecParam = nil;
  450. NSString *androidMarkParam = nil;
  451. NSDictionary *iphoneExecParams = nil;
  452. NSString *iphoneMarkParam = nil;
  453. NSDictionary *ipadExecParams = nil;
  454. NSString *ipadMarkParam = nil;
  455. SSDKContentType type = SSDKContentTypeText;
  456. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  457. {
  458. text = [value objectForKey:@"text"];
  459. }
  460. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  461. {
  462. NSString *imgPath = [value objectForKey:@"imageUrl"];
  463. SSDKImage *image = nil;
  464. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  465. options:MOBFRegexOptionsNoOptions
  466. inRange:NSMakeRange(0, imgPath.length)
  467. withString:imgPath])
  468. {
  469. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  470. }
  471. else
  472. {
  473. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  474. image = [[SSDKImage alloc] initWithImage:localImg
  475. format:SSDKImageFormatJpeg
  476. settings:nil];
  477. }
  478. if (image)
  479. {
  480. [images addObject:imgPath];
  481. }
  482. else
  483. {
  484. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  485. }
  486. }
  487. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  488. {
  489. NSArray *paths = [value objectForKey:@"imageUrl"];
  490. for (NSString *path in paths)
  491. {
  492. SSDKImage *image = nil;
  493. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  494. options:MOBFRegexOptionsNoOptions
  495. inRange:NSMakeRange(0, path.length)
  496. withString:path])
  497. {
  498. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  499. }
  500. else
  501. {
  502. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  503. image = [[SSDKImage alloc] initWithImage:localImg
  504. format:SSDKImageFormatJpeg
  505. settings:nil];
  506. }
  507. if (image)
  508. {
  509. [images addObject:path];
  510. }
  511. else
  512. {
  513. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  514. }
  515. }
  516. }
  517. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  518. {
  519. title = [value objectForKey:@"title"];
  520. }
  521. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  522. {
  523. url = [value objectForKey:@"url"];
  524. }
  525. if ([[value objectForKey:@"permission"] isKindOfClass:[NSString class]])
  526. {
  527. permission = [value objectForKey:@"permission"];
  528. }
  529. if ([[value objectForKey:@"enableShare"] boolValue])
  530. {
  531. enableShare = YES;
  532. }
  533. if ([[value objectForKey:@"imageWidth"] isKindOfClass:[NSNumber class]])
  534. {
  535. imageWidth = [[value objectForKey:@"imageWidth"] floatValue];
  536. }
  537. if ([[value objectForKey:@"imageHeight"] isKindOfClass:[NSNumber class]])
  538. {
  539. imageHeight = [[value objectForKey:@"imageHeight"] floatValue];
  540. }
  541. if ([[value objectForKey:@"appButtonTitle"] isKindOfClass:[NSString class]])
  542. {
  543. appButtonTitle = [value objectForKey:@"appButtonTitle"];
  544. }
  545. if ([[value objectForKey:@"androidExecParam"] isKindOfClass:[NSDictionary class]])
  546. {
  547. androidExecParam = [value objectForKey:@"androidExecParam"];
  548. }
  549. if ([[value objectForKey:@"androidMarkParam"] isKindOfClass:[NSString class]])
  550. {
  551. androidMarkParam = [value objectForKey:@"androidMarkParam"];
  552. }
  553. if ([[value objectForKey:@"iphoneExecParam"] isKindOfClass:[NSDictionary class]])
  554. {
  555. iphoneExecParams = [value objectForKey:@"iphoneExecParam"];
  556. }
  557. if ([[value objectForKey:@"iphoneMarkParam"] isKindOfClass:[NSString class]])
  558. {
  559. iphoneMarkParam = [value objectForKey:@"iphoneMarkParam"];
  560. }
  561. if ([[value objectForKey:@"ipadExecParam"] isKindOfClass:[NSDictionary class]])
  562. {
  563. ipadExecParams = [value objectForKey:@"ipadExecParam"];
  564. }
  565. if ([[value objectForKey:@"ipadMarkParam"] isKindOfClass:[NSString class]])
  566. {
  567. ipadMarkParam = [value objectForKey:@"ipadMarkParam"];
  568. }
  569. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  570. {
  571. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  572. }
  573. [params SSDKSetupKaKaoParamsByText:text
  574. images:images
  575. title:title
  576. url:[NSURL URLWithString:url]
  577. permission:permission
  578. enableShare:enableShare
  579. imageSize:CGSizeMake(imageWidth, imageHeight)
  580. appButtonTitle:appButtonTitle
  581. androidExecParam:androidExecParam
  582. androidMarkParam:androidMarkParam
  583. iphoneExecParams:iphoneExecParams
  584. iphoneMarkParam:iphoneMarkParam
  585. ipadExecParams:ipadExecParams
  586. ipadMarkParam:ipadMarkParam
  587. type:type
  588. forPlatformSubType:subType];
  589. }
  590. NSMutableDictionary *__getShareParamsWithString(NSString *dataStr)
  591. {
  592. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  593. NSMutableArray *imageArray = [NSMutableArray array];
  594. NSString *text = nil;
  595. NSString *title = nil;
  596. NSString *url = nil;
  597. SSDKContentType type = SSDKContentTypeText;
  598. NSDictionary *shareParamsDic = [MOBFJson objectFromJSONString:dataStr];
  599. if (shareParamsDic)
  600. {
  601. if ([[shareParamsDic objectForKey:@"text"] isKindOfClass:[NSString class]])
  602. {
  603. text = [shareParamsDic objectForKey:@"text"];
  604. }
  605. id img = [shareParamsDic objectForKey:@"imageUrl"];
  606. if ([img isKindOfClass:[NSString class]])
  607. {
  608. NSString *imgPath = img;
  609. SSDKImage *image = nil;
  610. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  611. options:MOBFRegexOptionsNoOptions
  612. inRange:NSMakeRange(0, imgPath.length)
  613. withString:imgPath])
  614. {
  615. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  616. }
  617. else
  618. {
  619. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  620. image = [[SSDKImage alloc] initWithImage:localImg
  621. format:SSDKImageFormatJpeg
  622. settings:nil];
  623. }
  624. if (image)
  625. {
  626. [imageArray addObject:imgPath];
  627. }
  628. else
  629. {
  630. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  631. }
  632. }
  633. else if([img isKindOfClass:[NSArray class]])
  634. {
  635. NSArray *paths = [img copy];
  636. for (NSString *path in paths)
  637. {
  638. SSDKImage *image = nil;
  639. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  640. options:MOBFRegexOptionsNoOptions
  641. inRange:NSMakeRange(0, path.length)
  642. withString:path])
  643. {
  644. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  645. }
  646. else
  647. {
  648. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  649. image = [[SSDKImage alloc] initWithImage:localImg
  650. format:SSDKImageFormatJpeg
  651. settings:nil];
  652. }
  653. if (image)
  654. {
  655. [imageArray addObject:path];
  656. }
  657. else
  658. {
  659. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  660. }
  661. }
  662. }
  663. if ([[shareParamsDic objectForKey:@"title"] isKindOfClass:[NSString class]])
  664. {
  665. title = [shareParamsDic objectForKey:@"title"];
  666. }
  667. if ([[shareParamsDic objectForKey:@"url"] isKindOfClass:[NSString class]])
  668. {
  669. url = [shareParamsDic objectForKey:@"url"];
  670. }
  671. if ([[shareParamsDic objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  672. {
  673. type = __convertContentType([[shareParamsDic objectForKey:@"shareType"] integerValue]);
  674. }
  675. if ([[shareParamsDic objectForKey:@"clientShare"] isKindOfClass:[NSNumber class]])
  676. {
  677. NSInteger enable = [[shareParamsDic objectForKey:@"clientShare"] integerValue];
  678. if (enable > 0)
  679. {
  680. [params SSDKEnableUseClientShare];
  681. }
  682. }
  683. [params SSDKSetupShareParamsByText:text
  684. images:imageArray
  685. url:[NSURL URLWithString:url]
  686. title:title
  687. type:type];
  688. NSDictionary *customizeShareParams = [shareParamsDic objectForKey:@"customizeShareParams"];
  689. if (customizeShareParams && [[customizeShareParams allKeys] count] > 0)
  690. {
  691. //新浪微博
  692. id value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSinaWeibo]]];
  693. if ([value isKindOfClass:[NSDictionary class]])
  694. {
  695. NSString *text = nil;
  696. NSString *title = nil;
  697. NSString *image = nil;
  698. NSString *url = nil;
  699. double lat = 0;
  700. double lng = 0;
  701. NSString *objID = nil;
  702. SSDKContentType type = SSDKContentTypeWebPage;
  703. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  704. {
  705. text = [value objectForKey:@"text"];
  706. }
  707. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  708. {
  709. title = [value objectForKey:@"title"];
  710. }
  711. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  712. {
  713. image = [value objectForKey:@"imageUrl"];
  714. }
  715. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  716. {
  717. url = [value objectForKey:@"url"];
  718. }
  719. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSString class]])
  720. {
  721. lat = [[value objectForKey:@"latitude"] doubleValue];
  722. }
  723. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSString class]])
  724. {
  725. lng = [[value objectForKey:@"longitude"] doubleValue];
  726. }
  727. if ([[value objectForKey:@"objectID"] isKindOfClass:[NSString class]])
  728. {
  729. objID = [value objectForKey:@"objectID"];
  730. }
  731. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  732. {
  733. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  734. }
  735. if ([[value objectForKey:@"clientShare"] isKindOfClass:[NSNumber class]])
  736. {
  737. NSInteger enable = [[value objectForKey:@"clientShare"] integerValue];
  738. if (enable > 0)
  739. {
  740. [params SSDKEnableUseClientShare];
  741. }
  742. }
  743. [params SSDKSetupSinaWeiboShareParamsByText:text
  744. title:title
  745. image:image
  746. url:[NSURL URLWithString:url]
  747. latitude:lat
  748. longitude:lng
  749. objectID:objID
  750. type:type];
  751. }
  752. //腾讯微博
  753. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTencentWeibo]]];
  754. if ([value isKindOfClass:[NSDictionary class]])
  755. {
  756. NSString *text = nil;
  757. NSMutableArray *images = [NSMutableArray array];
  758. double lat;
  759. double lng;
  760. SSDKContentType type = SSDKContentTypeImage;
  761. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  762. {
  763. text = [value objectForKey:@"text"];
  764. }
  765. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  766. {
  767. NSString *imgPath = [value objectForKey:@"imageUrl"];
  768. SSDKImage *image = nil;
  769. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  770. options:MOBFRegexOptionsNoOptions
  771. inRange:NSMakeRange(0, imgPath.length)
  772. withString:imgPath])
  773. {
  774. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  775. }
  776. else
  777. {
  778. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  779. image = [[SSDKImage alloc]initWithImage:localImg
  780. format:SSDKImageFormatJpeg
  781. settings:nil];
  782. }
  783. if (image)
  784. {
  785. [images addObject:imgPath];
  786. }
  787. else
  788. {
  789. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  790. }
  791. }
  792. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  793. {
  794. NSArray *paths = [value objectForKey:@"imageUrl"];
  795. for (NSString *path in paths)
  796. {
  797. SSDKImage *image = nil;
  798. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  799. options:MOBFRegexOptionsNoOptions
  800. inRange:NSMakeRange(0, path.length)
  801. withString:path])
  802. {
  803. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  804. }
  805. else
  806. {
  807. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  808. image = [[SSDKImage alloc] initWithImage:localImg
  809. format:SSDKImageFormatJpeg
  810. settings:nil];
  811. }
  812. if (image)
  813. {
  814. [images addObject:path];
  815. }
  816. else
  817. {
  818. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  819. }
  820. }
  821. }
  822. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSNumber class]])
  823. {
  824. lat = [[value objectForKey:@"latitude"] doubleValue];
  825. }
  826. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSNumber class]])
  827. {
  828. lng = [[value objectForKey:@"longitude"] doubleValue];
  829. }
  830. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  831. {
  832. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  833. }
  834. [params SSDKSetupTencentWeiboShareParamsByText:text
  835. images:images
  836. latitude:lat
  837. longitude:lng
  838. type:type];
  839. }
  840. //豆瓣
  841. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDouBan]]];
  842. if ([value isKindOfClass:[NSDictionary class]])
  843. {
  844. NSString *text = nil;
  845. NSString *image = nil;
  846. NSString *title = nil;
  847. NSString *url = nil;
  848. NSString *urlDesc = nil;
  849. SSDKContentType type = SSDKContentTypeText;
  850. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  851. {
  852. text = [value objectForKey:@"text"];
  853. }
  854. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  855. {
  856. image = [value objectForKey:@"imageUrl"];
  857. }
  858. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  859. {
  860. title = [value objectForKey:@"title"];
  861. }
  862. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  863. {
  864. url = [value objectForKey:@"url"];
  865. }
  866. if ([[value objectForKey:@"urlDesc"] isKindOfClass:[NSString class]])
  867. {
  868. urlDesc = [value objectForKey:@"urlDesc"];
  869. }
  870. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  871. {
  872. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  873. }
  874. [params SSDKSetupDouBanParamsByText:text
  875. image:image
  876. title:title
  877. url:[NSURL URLWithString:url]
  878. urlDesc:urlDesc
  879. type:type];
  880. }
  881. //QQ系列
  882. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeQQFriend]]];
  883. if ([value isKindOfClass:[NSDictionary class]])
  884. {
  885. __setQQParams(value,params,SSDKPlatformSubTypeQQFriend);
  886. }
  887. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeQZone]]];
  888. if ([value isKindOfClass:[NSDictionary class]])
  889. {
  890. __setQQParams(value,params,SSDKPlatformSubTypeQZone);
  891. }
  892. //微信系列
  893. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatSession]]];
  894. if ([value isKindOfClass:[NSDictionary class]])
  895. {
  896. __setWechatParams(value,params,SSDKPlatformSubTypeWechatSession);
  897. }
  898. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatTimeline]]];
  899. if ([value isKindOfClass:[NSDictionary class]])
  900. {
  901. __setWechatParams(value,params,SSDKPlatformSubTypeWechatTimeline);
  902. }
  903. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatFav]]];
  904. if ([value isKindOfClass:[NSDictionary class]])
  905. {
  906. __setWechatParams(value,params,SSDKPlatformSubTypeWechatFav);
  907. }
  908. //人人网
  909. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeRenren]]];
  910. if ([value isKindOfClass:[NSDictionary class]])
  911. {
  912. NSString *text = nil;
  913. NSString *image = nil;
  914. NSString *url = nil;
  915. NSString *albumId = nil;
  916. SSDKContentType type = SSDKContentTypeImage;
  917. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  918. {
  919. text = [value objectForKey:@"text"];
  920. }
  921. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  922. {
  923. image = [value objectForKey:@"imageUrl"];
  924. }
  925. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  926. {
  927. url = [value objectForKey:@"url"];
  928. }
  929. if ([[value objectForKey:@"albumID"] isKindOfClass:[NSString class]])
  930. {
  931. albumId = [value objectForKey:@"albumID"];
  932. }
  933. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  934. {
  935. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  936. }
  937. [params SSDKSetupRenRenParamsByText:text
  938. image:image
  939. url:[NSURL URLWithString:url]
  940. albumId:albumId
  941. type:type];
  942. }
  943. //开心网
  944. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeKaixin]]];
  945. if ([value isKindOfClass:[NSDictionary class]])
  946. {
  947. NSString *text = nil;
  948. NSString *image = nil;
  949. SSDKContentType type = SSDKContentTypeText;
  950. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  951. {
  952. text = [value objectForKey:@"text"];
  953. }
  954. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  955. {
  956. image = [value objectForKey:@"imageUrl"];
  957. }
  958. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  959. {
  960. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  961. }
  962. [params SSDKSetupKaiXinParamsByText:text
  963. image:image
  964. type:type];
  965. }
  966. //Facebook
  967. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFacebook]]];
  968. if ([value isKindOfClass:[NSDictionary class]])
  969. {
  970. NSString *text = nil;
  971. NSString *image = nil;
  972. NSString *title = nil;
  973. NSString *urlDesc = nil;
  974. NSString *attachmentPath = nil;
  975. SSDKContentType type = SSDKContentTypeText;
  976. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  977. {
  978. text = [value objectForKey:@"text"];
  979. }
  980. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  981. {
  982. image = [value objectForKey:@"imageUrl"];
  983. }
  984. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  985. {
  986. url = [value objectForKey:@"url"];
  987. }
  988. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  989. {
  990. title = [value objectForKey:@"title"];
  991. }
  992. if ([[value objectForKey:@"urlDesc"] isKindOfClass:[NSString class]])
  993. {
  994. urlDesc = [value objectForKey:@"urlDesc"];
  995. }
  996. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  997. {
  998. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  999. }
  1000. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1001. {
  1002. attachmentPath = [value objectForKey:@"attachmentPath"];
  1003. }
  1004. if ([[value objectForKey:@"clientShare"] isKindOfClass:[NSNumber class]])
  1005. {
  1006. NSInteger enable = [[value objectForKey:@"clientShare"] integerValue];
  1007. if (enable > 0)
  1008. {
  1009. [params SSDKEnableUseClientShare];
  1010. }
  1011. }
  1012. [params SSDKSetupFacebookParamsByText:text
  1013. image:image
  1014. url:[NSURL URLWithString:url]
  1015. urlTitle:title
  1016. urlName:urlDesc
  1017. attachementUrl:[NSURL URLWithString:attachmentPath]
  1018. type:type];
  1019. }
  1020. //Twitter
  1021. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTwitter]]];
  1022. if ([value isKindOfClass:[NSDictionary class]])
  1023. {
  1024. NSString *text = nil;
  1025. NSMutableArray *images = [NSMutableArray array];
  1026. double lat;
  1027. double lng;
  1028. SSDKContentType type = SSDKContentTypeText;
  1029. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1030. {
  1031. text = [value objectForKey:@"text"];
  1032. }
  1033. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1034. {
  1035. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1036. SSDKImage *image = nil;
  1037. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1038. options:MOBFRegexOptionsNoOptions
  1039. inRange:NSMakeRange(0, imgPath.length)
  1040. withString:imgPath])
  1041. {
  1042. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1043. }
  1044. else
  1045. {
  1046. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1047. image = [[SSDKImage alloc] initWithImage:localImg
  1048. format:SSDKImageFormatJpeg
  1049. settings:nil];
  1050. }
  1051. if (image)
  1052. {
  1053. [images addObject:imgPath];
  1054. }
  1055. else
  1056. {
  1057. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1058. }
  1059. }
  1060. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1061. {
  1062. NSArray *paths = [value objectForKey:@"imageUrl"];
  1063. for (NSString *path in paths)
  1064. {
  1065. SSDKImage *image = nil;
  1066. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1067. options:MOBFRegexOptionsNoOptions
  1068. inRange:NSMakeRange(0, path.length)
  1069. withString:path])
  1070. {
  1071. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1072. }
  1073. else
  1074. {
  1075. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1076. image = [[SSDKImage alloc] initWithImage:localImg
  1077. format:SSDKImageFormatJpeg
  1078. settings:nil];
  1079. }
  1080. if (image)
  1081. {
  1082. [images addObject:path];
  1083. }
  1084. else
  1085. {
  1086. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1087. }
  1088. }
  1089. }
  1090. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSNumber class]])
  1091. {
  1092. lat = [[value objectForKey:@"latitude"] doubleValue];
  1093. }
  1094. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSNumber class]])
  1095. {
  1096. lng = [[value objectForKey:@"longitude"] doubleValue];
  1097. }
  1098. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1099. {
  1100. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1101. }
  1102. [params SSDKSetupTwitterParamsByText:text
  1103. images:images
  1104. latitude:lat
  1105. longitude:lng
  1106. type:type];
  1107. }
  1108. //YinXiang
  1109. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYinXiang]]];
  1110. if ([value isKindOfClass:[NSDictionary class]])
  1111. {
  1112. NSString *text = nil;
  1113. NSString *title = nil;
  1114. NSMutableArray *images = [NSMutableArray array];
  1115. NSMutableArray *tags = [NSMutableArray array];
  1116. NSString *notebook = nil;
  1117. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1118. {
  1119. text = [value objectForKey:@"text"];
  1120. }
  1121. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1122. {
  1123. title = [value objectForKey:@"title"];
  1124. }
  1125. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1126. {
  1127. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1128. SSDKImage *image = nil;
  1129. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1130. options:MOBFRegexOptionsNoOptions
  1131. inRange:NSMakeRange(0, imgPath.length)
  1132. withString:imgPath])
  1133. {
  1134. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1135. }
  1136. else
  1137. {
  1138. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1139. image = [[SSDKImage alloc] initWithImage:localImg
  1140. format:SSDKImageFormatJpeg
  1141. settings:nil];
  1142. }
  1143. if (image)
  1144. {
  1145. [images addObject:imgPath];
  1146. }
  1147. else
  1148. {
  1149. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1150. }
  1151. }
  1152. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1153. {
  1154. NSArray *paths = [value objectForKey:@"imageUrl"];
  1155. for (NSString *path in paths)
  1156. {
  1157. SSDKImage *image = nil;
  1158. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1159. options:MOBFRegexOptionsNoOptions
  1160. inRange:NSMakeRange(0, path.length)
  1161. withString:path])
  1162. {
  1163. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1164. }
  1165. else
  1166. {
  1167. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1168. image = [[SSDKImage alloc] initWithImage:localImg
  1169. format:SSDKImageFormatJpeg
  1170. settings:nil];
  1171. }
  1172. if (image)
  1173. {
  1174. [images addObject:path];
  1175. }
  1176. else
  1177. {
  1178. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1179. }
  1180. }
  1181. }
  1182. if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
  1183. {
  1184. notebook = [value objectForKey:@"notebook"];
  1185. }
  1186. id tagValue = [value objectForKey:@"tags"];
  1187. if ([tagValue isKindOfClass:[NSString class]])
  1188. {
  1189. [tags addObject:tagValue];
  1190. }
  1191. else if ([tagValue isKindOfClass:[NSArray class]])
  1192. {
  1193. tags = [tagValue mutableCopy];
  1194. }
  1195. [params SSDKSetupEvernoteParamsByText:text
  1196. images:images
  1197. title:title
  1198. notebook:notebook
  1199. tags:tags
  1200. platformType:SSDKPlatformTypeYinXiang];
  1201. }
  1202. //GooglePlus
  1203. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeGooglePlus]]];
  1204. if ([value isKindOfClass:[NSDictionary class]])
  1205. {
  1206. NSString *text = nil;
  1207. NSString *url = nil;
  1208. SSDKContentType type = SSDKContentTypeText;
  1209. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1210. {
  1211. text = [value objectForKey:@"text"];
  1212. }
  1213. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1214. {
  1215. url = [value objectForKey:@"url"];
  1216. }
  1217. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1218. {
  1219. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1220. }
  1221. [params SSDKSetupGooglePlusParamsByText:text
  1222. url:[NSURL URLWithString:url]
  1223. type:type];
  1224. }
  1225. //Instagram
  1226. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeInstagram]]];
  1227. if ([value isKindOfClass:[NSDictionary class]])
  1228. {
  1229. NSString *image = nil;
  1230. CGFloat menuX;
  1231. CGFloat menuY;
  1232. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1233. {
  1234. image = [value objectForKey:@"imageUrl"];
  1235. }
  1236. if ([[value objectForKey:@"menuX"] isKindOfClass:[NSString class]])
  1237. {
  1238. menuX = [[value objectForKey:@"menuX"] floatValue];
  1239. }
  1240. if ([[value objectForKey:@"menuY"] isKindOfClass:[NSString class]])
  1241. {
  1242. menuX = [[value objectForKey:@"menuY"] floatValue];
  1243. }
  1244. CGPoint point = CGPointMake(menuX, menuY);
  1245. [params SSDKSetupInstagramByImage:image menuDisplayPoint:point];
  1246. }
  1247. //LinkedIn
  1248. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeLinkedIn]]];
  1249. if ([value isKindOfClass:[NSDictionary class]])
  1250. {
  1251. NSString *text = nil;
  1252. NSString *image = nil;
  1253. NSString *title = nil;
  1254. NSString *url = nil;
  1255. NSString *urlDesc = nil;
  1256. NSString *visibility = nil;
  1257. SSDKContentType type = SSDKContentTypeText;
  1258. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1259. {
  1260. text = [value objectForKey:@"text"];
  1261. }
  1262. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1263. {
  1264. image = [value objectForKey:@"imageUrl"];
  1265. }
  1266. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1267. {
  1268. title = [value objectForKey:@"title"];
  1269. }
  1270. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1271. {
  1272. url = [value objectForKey:@"url"];
  1273. }
  1274. if ([[value objectForKey:@"urlDesc"] isKindOfClass:[NSString class]])
  1275. {
  1276. urlDesc = [value objectForKey:@"urlDesc"];
  1277. }
  1278. if ([[value objectForKey:@"visibility"] isKindOfClass:[NSString class]])
  1279. {
  1280. visibility = [value objectForKey:@"visibility"];
  1281. }
  1282. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1283. {
  1284. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1285. }
  1286. [params SSDKSetupLinkedInParamsByText:text
  1287. image:image
  1288. url:[NSURL URLWithString:url]
  1289. title:title
  1290. urlDesc:urlDesc
  1291. visibility:visibility
  1292. type:type];
  1293. }
  1294. //Tumblr
  1295. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTumblr]]];
  1296. if ([value isKindOfClass:[NSDictionary class]])
  1297. {
  1298. NSString *text = nil;
  1299. NSString *image = nil;
  1300. NSString *title = nil;
  1301. NSString *url = nil;
  1302. NSString *blogName = nil;
  1303. SSDKContentType type = SSDKContentTypeText;
  1304. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1305. {
  1306. text = [value objectForKey:@"text"];
  1307. }
  1308. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1309. {
  1310. image = [value objectForKey:@"imageUrl"];
  1311. }
  1312. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1313. {
  1314. title = [value objectForKey:@"title"];
  1315. }
  1316. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1317. {
  1318. url = [value objectForKey:@"url"];
  1319. }
  1320. if ([[value objectForKey:@"blogName"] isKindOfClass:[NSString class]])
  1321. {
  1322. blogName = [value objectForKey:@"blogName"];
  1323. }
  1324. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1325. {
  1326. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1327. }
  1328. [params SSDKSetupTumblrParamsByText:text
  1329. image:image
  1330. url:[NSURL URLWithString:url]
  1331. title:title
  1332. blogName:blogName
  1333. type:type];
  1334. }
  1335. //Mail
  1336. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeMail]]];
  1337. if ([value isKindOfClass:[NSDictionary class]])
  1338. {
  1339. NSString *text = nil;
  1340. NSString *title = nil;
  1341. NSMutableArray *images = [NSMutableArray array];
  1342. NSMutableArray *attachments = [NSMutableArray array];
  1343. NSMutableArray *recipients = [NSMutableArray array];
  1344. NSMutableArray *ccRecipients = [NSMutableArray array];
  1345. NSMutableArray *bccRecipients = [NSMutableArray array];
  1346. SSDKContentType type = SSDKContentTypeText;
  1347. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1348. {
  1349. text = [value objectForKey:@"text"];
  1350. }
  1351. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1352. {
  1353. title = [value objectForKey:@"title"];
  1354. }
  1355. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1356. {
  1357. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1358. SSDKImage *image = nil;
  1359. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1360. options:MOBFRegexOptionsNoOptions
  1361. inRange:NSMakeRange(0, imgPath.length)
  1362. withString:imgPath])
  1363. {
  1364. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1365. }
  1366. else
  1367. {
  1368. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1369. image = [[SSDKImage alloc] initWithImage:localImg
  1370. format:SSDKImageFormatJpeg
  1371. settings:nil];
  1372. }
  1373. if (image)
  1374. {
  1375. [images addObject:imgPath];
  1376. }
  1377. else
  1378. {
  1379. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1380. }
  1381. }
  1382. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1383. {
  1384. NSArray *paths = [value objectForKey:@"imageUrl"];
  1385. for (NSString *path in paths)
  1386. {
  1387. SSDKImage *image = nil;
  1388. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1389. options:MOBFRegexOptionsNoOptions
  1390. inRange:NSMakeRange(0, path.length)
  1391. withString:path])
  1392. {
  1393. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1394. }
  1395. else
  1396. {
  1397. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1398. image = [[SSDKImage alloc] initWithImage:localImg
  1399. format:SSDKImageFormatJpeg
  1400. settings:nil];
  1401. }
  1402. if (image)
  1403. {
  1404. [images addObject:path];
  1405. }
  1406. else
  1407. {
  1408. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1409. }
  1410. }
  1411. }
  1412. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1413. {
  1414. NSData *attachementsData = [NSData dataWithContentsOfFile:[value objectForKey:@"attachmentPath"]];
  1415. [attachments addObject:attachementsData];
  1416. }
  1417. else if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSArray class]])
  1418. {
  1419. NSArray *paths = [value objectForKey:@"attachmentPath"];
  1420. for (NSString *path in paths)
  1421. {
  1422. NSData *attachementsData = [NSData dataWithContentsOfFile:path];
  1423. [attachments addObject:attachementsData];
  1424. }
  1425. }
  1426. if ([[value objectForKey:@"recipients"] isKindOfClass:[NSString class]])
  1427. {
  1428. [recipients addObject:[value objectForKey:@"recipients"]];
  1429. }
  1430. else if ([[value objectForKey:@"recipients"] isKindOfClass:[NSArray class]])
  1431. {
  1432. NSArray *recipientsArray = [value objectForKey:@"recipients"];
  1433. for (NSString *recipient in recipientsArray)
  1434. {
  1435. [recipients addObject:recipient];
  1436. }
  1437. }
  1438. if ([[value objectForKey:@"ccRecipients"] isKindOfClass:[NSString class]])
  1439. {
  1440. [ccRecipients addObject:[value objectForKey:@"ccRecipients"]];
  1441. }
  1442. else if ([[value objectForKey:@"ccRecipients"] isKindOfClass:[NSArray class]])
  1443. {
  1444. NSArray *recipientsArray = [value objectForKey:@"ccRecipients"];
  1445. for (NSString *recipient in recipientsArray)
  1446. {
  1447. [ccRecipients addObject:recipient];
  1448. }
  1449. }
  1450. if ([[value objectForKey:@"bccRecipients"] isKindOfClass:[NSString class]])
  1451. {
  1452. [bccRecipients addObject:[value objectForKey:@"bccRecipients"]];
  1453. }
  1454. else if ([[value objectForKey:@"bccRecipients"] isKindOfClass:[NSArray class]])
  1455. {
  1456. NSArray *recipientsArray = [value objectForKey:@"bccRecipients"];
  1457. for (NSString *recipient in recipientsArray)
  1458. {
  1459. [bccRecipients addObject:recipient];
  1460. }
  1461. }
  1462. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1463. {
  1464. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1465. }
  1466. [params SSDKSetupMailParamsByText:text
  1467. title:title
  1468. images:images
  1469. attachments:attachments
  1470. recipients:recipients
  1471. ccRecipients:ccRecipients
  1472. bccRecipients:bccRecipients
  1473. type:type];
  1474. }
  1475. //SMS
  1476. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSMS]]];
  1477. if ([value isKindOfClass:[NSDictionary class]])
  1478. {
  1479. NSString *text = nil;
  1480. NSString *title = nil;
  1481. NSMutableArray *images = [NSMutableArray array];
  1482. NSMutableArray *attachments = [NSMutableArray array];
  1483. NSMutableArray *recipients = [NSMutableArray array];
  1484. SSDKContentType type = SSDKContentTypeText;
  1485. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1486. {
  1487. text = [value objectForKey:@"text"];
  1488. }
  1489. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1490. {
  1491. title = [value objectForKey:@"title"];
  1492. }
  1493. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1494. {
  1495. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1496. SSDKImage *image = nil;
  1497. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1498. options:MOBFRegexOptionsNoOptions
  1499. inRange:NSMakeRange(0, imgPath.length)
  1500. withString:imgPath])
  1501. {
  1502. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1503. }
  1504. else
  1505. {
  1506. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1507. image = [[SSDKImage alloc] initWithImage:localImg
  1508. format:SSDKImageFormatJpeg
  1509. settings:nil];
  1510. }
  1511. if (image)
  1512. {
  1513. [images addObject:imgPath];
  1514. }
  1515. else
  1516. {
  1517. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1518. }
  1519. }
  1520. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1521. {
  1522. NSArray *paths = [value objectForKey:@"imageUrl"];
  1523. for (NSString *path in paths)
  1524. {
  1525. SSDKImage *image = nil;
  1526. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1527. options:MOBFRegexOptionsNoOptions
  1528. inRange:NSMakeRange(0, path.length)
  1529. withString:path])
  1530. {
  1531. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1532. }
  1533. else
  1534. {
  1535. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1536. image = [[SSDKImage alloc] initWithImage:localImg
  1537. format:SSDKImageFormatJpeg
  1538. settings:nil];
  1539. }
  1540. if (image)
  1541. {
  1542. [images addObject:path];
  1543. }
  1544. else
  1545. {
  1546. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1547. }
  1548. }
  1549. }
  1550. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1551. {
  1552. NSData *attachementsData = [NSData dataWithContentsOfFile:[value objectForKey:@"attachmentPath"]];
  1553. [attachments addObject:attachementsData];
  1554. }
  1555. else if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSArray class]])
  1556. {
  1557. NSArray *paths = [value objectForKey:@"attachmentPath"];
  1558. for (NSString *path in paths)
  1559. {
  1560. NSData *attachementsData = [NSData dataWithContentsOfFile:path];
  1561. [attachments addObject:attachementsData];
  1562. }
  1563. }
  1564. if ([[value objectForKey:@"recipients"] isKindOfClass:[NSString class]])
  1565. {
  1566. [recipients addObject:[value objectForKey:@"recipients"]];
  1567. }
  1568. else if ([[value objectForKey:@"recipients"] isKindOfClass:[NSArray class]])
  1569. {
  1570. NSArray *recipientsArray = [value objectForKey:@"recipients"];
  1571. for (NSString *recipient in recipientsArray)
  1572. {
  1573. [recipients addObject:recipient];
  1574. }
  1575. }
  1576. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1577. {
  1578. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1579. }
  1580. [params SSDKSetupSMSParamsByText:text
  1581. title:title
  1582. images:images
  1583. attachments:attachments
  1584. recipients:recipients
  1585. type:type];
  1586. }
  1587. //Print
  1588. //无定制内容方法
  1589. //Copy
  1590. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeCopy]]];
  1591. if ([value isKindOfClass:[NSDictionary class]])
  1592. {
  1593. NSString *text = nil;
  1594. NSMutableArray *images = [NSMutableArray array];
  1595. NSString *url = nil;
  1596. SSDKContentType type = SSDKContentTypeImage;
  1597. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1598. {
  1599. text = [value objectForKey:@"text"];
  1600. }
  1601. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1602. {
  1603. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1604. SSDKImage *image = nil;
  1605. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1606. options:MOBFRegexOptionsNoOptions
  1607. inRange:NSMakeRange(0, imgPath.length)
  1608. withString:imgPath])
  1609. {
  1610. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1611. }
  1612. else
  1613. {
  1614. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1615. image = [[SSDKImage alloc] initWithImage:localImg
  1616. format:SSDKImageFormatJpeg
  1617. settings:nil];
  1618. }
  1619. if (image)
  1620. {
  1621. [images addObject:imgPath];
  1622. }
  1623. else
  1624. {
  1625. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1626. }
  1627. }
  1628. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1629. {
  1630. NSArray *paths = [value objectForKey:@"imageUrl"];
  1631. for (NSString *path in paths)
  1632. {
  1633. SSDKImage *image = nil;
  1634. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1635. options:MOBFRegexOptionsNoOptions
  1636. inRange:NSMakeRange(0, path.length)
  1637. withString:path])
  1638. {
  1639. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1640. }
  1641. else
  1642. {
  1643. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1644. image = [[SSDKImage alloc] initWithImage:localImg
  1645. format:SSDKImageFormatJpeg
  1646. settings:nil];
  1647. }
  1648. if (image)
  1649. {
  1650. [images addObject:path];
  1651. }
  1652. else
  1653. {
  1654. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1655. }
  1656. }
  1657. }
  1658. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1659. {
  1660. url = [value objectForKey:@"url"];
  1661. }
  1662. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1663. {
  1664. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1665. }
  1666. [params SSDKSetupCopyParamsByText:text
  1667. images:images
  1668. url:[NSURL URLWithString:url]
  1669. type:type];
  1670. }
  1671. //Instapaper
  1672. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeInstapaper]]];
  1673. if ([value isKindOfClass:[NSDictionary class]])
  1674. {
  1675. NSString *url = nil;
  1676. NSString *title = nil;
  1677. NSString *desc = nil;
  1678. NSString *content = nil;
  1679. BOOL isPrivateFromSource;
  1680. NSInteger folderId;
  1681. BOOL resolveFinalUrl;
  1682. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1683. {
  1684. url = [value objectForKey:@"url"];
  1685. }
  1686. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1687. {
  1688. title = [value objectForKey:@"title"];
  1689. }
  1690. if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
  1691. {
  1692. desc = [value objectForKey:@"desc"];
  1693. }
  1694. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1695. {
  1696. content = [value objectForKey:@"text"];
  1697. }
  1698. if ([[value objectForKey:@"isPrivateFromSource"] boolValue])
  1699. {
  1700. isPrivateFromSource = YES;
  1701. }
  1702. if (![[value objectForKey:@"resolveFinalUrl"] boolValue])
  1703. {
  1704. resolveFinalUrl = YES;
  1705. }
  1706. folderId = [[value objectForKey:@"folderId"] integerValue];
  1707. [params SSDKSetupInstapaperParamsByUrl:[NSURL URLWithString:url]
  1708. title:title
  1709. desc:desc
  1710. content:content
  1711. isPrivateFromSource:isPrivateFromSource
  1712. folderId:folderId
  1713. resolveFinalUrl:resolveFinalUrl];
  1714. }
  1715. //Pocket
  1716. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypePocket]]];
  1717. if ([value isKindOfClass:[NSDictionary class]])
  1718. {
  1719. NSString *url = nil;
  1720. NSString *title = nil;
  1721. NSString *tags = nil;
  1722. NSString *tweetId = nil;
  1723. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1724. {
  1725. url = [value objectForKey:@"url"];
  1726. }
  1727. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1728. {
  1729. title = [value objectForKey:@"title"];
  1730. }
  1731. id tagValue = [value objectForKey:@"tags"];
  1732. if ([tagValue isKindOfClass:[NSString class]])
  1733. {
  1734. tags = tagValue;
  1735. }
  1736. else if ([tagValue isKindOfClass:[NSArray class]])
  1737. {
  1738. NSArray *tagsArr = tagValue;
  1739. tags = [tagsArr componentsJoinedByString:@","];
  1740. }
  1741. if ([[value objectForKey:@"tweetID"] isKindOfClass:[NSString class]])
  1742. {
  1743. tweetId = [value objectForKey:@"tweetID"];
  1744. }
  1745. [params SSDKSetupPocketParamsByUrl:[NSURL URLWithString:url]
  1746. title:title
  1747. tags:tags
  1748. tweetId:tweetId];
  1749. }
  1750. //YouDaoNote
  1751. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYouDaoNote]]];
  1752. if ([value isKindOfClass:[NSDictionary class]])
  1753. {
  1754. NSString *text = nil;
  1755. NSString *title = nil;
  1756. NSMutableArray *images = [NSMutableArray array];
  1757. NSString *source = nil;
  1758. NSString *author = nil;
  1759. NSString *notebook = nil;
  1760. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1761. {
  1762. text = [value objectForKey:@"text"];
  1763. }
  1764. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1765. {
  1766. title = [value objectForKey:@"title"];
  1767. }
  1768. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1769. {
  1770. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1771. SSDKImage *image = nil;
  1772. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1773. options:MOBFRegexOptionsNoOptions
  1774. inRange:NSMakeRange(0, imgPath.length)
  1775. withString:imgPath])
  1776. {
  1777. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1778. }
  1779. else
  1780. {
  1781. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1782. image = [[SSDKImage alloc] initWithImage:localImg
  1783. format:SSDKImageFormatJpeg
  1784. settings:nil];
  1785. }
  1786. if (image)
  1787. {
  1788. [images addObject:imgPath];
  1789. }
  1790. else
  1791. {
  1792. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1793. }
  1794. }
  1795. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1796. {
  1797. NSArray *paths = [value objectForKey:@"imageUrl"];
  1798. for (NSString *path in paths)
  1799. {
  1800. SSDKImage *image = nil;
  1801. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1802. options:MOBFRegexOptionsNoOptions
  1803. inRange:NSMakeRange(0, path.length)
  1804. withString:path])
  1805. {
  1806. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1807. }
  1808. else
  1809. {
  1810. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1811. image = [[SSDKImage alloc] initWithImage:localImg
  1812. format:SSDKImageFormatJpeg
  1813. settings:nil];
  1814. }
  1815. if (image)
  1816. {
  1817. [images addObject:path];
  1818. }
  1819. else
  1820. {
  1821. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1822. }
  1823. }
  1824. }
  1825. if ([[value objectForKey:@"source"] isKindOfClass:[NSString class]])
  1826. {
  1827. source = [value objectForKey:@"source"];
  1828. }
  1829. if ([[value objectForKey:@"author"] isKindOfClass:[NSString class]])
  1830. {
  1831. author = [value objectForKey:@"author"];
  1832. }
  1833. if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
  1834. {
  1835. notebook = [value objectForKey:@"notebook"];
  1836. }
  1837. [params SSDKSetupYouDaoNoteParamsByText:text
  1838. images:images
  1839. title:title
  1840. source:source
  1841. author:author
  1842. notebook:notebook];
  1843. }
  1844. //Pinterest
  1845. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypePinterest]]];
  1846. if ([value isKindOfClass:[NSDictionary class]])
  1847. {
  1848. NSString *image = nil;
  1849. NSString *desc = nil;
  1850. NSString *url = nil;
  1851. NSString *board = nil;
  1852. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1853. {
  1854. image = [value objectForKey:@"imageUrl"];
  1855. }
  1856. if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
  1857. {
  1858. desc = [value objectForKey:@"desc"];
  1859. }
  1860. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1861. {
  1862. url = [value objectForKey:@"url"];
  1863. }
  1864. if ([[value objectForKey:@"board"] isKindOfClass:[NSString class]])
  1865. {
  1866. board = [value objectForKey:@"board"];
  1867. }
  1868. [params SSDKSetupPinterestParamsByImage:image
  1869. desc:desc
  1870. url:[NSURL URLWithString:url]
  1871. boardName:board];
  1872. }
  1873. //Flickr
  1874. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFlickr]]];
  1875. if ([value isKindOfClass:[NSDictionary class]])
  1876. {
  1877. NSString *text = nil;
  1878. NSString *image = nil;
  1879. NSString *title = nil;
  1880. NSMutableArray *tags = [NSMutableArray array];
  1881. BOOL isPublic;
  1882. BOOL isFriend;
  1883. BOOL isFamiliy;
  1884. NSInteger safetyLevel;
  1885. NSInteger contentType;
  1886. NSInteger hidden;
  1887. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1888. {
  1889. text = [value objectForKey:@"text"];
  1890. }
  1891. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1892. {
  1893. image = [value objectForKey:@"imageUrl"];
  1894. }
  1895. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1896. {
  1897. title = [value objectForKey:@"title"];
  1898. }
  1899. id tagValue = [value objectForKey:@"tags"];
  1900. if ([tagValue isKindOfClass:[NSString class]])
  1901. {
  1902. [tags addObject:tagValue];
  1903. }
  1904. else if ([tagValue isKindOfClass:[NSArray class]])
  1905. {
  1906. tags = [tagValue mutableCopy];
  1907. }
  1908. if ([[value objectForKey:@"isPublic"] boolValue])
  1909. {
  1910. isPublic = YES;
  1911. }
  1912. if ([[value objectForKey:@"isFriend"] boolValue])
  1913. {
  1914. isFriend = YES;
  1915. }
  1916. if ([[value objectForKey:@"isFamiliy"] boolValue])
  1917. {
  1918. isFamiliy = YES;
  1919. }
  1920. if ([[value objectForKey:@"safetyLevel"] integerValue])
  1921. {
  1922. safetyLevel = [[value objectForKey:@"safetyLevel"] integerValue];
  1923. }
  1924. if ([[value objectForKey:@"contentType"] integerValue])
  1925. {
  1926. contentType = [[value objectForKey:@"contentType"] integerValue];
  1927. }
  1928. if ([[value objectForKey:@"hidden"] integerValue])
  1929. {
  1930. hidden = [[value objectForKey:@"hidden"] integerValue];
  1931. }
  1932. [params SSDKSetupFlickrParamsByText:text
  1933. image:image
  1934. title:title
  1935. tags:tags
  1936. isPublic:isPublic
  1937. isFriend:isFriend
  1938. isFamily:isFamiliy
  1939. safetyLevel:safetyLevel
  1940. contentType:contentType
  1941. hidden:hidden];
  1942. }
  1943. //Dropbox
  1944. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDropbox]]];
  1945. if ([value isKindOfClass:[NSDictionary class]])
  1946. {
  1947. NSString *attachmentPath = nil;
  1948. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1949. {
  1950. attachmentPath = [value objectForKey:@"attachmentPath"];
  1951. }
  1952. [params SSDKSetupDropboxParamsByAttachment:attachmentPath];
  1953. }
  1954. //VKontakte
  1955. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeVKontakte]]];
  1956. if ([value isKindOfClass:[NSDictionary class]])
  1957. {
  1958. NSString *text = nil;
  1959. NSString *url = nil;
  1960. NSMutableArray *images = [NSMutableArray array];
  1961. NSString *groupId = nil;
  1962. BOOL friendsOnly;
  1963. double lat;
  1964. double lng;
  1965. SSDKContentType type = SSDKContentTypeText;
  1966. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1967. {
  1968. text = [value objectForKey:@"text"];
  1969. }
  1970. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1971. {
  1972. url = [value objectForKey:@"url"];
  1973. }
  1974. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1975. {
  1976. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1977. SSDKImage *image = nil;
  1978. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1979. options:MOBFRegexOptionsNoOptions
  1980. inRange:NSMakeRange(0, imgPath.length)
  1981. withString:imgPath])
  1982. {
  1983. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1984. }
  1985. else
  1986. {
  1987. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1988. image = [[SSDKImage alloc] initWithImage:localImg
  1989. format:SSDKImageFormatJpeg
  1990. settings:nil];
  1991. }
  1992. if (image)
  1993. {
  1994. [images addObject:imgPath];
  1995. }
  1996. else
  1997. {
  1998. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1999. }
  2000. }
  2001. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  2002. {
  2003. NSArray *paths = [value objectForKey:@"imageUrl"];
  2004. for (NSString *path in paths)
  2005. {
  2006. SSDKImage *image = nil;
  2007. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2008. options:MOBFRegexOptionsNoOptions
  2009. inRange:NSMakeRange(0, path.length)
  2010. withString:path])
  2011. {
  2012. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  2013. }
  2014. else
  2015. {
  2016. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  2017. image = [[SSDKImage alloc] initWithImage:localImg
  2018. format:SSDKImageFormatJpeg
  2019. settings:nil];
  2020. }
  2021. if (image)
  2022. {
  2023. [images addObject:path];
  2024. }
  2025. else
  2026. {
  2027. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2028. }
  2029. }
  2030. }
  2031. if ([[value objectForKey:@"groupID"] isKindOfClass:[NSString class]])
  2032. {
  2033. groupId = [value objectForKey:@"groupID"];
  2034. }
  2035. if ([[value objectForKey:@"friendsOnly"] boolValue])
  2036. {
  2037. friendsOnly = YES;
  2038. }
  2039. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSString class]])
  2040. {
  2041. lat = [[value objectForKey:@"latitude"] doubleValue];
  2042. }
  2043. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSString class]])
  2044. {
  2045. lng = [[value objectForKey:@"longitude"] doubleValue];
  2046. }
  2047. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2048. {
  2049. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2050. }
  2051. [params SSDKSetupVKontakteParamsByText:text
  2052. images:images
  2053. url:[NSURL URLWithString:url]
  2054. groupId:groupId
  2055. friendsOnly:friendsOnly
  2056. latitude:lat
  2057. longitude:lng
  2058. type:type];
  2059. }
  2060. //Yixin系列
  2061. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinSession]]];
  2062. if ([value isKindOfClass:[NSDictionary class]])
  2063. {
  2064. __setYixinParams(value, params, SSDKPlatformSubTypeYiXinSession);
  2065. }
  2066. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinTimeline]]];
  2067. if ([value isKindOfClass:[NSDictionary class]])
  2068. {
  2069. __setYixinParams(value, params, SSDKPlatformSubTypeYiXinTimeline);
  2070. }
  2071. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinFav]]];
  2072. if ([value isKindOfClass:[NSDictionary class]])
  2073. {
  2074. __setYixinParams(value, params, SSDKPlatformSubTypeYiXinFav);
  2075. }
  2076. //MingDao
  2077. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeMingDao]]];
  2078. if ([value isKindOfClass:[NSDictionary class]])
  2079. {
  2080. NSString *text = nil;
  2081. NSString *image = nil;
  2082. NSString *url = nil;
  2083. NSString *title = nil;
  2084. SSDKContentType type = SSDKContentTypeText;
  2085. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2086. {
  2087. text = [value objectForKey:@"text"];
  2088. }
  2089. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2090. {
  2091. image = [value objectForKey:@"imageUrl"];
  2092. }
  2093. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2094. {
  2095. url = [value objectForKey:@"url"];
  2096. }
  2097. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2098. {
  2099. title = [value objectForKey:@"title"];
  2100. }
  2101. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2102. {
  2103. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2104. }
  2105. [params SSDKSetupMingDaoParamsByText:text
  2106. image:image
  2107. url:[NSURL URLWithString:url]
  2108. title:title
  2109. type:type];
  2110. }
  2111. //Line
  2112. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeLine]]];
  2113. if ([value isKindOfClass:[NSDictionary class]])
  2114. {
  2115. NSString *text = nil;
  2116. NSString *image = nil;
  2117. SSDKContentType type = SSDKContentTypeText;
  2118. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2119. {
  2120. text = [value objectForKey:@"text"];
  2121. }
  2122. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2123. {
  2124. image = [value objectForKey:@"imageUrl"];
  2125. }
  2126. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2127. {
  2128. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2129. }
  2130. [params SSDKSetupLineParamsByText:text
  2131. image:image
  2132. type:type];
  2133. }
  2134. //whatsApp
  2135. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeWhatsApp]]];
  2136. if ([value isKindOfClass:[NSDictionary class]])
  2137. {
  2138. NSString *text = nil;
  2139. NSString *image = nil;
  2140. NSString *audioPath = nil;
  2141. NSString *videoPath = nil;
  2142. CGFloat menuX;
  2143. CGFloat menuY;
  2144. SSDKContentType type = SSDKContentTypeText;
  2145. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2146. {
  2147. text = [value objectForKey:@"text"];
  2148. }
  2149. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2150. {
  2151. image = [value objectForKey:@"imageUrl"];
  2152. }
  2153. if ([[value objectForKey:@"audioPath"] isKindOfClass:[NSString class]])
  2154. {
  2155. audioPath = [value objectForKey:@"audioPath"];
  2156. }
  2157. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2158. {
  2159. videoPath = [value objectForKey:@"videoPath"];
  2160. }
  2161. if ([[value objectForKey:@"menuX"] isKindOfClass:[NSString class]])
  2162. {
  2163. menuX = [[value objectForKey:@"menuX"] floatValue];
  2164. }
  2165. if ([[value objectForKey:@"menuY"] isKindOfClass:[NSString class]])
  2166. {
  2167. menuX = [[value objectForKey:@"menuY"] floatValue];
  2168. }
  2169. CGPoint point = CGPointMake(menuX, menuY);
  2170. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2171. {
  2172. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2173. }
  2174. [params SSDKSetupWhatsAppParamsByText:text
  2175. image:image
  2176. audio:audioPath
  2177. video:videoPath
  2178. menuDisplayPoint:point
  2179. type:type];
  2180. }
  2181. //Kakao系列
  2182. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeKakaoTalk]]];
  2183. if ([value isKindOfClass:[NSDictionary class]])
  2184. {
  2185. __setKakaoParams(value,params,SSDKPlatformSubTypeKakaoTalk);
  2186. }
  2187. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeKakaoStory]]];
  2188. if ([value isKindOfClass:[NSDictionary class]])
  2189. {
  2190. __setKakaoParams(value,params,SSDKPlatformSubTypeKakaoStory);
  2191. }
  2192. //支付宝好友
  2193. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliPaySocial]]];
  2194. if ([value isKindOfClass:[NSDictionary class]])
  2195. {
  2196. NSString *text = nil;
  2197. NSString *image = nil;
  2198. NSString *title = nil;
  2199. NSString *url = nil;
  2200. SSDKContentType type = SSDKContentTypeText;
  2201. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2202. {
  2203. text = [value objectForKey:@"text"];
  2204. }
  2205. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2206. {
  2207. image = [value objectForKey:@"imageUrl"];
  2208. }
  2209. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2210. {
  2211. title = [value objectForKey:@"title"];
  2212. }
  2213. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2214. {
  2215. url = [value objectForKey:@"url"];
  2216. }
  2217. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2218. {
  2219. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2220. }
  2221. [params SSDKSetupAliPaySocialParamsByText:text
  2222. image:image
  2223. title:title
  2224. url:[NSURL URLWithString:url]
  2225. type:type];
  2226. }
  2227. //钉钉
  2228. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDingTalk]]];
  2229. if ([value isKindOfClass:[NSDictionary class]])
  2230. {
  2231. NSString *text = nil;
  2232. NSString *image = nil;
  2233. NSString *title = nil;
  2234. NSString *url = nil;
  2235. SSDKContentType type = SSDKContentTypeText;
  2236. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2237. {
  2238. text = [value objectForKey:@"text"];
  2239. }
  2240. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2241. {
  2242. image = [value objectForKey:@"imageUrl"];
  2243. }
  2244. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2245. {
  2246. title = [value objectForKey:@"title"];
  2247. }
  2248. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2249. {
  2250. url = [value objectForKey:@"url"];
  2251. }
  2252. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2253. {
  2254. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2255. }
  2256. [params SSDKSetupDingTalkParamsByText:text
  2257. image:image
  2258. title:title
  2259. url:[NSURL URLWithString:url]
  2260. type:type];
  2261. }
  2262. //Evernote
  2263. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeEvernote]]];
  2264. if ([value isKindOfClass:[NSDictionary class]])
  2265. {
  2266. NSString *text = nil;
  2267. NSString *title = nil;
  2268. NSMutableArray *images = [NSMutableArray array];
  2269. NSMutableArray *tags = [NSMutableArray array];
  2270. NSString *notebook = nil;
  2271. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2272. {
  2273. text = [value objectForKey:@"text"];
  2274. }
  2275. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2276. {
  2277. title = [value objectForKey:@"title"];
  2278. }
  2279. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2280. {
  2281. NSString *imgPath = [value objectForKey:@"imageUrl"];
  2282. SSDKImage *image = nil;
  2283. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2284. options:MOBFRegexOptionsNoOptions
  2285. inRange:NSMakeRange(0, imgPath.length)
  2286. withString:imgPath])
  2287. {
  2288. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  2289. }
  2290. else
  2291. {
  2292. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  2293. image = [[SSDKImage alloc] initWithImage:localImg
  2294. format:SSDKImageFormatJpeg
  2295. settings:nil];
  2296. }
  2297. if (image)
  2298. {
  2299. [images addObject:imgPath];
  2300. }
  2301. else
  2302. {
  2303. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2304. }
  2305. }
  2306. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  2307. {
  2308. NSArray *paths = [value objectForKey:@"imageUrl"];
  2309. for (NSString *path in paths)
  2310. {
  2311. SSDKImage *image = nil;
  2312. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2313. options:MOBFRegexOptionsNoOptions
  2314. inRange:NSMakeRange(0, path.length)
  2315. withString:path])
  2316. {
  2317. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  2318. }
  2319. else
  2320. {
  2321. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  2322. image = [[SSDKImage alloc] initWithImage:localImg
  2323. format:SSDKImageFormatJpeg
  2324. settings:nil];
  2325. }
  2326. if (image)
  2327. {
  2328. [images addObject:path];
  2329. }
  2330. else
  2331. {
  2332. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2333. }
  2334. }
  2335. }
  2336. if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
  2337. {
  2338. notebook = [value objectForKey:@"notebook"];
  2339. }
  2340. id tagValue = [value objectForKey:@"tags"];
  2341. if ([tagValue isKindOfClass:[NSString class]])
  2342. {
  2343. [tags addObject:tagValue];
  2344. }
  2345. else if ([tagValue isKindOfClass:[NSArray class]])
  2346. {
  2347. tags = [tagValue mutableCopy];
  2348. }
  2349. [params SSDKSetupEvernoteParamsByText:text
  2350. images:images
  2351. title:title
  2352. notebook:notebook
  2353. tags:tags
  2354. platformType:SSDKPlatformTypeEvernote];
  2355. }
  2356. }
  2357. }
  2358. return params;
  2359. }
  2360. void __iosShareSDKRegisterAppAndSetPltformsConfig (void *appKey, void*configInfo)
  2361. {
  2362. NSMutableArray *activePlatforms = [NSMutableArray array];
  2363. NSMutableDictionary *platformsDict = [NSMutableDictionary dictionary];
  2364. NSString *appKeyStr = [NSString stringWithCString:appKey encoding:NSUTF8StringEncoding];
  2365. if (configInfo)
  2366. {
  2367. platformsDict = __parseWithHashtable(configInfo);
  2368. }
  2369. for (id obj in [platformsDict allKeys])
  2370. {
  2371. NSInteger platformInterger = [obj integerValue];
  2372. NSDictionary *dict = [platformsDict objectForKey:[NSString stringWithFormat:@"%@",obj]];
  2373. if ([[dict objectForKey:@"Enable"] isEqualToString:@"true"])
  2374. {
  2375. [activePlatforms addObject:[NSNumber numberWithInteger:platformInterger]];
  2376. }
  2377. }
  2378. [ShareSDK registerApp:appKeyStr
  2379. activePlatforms:activePlatforms
  2380. onImport:^(SSDKPlatformType platformType) {
  2381. switch (platformType)
  2382. {
  2383. case SSDKPlatformTypeSinaWeibo:
  2384. #ifdef __SHARESDK_SINA_WEIBO__
  2385. [ShareSDKConnector connectWeibo:[WeiboSDK class]];
  2386. #endif
  2387. break;
  2388. case SSDKPlatformTypeQQ:
  2389. #ifdef __SHARESDK_QQ__
  2390. [ShareSDKConnector connectQQ:[QQApiInterface class]
  2391. tencentOAuthClass:[TencentOAuth class]];
  2392. #endif
  2393. break;
  2394. case SSDKPlatformTypeWechat:
  2395. #ifdef __SHARESDK_WECHAT__
  2396. [ShareSDKConnector connectWeChat:[WXApi class]];
  2397. #endif
  2398. break;
  2399. case SSDKPlatformTypeRenren:
  2400. #ifdef __SHARESDK_RENREN__
  2401. [ShareSDKConnector connectRenren:[RennClient class]];
  2402. #endif
  2403. break;
  2404. case SSDKPlatformTypeKakao:
  2405. #ifdef __SHARESDK_KAKAO__
  2406. [ShareSDKConnector connectKaKao:[KOSession class]];
  2407. #endif
  2408. break;
  2409. case SSDKPlatformTypeYiXin:
  2410. #ifdef __SHARESDK_YIXIN__
  2411. [ShareSDKConnector connectYiXin:[YXApi class]];
  2412. #endif
  2413. break;
  2414. case SSDKPlatformTypeFacebookMessenger:
  2415. #ifdef __SHARESDK_FACEBOOK_MSG__
  2416. [ShareSDKConnector connectFacebookMessenger:[FBSDKMessengerSharer class]];
  2417. #endif
  2418. break;
  2419. case SSDKPlatformTypeAliPaySocial:
  2420. #ifdef __SHARESDK_ALIPAYSOCIAL__
  2421. [ShareSDKConnector connectAliPaySocial:[APOpenAPI class]];
  2422. #endif
  2423. break;
  2424. case SSDKPlatformTypeDingTalk:
  2425. #ifdef __SHARESDK_DINGTALK__
  2426. [ShareSDKConnector connectDingTalk:[DTOpenAPI class]];
  2427. #endif
  2428. break;
  2429. default:
  2430. break;
  2431. }
  2432. } onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo) {
  2433. switch (platformType)
  2434. {
  2435. case SSDKPlatformTypeWechat:
  2436. {
  2437. NSArray *weChatTypes = @[@(SSDKPlatformTypeWechat),
  2438. @(SSDKPlatformSubTypeWechatSession),
  2439. @(SSDKPlatformSubTypeWechatTimeline),
  2440. @(SSDKPlatformSubTypeWechatFav)];
  2441. [weChatTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  2442. NSDictionary *wechatDict = [platformsDict objectForKey:[NSString stringWithFormat:@"%@",obj]];
  2443. if (wechatDict && [[wechatDict allKeys] count] > 0)
  2444. {
  2445. [appInfo SSDKSetupWeChatByAppId:[wechatDict objectForKey:@"app_id"]
  2446. appSecret:[wechatDict objectForKey:@"app_secret"]];
  2447. *stop = YES;
  2448. }
  2449. }];
  2450. break;
  2451. }
  2452. case SSDKPlatformTypeQQ:
  2453. {
  2454. NSArray *QQTypes = @[@(SSDKPlatformTypeQQ),
  2455. @(SSDKPlatformSubTypeQQFriend),
  2456. @(SSDKPlatformSubTypeQZone)];
  2457. [QQTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  2458. NSDictionary *QQDict = [platformsDict objectForKey:[NSString stringWithFormat:@"%@",obj]];
  2459. if (QQDict && [[QQDict allKeys] count] > 0)
  2460. {
  2461. [appInfo SSDKSetupQQByAppId:[QQDict objectForKey:@"app_id"]
  2462. appKey:[QQDict objectForKey:@"app_key"]
  2463. authType:[QQDict objectForKey:@"auth_type"]];
  2464. *stop = YES;
  2465. }
  2466. }];
  2467. break;
  2468. }
  2469. case SSDKPlatformTypeKakao:
  2470. {
  2471. NSArray *KakaoTypes = @[@(SSDKPlatformTypeKakao),
  2472. @(SSDKPlatformSubTypeKakaoTalk),
  2473. @(SSDKPlatformSubTypeKakaoStory)];
  2474. [KakaoTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  2475. NSDictionary *KakaoDict = [platformsDict objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)obj]];
  2476. if (KakaoDict && [[KakaoDict allKeys] count] > 0)
  2477. {
  2478. [appInfo SSDKSetupKaKaoByAppKey:[KakaoDict objectForKey:@"app_key"]
  2479. restApiKey:[KakaoDict objectForKey:@"rest_api_key"]
  2480. redirectUri:[KakaoDict objectForKey:@"redirect_uri"]
  2481. authType:[KakaoDict objectForKey:@"auth_type"]];
  2482. *stop = YES;
  2483. }
  2484. }];
  2485. break;
  2486. }
  2487. case SSDKPlatformTypeYiXin:
  2488. {
  2489. NSArray *yiXinTypes = @[@(SSDKPlatformTypeYiXin),
  2490. @(SSDKPlatformSubTypeYiXinSession),
  2491. @(SSDKPlatformSubTypeYiXinTimeline),
  2492. @(SSDKPlatformSubTypeYiXinFav)];
  2493. [yiXinTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  2494. NSDictionary *yixinDict = [platformsDict objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)obj]];
  2495. if (yixinDict && [[yixinDict allKeys] count] > 0)
  2496. {
  2497. [appInfo SSDKSetupYiXinByAppId:[yixinDict objectForKey:@"app_id"]
  2498. appSecret:[yixinDict objectForKey:@"app_secret"]
  2499. redirectUri:[yixinDict objectForKey:@"redirect_uri"]
  2500. authType:[yixinDict objectForKey:@"auth_type"]];
  2501. *stop = YES;
  2502. }
  2503. }];
  2504. break;
  2505. }
  2506. case SSDKPlatformTypeAliPaySocial:
  2507. {
  2508. NSDictionary *platformDict = nil;
  2509. NSDictionary *dictFromAliPaySocial = [platformsDict objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliPaySocial]];
  2510. NSDictionary *dictFromAliPaySocialTimeline = [platformsDict objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliPaySocialTimeline]];
  2511. if (dictFromAliPaySocial)
  2512. {
  2513. platformDict = dictFromAliPaySocial;
  2514. }
  2515. else
  2516. {
  2517. platformDict = dictFromAliPaySocialTimeline;
  2518. }
  2519. [appInfo addEntriesFromDictionary:platformDict];
  2520. break;
  2521. }
  2522. default:
  2523. {
  2524. NSDictionary *platformDict = [platformsDict objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)platformType]];
  2525. [appInfo addEntriesFromDictionary:platformDict];
  2526. break;
  2527. }
  2528. }
  2529. }];
  2530. }
  2531. void __iosShareSDKAuthorize (int reqID, int platType, void *observer)
  2532. {
  2533. NSString *observerStr = nil;
  2534. if (observer)
  2535. {
  2536. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2537. }
  2538. [ShareSDK authorize:platType
  2539. settings:nil
  2540. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
  2541. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2542. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"action"];
  2543. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2544. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  2545. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2546. if (state == SSDKResponseStateFail && error)
  2547. {
  2548. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2549. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  2550. if ([[error userInfo] objectForKey:@"error_message"])
  2551. {
  2552. if ([[error userInfo] objectForKey:@"error_message"])
  2553. {
  2554. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  2555. }
  2556. }
  2557. else if ([[error userInfo] objectForKey:@"user_data"])
  2558. {
  2559. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2560. if ([error_data objectForKey:@"error"])
  2561. {
  2562. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  2563. }
  2564. if ([error_data objectForKey:@"error_code"])
  2565. {
  2566. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  2567. }
  2568. }
  2569. [resultDict setObject:errorDict forKey:@"res"];
  2570. }
  2571. if (state == SSDKResponseStateSuccess)
  2572. {
  2573. if ([user rawData])
  2574. {
  2575. [resultDict setObject:[[user credential] rawData] forKey:@"res"];
  2576. }
  2577. }
  2578. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2579. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2580. }];
  2581. }
  2582. void __iosShareSDKCancelAuthorize (int platType)
  2583. {
  2584. [ShareSDK cancelAuthorize:platType];
  2585. }
  2586. bool __iosShareSDKHasAuthorized (int platType)
  2587. {
  2588. return [ShareSDK hasAuthorized:platType];
  2589. }
  2590. bool __iosShareSDKIsClientInstalled(int platType)
  2591. {
  2592. return [ShareSDK isClientInstalled:platType];
  2593. }
  2594. void __iosShareSDKGetUserInfo (int reqID, int platType, void *observer)
  2595. {
  2596. NSString *observerStr = nil;
  2597. if (observer)
  2598. {
  2599. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2600. }
  2601. [ShareSDK getUserInfo:platType
  2602. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
  2603. {
  2604. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2605. [resultDict setObject:[NSNumber numberWithInteger:8] forKey:@"action"];
  2606. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2607. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  2608. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2609. if (state == SSDKResponseStateFail && error)
  2610. {
  2611. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2612. [errorDict setObject:[NSNumber numberWithInteger:[error code]]
  2613. forKey:@"error_code"];
  2614. if ([[error userInfo] objectForKey:@"error_message"])
  2615. {
  2616. if ([[error userInfo] objectForKey:@"error_message"])
  2617. {
  2618. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  2619. forKey:@"error_msg"];
  2620. }
  2621. }
  2622. else if ([[error userInfo] objectForKey:@"user_data"])
  2623. {
  2624. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2625. if ([error_data objectForKey:@"error"])
  2626. {
  2627. [errorDict setObject:[error_data objectForKey:@"error"]
  2628. forKey:@"error_msg"];
  2629. }
  2630. if ([error_data objectForKey:@"error_code"])
  2631. {
  2632. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  2633. forKey:@"error_code"];
  2634. }
  2635. }
  2636. [resultDict setObject:errorDict forKey:@"res"];
  2637. }
  2638. if (state == SSDKResponseStateSuccess && user)
  2639. {
  2640. [resultDict setObject:[user rawData] forKey:@"res"];
  2641. }
  2642. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2643. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2644. }];
  2645. }
  2646. void __iosShareSDKShare (int reqID, int platType, void *content, void *observer)
  2647. {
  2648. NSString *observerStr = nil;
  2649. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  2650. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2651. if (content)
  2652. {
  2653. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  2654. shareParams = __getShareParamsWithString(contentStr);
  2655. }
  2656. [ShareSDK share:platType
  2657. parameters:shareParams
  2658. onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
  2659. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2660. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  2661. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2662. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  2663. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2664. if (state == SSDKResponseStateFail && error)
  2665. {
  2666. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2667. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  2668. if ([[error userInfo] objectForKey:@"error_message"])
  2669. {
  2670. if ([[error userInfo] objectForKey:@"error_message"])
  2671. {
  2672. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  2673. forKey:@"error_msg"];
  2674. }
  2675. }
  2676. else if ([[error userInfo] objectForKey:@"user_data"])
  2677. {
  2678. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2679. if ([error_data objectForKey:@"error"])
  2680. {
  2681. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  2682. }
  2683. if ([error_data objectForKey:@"error_code"])
  2684. {
  2685. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  2686. forKey:@"error_code"];
  2687. }
  2688. }
  2689. [resultDict setObject:errorDict forKey:@"res"];
  2690. }
  2691. if (state == SSDKResponseStateSuccess)
  2692. {
  2693. if ([contentEntity rawData])
  2694. {
  2695. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  2696. }
  2697. }
  2698. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2699. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2700. }];
  2701. }
  2702. void __iosShareSDKOneKeyShare (int reqID, void *platTypes, void *content, void *observer)
  2703. {
  2704. NSArray *platTypesArr = nil;
  2705. NSString *observerStr = nil;
  2706. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  2707. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2708. if (platTypes)
  2709. {
  2710. NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
  2711. platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
  2712. }
  2713. if (content)
  2714. {
  2715. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  2716. shareParams = __getShareParamsWithString(contentStr);
  2717. }
  2718. [SSEShareHelper oneKeyShare:platTypesArr
  2719. parameters:shareParams
  2720. onStateChanged:^(SSDKPlatformType platformType, SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  2721. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2722. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  2723. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2724. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  2725. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2726. if (state == SSDKResponseStateFail && error)
  2727. {
  2728. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2729. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  2730. if ([[error userInfo] objectForKey:@"error_message"])
  2731. {
  2732. if ([[error userInfo] objectForKey:@"error_message"])
  2733. {
  2734. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  2735. }
  2736. }
  2737. else if ([[error userInfo] objectForKey:@"user_data"])
  2738. {
  2739. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2740. if ([error_data objectForKey:@"error"])
  2741. {
  2742. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  2743. }
  2744. if ([error_data objectForKey:@"error_code"])
  2745. {
  2746. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  2747. forKey:@"error_code"];
  2748. }
  2749. }
  2750. [resultDict setObject:errorDict forKey:@"res"];
  2751. }
  2752. if (state == SSDKResponseStateSuccess)
  2753. {
  2754. if ([contentEntity rawData])
  2755. {
  2756. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  2757. }
  2758. }
  2759. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2760. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2761. }];
  2762. }
  2763. void __iosShareSDKShowShareMenu (int reqID, void *platTypes, void *content, int x, int y, void *observer)
  2764. {
  2765. NSArray *platTypesArr = nil;
  2766. NSMutableArray *actionSheetItems = [NSMutableArray array];
  2767. NSString *observerStr = nil;
  2768. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  2769. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2770. if (platTypes)
  2771. {
  2772. NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
  2773. platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
  2774. }
  2775. else
  2776. {
  2777. platTypesArr = [ShareSDK activePlatforms];
  2778. for (id obj in platTypesArr)
  2779. {
  2780. NSInteger platformInterger = [obj integerValue];
  2781. [actionSheetItems addObject:[NSNumber numberWithInteger:platformInterger]];
  2782. }
  2783. platTypesArr = [actionSheetItems mutableCopy];
  2784. }
  2785. if (content)
  2786. {
  2787. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  2788. shareParams = __getShareParamsWithString(contentStr);
  2789. }
  2790. if ([MOBFDevice isPad])
  2791. {
  2792. if (!_refView)
  2793. {
  2794. _refView = [[UIView alloc] initWithFrame:CGRectMake(x, y, 10, 10)];
  2795. }
  2796. [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_refView];
  2797. }
  2798. [ShareSDK showShareActionSheet:_refView
  2799. items:platTypesArr
  2800. shareParams:shareParams
  2801. onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  2802. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2803. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  2804. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2805. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  2806. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2807. if (state == SSDKResponseStateFail && error)
  2808. {
  2809. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2810. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  2811. if ([[error userInfo] objectForKey:@"error_message"])
  2812. {
  2813. if ([[error userInfo] objectForKey:@"error_message"])
  2814. {
  2815. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  2816. forKey:@"error_msg"];
  2817. }
  2818. }
  2819. else if ([[error userInfo] objectForKey:@"user_data"])
  2820. {
  2821. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2822. if ([error_data objectForKey:@"error"])
  2823. {
  2824. [errorDict setObject:[error_data objectForKey:@"error"]
  2825. forKey:@"error_msg"];
  2826. }
  2827. else if ([error_data objectForKey:@"error_message"])
  2828. {
  2829. [errorDict setObject:[error_data objectForKey:@"error_message"]
  2830. forKey:@"error_msg"];
  2831. }
  2832. if ([error_data objectForKey:@"error_code"])
  2833. {
  2834. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  2835. forKey:@"error_code"];
  2836. }
  2837. }
  2838. [resultDict setObject:errorDict forKey:@"res"];
  2839. }
  2840. if (state == SSDKResponseStateSuccess)
  2841. {
  2842. if ([contentEntity rawData])
  2843. {
  2844. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  2845. }
  2846. }
  2847. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2848. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2849. if (_refView)
  2850. {
  2851. //移除视图
  2852. [_refView removeFromSuperview];
  2853. }
  2854. }];
  2855. }
  2856. void __iosShareSDKShowShareView (int reqID, int platType, void *content, void *observer)
  2857. {
  2858. NSString *observerStr = nil;
  2859. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  2860. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2861. if (content)
  2862. {
  2863. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  2864. shareParams = __getShareParamsWithString(contentStr);
  2865. }
  2866. [ShareSDK showShareEditor:platType
  2867. otherPlatformTypes:nil
  2868. shareParams:shareParams
  2869. onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  2870. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2871. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  2872. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2873. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  2874. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2875. if (state == SSDKResponseStateFail && error)
  2876. {
  2877. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2878. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  2879. if ([[error userInfo] objectForKey:@"error_message"])
  2880. {
  2881. if ([[error userInfo] objectForKey:@"error_message"])
  2882. {
  2883. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  2884. }
  2885. }
  2886. else if ([[error userInfo] objectForKey:@"user_data"])
  2887. {
  2888. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2889. if ([error_data objectForKey:@"error"])
  2890. {
  2891. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  2892. }
  2893. if ([error_data objectForKey:@"error_code"])
  2894. {
  2895. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  2896. }
  2897. }
  2898. [resultDict setObject:errorDict forKey:@"res"];
  2899. }
  2900. if (state == SSDKResponseStateSuccess)
  2901. {
  2902. if ([contentEntity rawData])
  2903. {
  2904. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  2905. }
  2906. }
  2907. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2908. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2909. }];
  2910. }
  2911. void __iosShareSDKGetFriendsList (int reqID, int platType, int count , int page, void *observer)
  2912. {
  2913. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  2914. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2915. NSInteger cursor = page;
  2916. NSInteger size = count;
  2917. if (shareType == SSDKPlatformTypeTwitter)
  2918. {
  2919. cursor = -1;
  2920. }
  2921. [ShareSDK getFriends:platType
  2922. cursor:cursor
  2923. size:size
  2924. onStateChanged:^(SSDKResponseState state, SSDKFriendsPaging *paging, NSError *error)
  2925. {
  2926. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2927. [resultDict setObject:[NSNumber numberWithInteger:2] forKey:@"action"];
  2928. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  2929. [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"platform"];
  2930. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  2931. if (state == SSDKResponseStateFail && error)
  2932. {
  2933. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  2934. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  2935. if ([[error userInfo] objectForKey:@"error_message"])
  2936. {
  2937. if ([[error userInfo] objectForKey:@"error_message"])
  2938. {
  2939. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  2940. }
  2941. }
  2942. else if ([[error userInfo] objectForKey:@"user_data"])
  2943. {
  2944. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  2945. if ([error_data objectForKey:@"error"])
  2946. {
  2947. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  2948. }
  2949. if ([error_data objectForKey:@"error_code"])
  2950. {
  2951. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  2952. }
  2953. }
  2954. [resultDict setObject:errorDict forKey:@"res"];
  2955. }
  2956. if (state == SSDKResponseStateSuccess)
  2957. {
  2958. if (paging)
  2959. {
  2960. NSArray *friends = [NSArray array];
  2961. friends = paging.users;
  2962. NSMutableDictionary *resDict = [NSMutableDictionary dictionary];
  2963. [resDict setObject:friends forKey:@"users"];
  2964. [resDict setObject:[NSNumber numberWithInteger:paging.prevCursor] forKey:@"prev_cursor"];
  2965. [resDict setObject:[NSNumber numberWithInteger:paging.nextCursor] forKey:@"next_cursor"];
  2966. [resDict setObject:[NSNumber numberWithUnsignedInteger:paging.total] forKey:@"total"];
  2967. [resDict setObject:[NSNumber numberWithBool:paging.hasNext] forKey:@"has_next"];
  2968. [resultDict setObject:resDict forKey:@"res"];
  2969. }
  2970. }
  2971. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  2972. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  2973. }];
  2974. }
  2975. char * __StringCopy( const char *string)
  2976. {
  2977. if (string != NULL)
  2978. {
  2979. char *copyStr = (char*)malloc(strlen(string)+1);
  2980. strcpy(copyStr, string);
  2981. return copyStr;
  2982. }
  2983. else
  2984. {
  2985. return NULL;
  2986. }
  2987. }
  2988. extern const char* __iosShareSDKGetCredential (int platType)
  2989. {
  2990. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  2991. SSDKUser *userInfo = [ShareSDK currentUser:shareType];
  2992. SSDKCredential *credential = userInfo.credential;
  2993. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2994. [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"type"];
  2995. if ([credential available])
  2996. {
  2997. if ([credential uid])
  2998. {
  2999. [resultDict setObject:[credential uid] forKey:@"uid"];
  3000. }
  3001. if ([credential token])
  3002. {
  3003. [resultDict setObject:[credential token] forKey:@"token"];
  3004. }
  3005. if ([credential secret])
  3006. {
  3007. [resultDict setObject:[credential secret] forKey:@"secret"];
  3008. }
  3009. if ([credential expired])
  3010. {
  3011. [resultDict setObject:@([[credential expired] timeIntervalSince1970]) forKey:@"expired"];
  3012. }
  3013. [resultDict setObject:[NSNumber numberWithBool:[credential available]] forKey:@"available"];
  3014. }
  3015. else
  3016. {
  3017. [resultDict setObject:[NSNumber numberWithBool:NO] forKey:@"available"];
  3018. [resultDict setObject:@"Invalid Authorization" forKey:@"error"];
  3019. }
  3020. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3021. return __StringCopy([resultStr UTF8String]);
  3022. }
  3023. void __iosShareSDKFollowFriend (int reqID, int platType,void *account, void *observer)
  3024. {
  3025. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3026. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3027. SSDKUser *user = [[SSDKUser alloc]init];
  3028. user.uid = [NSString stringWithCString:account encoding:NSUTF8StringEncoding];
  3029. if (shareType == SSDKPlatformTypeTencentWeibo)
  3030. {
  3031. user.uid = nil;
  3032. user.nickname = [NSString stringWithCString:account encoding:NSUTF8StringEncoding];
  3033. }
  3034. [ShareSDK addFriend:shareType
  3035. user:user
  3036. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
  3037. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3038. [resultDict setObject:[NSNumber numberWithInteger:6] forKey:@"action"];
  3039. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3040. [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"platform"];
  3041. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3042. if (state == SSDKResponseStateFail && error)
  3043. {
  3044. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3045. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3046. if ([[error userInfo] objectForKey:@"error_message"])
  3047. {
  3048. if ([[error userInfo] objectForKey:@"error_message"])
  3049. {
  3050. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3051. }
  3052. }
  3053. else if ([[error userInfo] objectForKey:@"user_data"])
  3054. {
  3055. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3056. if ([error_data objectForKey:@"error"])
  3057. {
  3058. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3059. }
  3060. if ([error_data objectForKey:@"error_code"])
  3061. {
  3062. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3063. forKey:@"error_code"];
  3064. }
  3065. }
  3066. [resultDict setObject:errorDict forKey:@"res"];
  3067. }
  3068. if (state == SSDKResponseStateSuccess)
  3069. {
  3070. NSDictionary *userRawdata = [NSDictionary dictionaryWithDictionary:[user rawData]];
  3071. [resultDict setObject:userRawdata forKey:@"res"];
  3072. }
  3073. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3074. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3075. }];
  3076. }
  3077. void __iosShareSDKShareWithContentName(int reqID, int platType, void *contentName, void *customHashtable, void *observer)
  3078. {
  3079. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3080. NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
  3081. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3082. NSDictionary *customFields = nil;
  3083. if (customHashtable)
  3084. {
  3085. customFields = __parseWithHashtable(customHashtable);
  3086. }
  3087. [ShareSDK shareWithContentName:contentNodeName
  3088. platform:shareType
  3089. customFields:customFields
  3090. onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
  3091. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3092. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3093. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3094. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  3095. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3096. if (state == SSDKResponseStateFail && error)
  3097. {
  3098. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3099. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3100. if ([[error userInfo] objectForKey:@"error_message"])
  3101. {
  3102. if ([[error userInfo] objectForKey:@"error_message"])
  3103. {
  3104. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3105. forKey:@"error_msg"];
  3106. }
  3107. }
  3108. else if ([[error userInfo] objectForKey:@"user_data"])
  3109. {
  3110. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3111. if ([error_data objectForKey:@"error"])
  3112. {
  3113. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3114. }
  3115. if ([error_data objectForKey:@"error_code"])
  3116. {
  3117. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3118. forKey:@"error_code"];
  3119. }
  3120. }
  3121. else if([[error userInfo] objectForKey:@"error_msg"])
  3122. {
  3123. if ([[error userInfo] objectForKey:@"error_msg"])
  3124. {
  3125. [errorDict setObject:[[error userInfo] objectForKey:@"error_msg"]
  3126. forKey:@"error_msg"];
  3127. }
  3128. }
  3129. [resultDict setObject:errorDict forKey:@"res"];
  3130. }
  3131. if (state == SSDKResponseStateSuccess)
  3132. {
  3133. if ([contentEntity rawData])
  3134. {
  3135. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3136. }
  3137. }
  3138. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3139. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3140. }];
  3141. }
  3142. void __iosShareSDKShowShareMenuWithContentName(int reqID, void *contentName, void *customHashtable, void *platTypes, int x, int y, void *observer)
  3143. {
  3144. NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
  3145. NSDictionary *customFields = nil;
  3146. if (customHashtable)
  3147. {
  3148. customFields = __parseWithHashtable(customHashtable);
  3149. }
  3150. NSArray *platTypesArr = nil;
  3151. NSMutableArray *actionSheetItems = [NSMutableArray array];
  3152. NSString *observerStr = nil;
  3153. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3154. if (platTypes)
  3155. {
  3156. NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
  3157. platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
  3158. }
  3159. else
  3160. {
  3161. platTypesArr = [ShareSDK activePlatforms];
  3162. for (id obj in platTypesArr)
  3163. {
  3164. NSInteger platformInterger = [obj integerValue];
  3165. [actionSheetItems addObject:[NSNumber numberWithInteger:platformInterger]];
  3166. }
  3167. platTypesArr = [actionSheetItems mutableCopy];
  3168. }
  3169. if ([MOBFDevice isPad])
  3170. {
  3171. if (!_refView)
  3172. {
  3173. _refView = [[UIView alloc] initWithFrame:CGRectMake(x, y, 10, 10)];
  3174. }
  3175. [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_refView];
  3176. }
  3177. [ShareSDK showShareActionSheet:_refView
  3178. items:platTypesArr
  3179. contentName:contentNodeName
  3180. customFields:customFields
  3181. onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  3182. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3183. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3184. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3185. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  3186. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3187. if (state == SSDKResponseStateFail && error)
  3188. {
  3189. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3190. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3191. if ([[error userInfo] objectForKey:@"error_message"])
  3192. {
  3193. if ([[error userInfo] objectForKey:@"error_message"])
  3194. {
  3195. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3196. forKey:@"error_msg"];
  3197. }
  3198. }
  3199. else if ([[error userInfo] objectForKey:@"user_data"])
  3200. {
  3201. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3202. if ([error_data objectForKey:@"error"])
  3203. {
  3204. [errorDict setObject:[error_data objectForKey:@"error"]
  3205. forKey:@"error_msg"];
  3206. }
  3207. else if ([error_data objectForKey:@"error_message"])
  3208. {
  3209. [errorDict setObject:[error_data objectForKey:@"error_message"]
  3210. forKey:@"error_msg"];
  3211. }
  3212. if ([error_data objectForKey:@"error_code"])
  3213. {
  3214. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3215. forKey:@"error_code"];
  3216. }
  3217. }
  3218. [resultDict setObject:errorDict forKey:@"res"];
  3219. }
  3220. if (state == SSDKResponseStateSuccess)
  3221. {
  3222. if ([contentEntity rawData])
  3223. {
  3224. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3225. }
  3226. }
  3227. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3228. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3229. if (_refView)
  3230. {
  3231. //移除视图
  3232. [_refView removeFromSuperview];
  3233. }
  3234. }];
  3235. }
  3236. void __iosShareSDKShowShareViewWithContentName(int reqID, int platType, void *contentName, void *customHashtable, void *observer)
  3237. {
  3238. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3239. NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
  3240. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3241. NSDictionary *customFields = nil;
  3242. if (customHashtable)
  3243. {
  3244. customFields = __parseWithHashtable(customHashtable);
  3245. }
  3246. [ShareSDK showShareEditor:shareType
  3247. otherPlatformTypes:nil
  3248. contentName:contentNodeName
  3249. customFields:customFields
  3250. onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  3251. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3252. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3253. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3254. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  3255. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3256. if (state == SSDKResponseStateFail && error)
  3257. {
  3258. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3259. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3260. if ([[error userInfo] objectForKey:@"error_message"])
  3261. {
  3262. if ([[error userInfo] objectForKey:@"error_message"])
  3263. {
  3264. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3265. }
  3266. }
  3267. else if ([[error userInfo] objectForKey:@"user_data"])
  3268. {
  3269. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3270. if ([error_data objectForKey:@"error"])
  3271. {
  3272. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3273. }
  3274. if ([error_data objectForKey:@"error_code"])
  3275. {
  3276. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  3277. }
  3278. }
  3279. [resultDict setObject:errorDict forKey:@"res"];
  3280. }
  3281. if (state == SSDKResponseStateSuccess)
  3282. {
  3283. if ([contentEntity rawData])
  3284. {
  3285. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3286. }
  3287. }
  3288. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3289. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3290. }];
  3291. }
  3292. #if defined (__cplusplus)
  3293. }
  3294. #endif
  3295. @implementation ShareSDKUnity3DBridge
  3296. @end