ShareSDKUnity3DBridge.m 184 KB

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