ShareSDKUnity3DBridge.m 210 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469
  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 <objc/message.h>
  10. #import <ShareSDK/ShareSDK.h>
  11. #import <ShareSDKUI/ShareSDKUI.h>
  12. #import <ShareSDK/ShareSDK+Base.h>
  13. #import <MOBFoundation/MOBFJson.h>
  14. #import <MOBFoundation/MOBFoundation.h>
  15. #import <MOBFoundation/MobSDK+Privacy.h>
  16. #import <ShareSDKExtension/ShareSDK+Extension.h>
  17. #import <ShareSDKExtension/SSEFriendsPaging.h>
  18. #import <ShareSDKExtension/SSEShareHelper.h>
  19. #import <ShareSDKConfigFile/ShareSDK+XML.h>
  20. #import <ShareSDK/NSMutableDictionary+SSDKShare.h>
  21. //#import <ShareSDKExtension/SSERestoreSceneHeader.h>
  22. //static ShareSDKUnityRestoreSceneCallback *_callback = nil;
  23. static UIView *_refView = nil;
  24. #if defined (__cplusplus)
  25. extern "C" {
  26. #endif
  27. /**
  28. * @brief 配置SDK并初始化
  29. *
  30. * @param appKey ShareSDK的AppKey
  31. * @param configInfo 配置信息
  32. */
  33. extern void __iosShareSDKRegisterAppAndSetPltformsConfig (void *appKey, void*configInfo);
  34. /**
  35. * 用户授权
  36. *
  37. * @param reqID 流水号
  38. * @param platType 平台类型
  39. * @param observer 观察回调对象名称
  40. */
  41. extern void __iosShareSDKAuthorize (int reqID, int platType, void *observer);
  42. /**
  43. * @brief 取消用户授权
  44. *
  45. * @param platType 平台类型
  46. */
  47. extern void __iosShareSDKCancelAuthorize (int platType);
  48. /**
  49. * @brief 判断用户是否授权
  50. *
  51. * @param platType 平台类型
  52. *
  53. * @return YES 表示已经授权,NO 表示尚未授权
  54. */
  55. extern bool __iosShareSDKHasAuthorized (int platType);
  56. /**
  57. * @brief 检测是否安装客户端
  58. *
  59. * @param platType 平台类型
  60. *
  61. * @return YES 表示已经安装,NO 表示尚未安装
  62. */
  63. extern bool __iosShareSDKIsClientInstalled (int platType);
  64. /**
  65. * @brief 获取用户信息
  66. *
  67. * @param reqID 流水号
  68. * @param platType 平台类型
  69. * @param observer 观察回调对象名称
  70. */
  71. extern void __iosShareSDKGetUserInfo (int reqID, int platType, void *observer);
  72. /**
  73. * @brief 分享内容
  74. *
  75. * @param reqID 流水号
  76. * @param platType 平台类型
  77. * @param content 分享内容
  78. * @param observer 观察回调对象名称
  79. */
  80. extern void __iosShareSDKShare (int reqID, int platType, void *content, void *observer);
  81. /**
  82. * @brief 系统分享内容
  83. *
  84. * @param reqID 流水号
  85. * @param platType 平台类型
  86. * @param content 分享内容
  87. * @param observer 观察回调对象名称
  88. */
  89. extern void __iosShareSDKShareWithActivity (int reqID, int platType, void *content, void *observer);
  90. /**
  91. * @brief 一键分享内容
  92. *
  93. * @param reqID 流水号
  94. * @param platTypes 平台类型列表
  95. * @param content 分享内容
  96. * @param observer 观察回调对象名称
  97. */
  98. extern void __iosShareSDKOneKeyShare (int reqID, void *platTypes, void *content, void *observer);
  99. /**
  100. * @brief 口令分享
  101. *
  102. * @param content 分享内容
  103. * @param observer 观察回调对象名称
  104. */
  105. extern void __iosShareSDKShareWithCommand (void *content, void *observer);
  106. /**
  107. * @brief 显示分享菜单
  108. *
  109. * @param reqID 流水号
  110. * @param platTypes 平台类型列表
  111. * @param content 分享内容
  112. * @param x 弹出菜单的箭头的横坐标,仅用于iPad
  113. * @param y 弹出菜单的箭头的纵坐标,仅用于iPad
  114. * @param observer 观察回调对象名称
  115. */
  116. extern void __iosShareSDKShowShareMenu (int reqID, void *platTypes, void *content, int x, int y, void *observer);
  117. /**
  118. * @brief 显示分享编辑界面
  119. *
  120. * @param reqID 流水号
  121. * @param platType 平台类型
  122. * @param content 分享内容
  123. * @param observer 观察回调对象名称
  124. */
  125. extern void __iosShareSDKShowShareView (int reqID, int platType, void *content, void *observer);
  126. /**
  127. * @brief 获取授权用户好友列表
  128. *
  129. * @param reqID 流水号
  130. * @param platType 平台类型
  131. * @param count 单页好友数量
  132. * @param page 页码/游标cusor
  133. * @param observer 观察回调对象名称
  134. */
  135. extern void __iosShareSDKGetFriendsList (int reqID, int platType, int count , int page, void *observer);
  136. /**
  137. * @brief 获取授权信息
  138. *
  139. * @param platType 平台类型
  140. * @param observer 观察回调对象名称
  141. */
  142. extern const char* __iosShareSDKGetCredential (int platType);
  143. /**
  144. * @brief 关注/添加好友
  145. *
  146. * @param platType 平台类型
  147. * @param observer 观察回调对象名称
  148. */
  149. extern void __iosShareSDKFollowFriend (int reqID, int platType, void *account, void *observer);
  150. /**
  151. * @brief 根据配置文件分享
  152. *
  153. * @param reqID 流水号
  154. * @param contentName 配置文件节点标识
  155. * @param customHashtable 自定义字段表
  156. * @param platType 平台类型
  157. * @param observer 观察回调对象名称
  158. */
  159. extern void __iosShareSDKShareWithContentName(int reqID,
  160. int platType,
  161. void *contentName,
  162. void *customHashtable,
  163. void *observer);
  164. /**
  165. * @brief 根据配置文件展示分享菜单
  166. *
  167. * @param reqID 流水号
  168. * @param contentName 配置文件节点标识
  169. * @param customHashtable 自定义字段表
  170. * @param platTypes 平台类型列表
  171. * @param x 弹出菜单的箭头的横坐标,仅用于iPad
  172. * @param y 弹出菜单的箭头的纵坐标,仅用于iPad
  173. * @param observer 观察回调对象名称
  174. */
  175. extern void __iosShareSDKShowShareMenuWithContentName(int reqID,
  176. void *contentName,
  177. void *customHashtable,
  178. void *platTypes,
  179. int x,
  180. int y,
  181. void *observer);
  182. /**
  183. * @brief 根据配置文件展示分享编辑界面
  184. *
  185. * @param reqID 流水号
  186. * @param contentName 配置文件节点标识
  187. * @param customHashtable 自定义字段表
  188. * @param platType 平台类型
  189. * @param observer 观察回调对象名称
  190. */
  191. extern void __iosShareSDKShowShareViewWithContentName(int reqID,
  192. int platType,
  193. void *contentName,
  194. void *customHashtable,
  195. void *observer);
  196. /**
  197. 打开小程序
  198. @param userName 小程序userName
  199. @param path 路径
  200. @param miniProgramType 版本
  201. @return 是否成功打开
  202. */
  203. extern bool __iosShareSDKOpenMiniProgram(void *userName, void *path, int miniProgramType);
  204. extern void __iosShareSDKWXRefreshRequestToken(void *observer);
  205. extern void __iosShareSDKWXRefreshSendTokenToGetUser(void *token);
  206. extern void __iosShareSDKWXRequestToken(void *observer);
  207. extern void __iosShareSDKWXRequestSendTokenToGetUser(void * uid, void *token);
  208. extern void __iosMobSDKGetPolicy(int type, void * language , void * observer);
  209. extern void __iosMobSDKSubmitPolicyGrantResult(int granted);
  210. extern void __iosMobSDKSetAllowDialog(int allow);
  211. extern void __iosMobSDKSetPolicyUI(void * backgroundColorRes , void * positiveBtnColorRes, void * negativeBtnColorRes);
  212. extern char * __iosMobSDKGetCurrentLanguage();
  213. #if defined (__cplusplus)
  214. }
  215. #endif
  216. #if defined (__cplusplus)
  217. extern "C" {
  218. #endif
  219. NSMutableDictionary *__parseWithHashtable (void*configInfo)
  220. {
  221. NSString *confCs = [NSString stringWithCString:configInfo encoding:NSUTF8StringEncoding];
  222. NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[MOBFJson objectFromJSONString:confCs]];
  223. return dic;
  224. }
  225. SSDKPlatformType __convertContentType(NSInteger type)
  226. {
  227. switch (type)
  228. {
  229. case 0:
  230. return SSDKContentTypeAuto;
  231. case 1:
  232. return SSDKContentTypeText;
  233. case 2:
  234. return SSDKContentTypeImage;
  235. case 4:
  236. return SSDKContentTypeWebPage;
  237. case 5:
  238. return SSDKContentTypeAudio;
  239. case 6:
  240. return SSDKContentTypeVideo;
  241. case 7:
  242. return SSDKContentTypeApp;
  243. case 8:
  244. return SSDKContentTypeFile;
  245. case 9:
  246. return SSDKContentTypeImage;
  247. case 10:
  248. return SSDKContentTypeMiniProgram;
  249. case 11:
  250. return SSDKContentTypeMessage;
  251. default:
  252. return SSDKContentTypeText;
  253. }
  254. }
  255. void __setWechatParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  256. {
  257. NSString *text = nil;
  258. NSString *title = nil;
  259. NSString *url = nil;
  260. NSString *thumbImg = nil;
  261. NSString *image = nil;
  262. NSString *musicFileUrl = nil;
  263. NSString *extInfo = nil;
  264. NSData *fileData = nil;
  265. NSData *emoData = nil;
  266. NSString *sourceFileExtension = nil;
  267. NSData *sourceFileData = nil;
  268. //小程序参数
  269. NSString *path = nil;
  270. NSString *hdThumbImage = nil;
  271. NSString *username = nil;
  272. BOOL withShareTicket = NO;
  273. int miniProgramType = 0;
  274. SSDKContentType type = SSDKContentTypeText;
  275. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  276. {
  277. text = [value objectForKey:@"text"];
  278. }
  279. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  280. {
  281. title = [value objectForKey:@"title"];
  282. }
  283. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  284. {
  285. url = [value objectForKey:@"url"];
  286. }
  287. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  288. {
  289. thumbImg = [value objectForKey:@"thumbImageUrl"];
  290. }
  291. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  292. {
  293. image = [value objectForKey:@"imageUrl"];
  294. }
  295. if ([[value objectForKey:@"musicUrl"] isKindOfClass:[NSString class]])
  296. {
  297. musicFileUrl = [value objectForKey:@"musicUrl"];
  298. }
  299. if ([[value objectForKey:@"extInfoPath"] isKindOfClass:[NSString class]])
  300. {
  301. extInfo = [value objectForKey:@"extInfoPath"];
  302. }
  303. if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
  304. {
  305. fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"filePath"]];
  306. }
  307. if ([[value objectForKey:@"emotionPath"] isKindOfClass:[NSString class]])
  308. {
  309. emoData = [NSData dataWithContentsOfFile:[value objectForKey:@"emotionPath"]];
  310. }
  311. if ([[value objectForKey:@"sourceFileExtension"] isKindOfClass:[NSString class]])
  312. {
  313. sourceFileExtension = [value objectForKey:@"sourceFileExtension"];
  314. }
  315. if ([[value objectForKey:@"sourceFilePath"] isKindOfClass:[NSString class]])
  316. {
  317. sourceFileData = [NSData dataWithContentsOfFile:[value objectForKey:@"sourceFilePath"]];
  318. }
  319. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  320. {
  321. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  322. }
  323. if ([[value objectForKey:@"wxUserName"] isKindOfClass:[NSString class]])
  324. {
  325. username = [value objectForKey:@"wxUserName"];
  326. }
  327. if ([[value objectForKey:@"wxPath"] isKindOfClass:[NSString class]])
  328. {
  329. path = [value objectForKey:@"wxPath"];
  330. }
  331. if ([[value objectForKey:@"wxMiniProgramHdThumbImage"] isKindOfClass:[NSString class]])
  332. {
  333. hdThumbImage = [value objectForKey:@"wxMiniProgramHdThumbImage"];
  334. }
  335. if ([[value objectForKey:@"wxWithShareTicket"] isKindOfClass:[NSNumber class]])
  336. {
  337. withShareTicket = [[value objectForKey:@"wxWithShareTicket"] boolValue];
  338. }
  339. if ([[value objectForKey:@"wxMiniProgramType"] isKindOfClass:[NSNumber class]])
  340. {
  341. miniProgramType = [[value objectForKey:@"wxMiniProgramType"] intValue];
  342. }
  343. if (type == SSDKContentTypeMiniProgram)
  344. {
  345. [params SSDKSetupWeChatMiniProgramShareParamsByTitle:title
  346. description:text
  347. webpageUrl:[NSURL URLWithString:url]
  348. path:path
  349. thumbImage:thumbImg
  350. hdThumbImage:hdThumbImage
  351. userName:username
  352. withShareTicket:withShareTicket
  353. miniProgramType:miniProgramType
  354. forPlatformSubType:subType];
  355. }
  356. else
  357. {
  358. [params SSDKSetupWeChatParamsByText:text
  359. title:title
  360. url:[NSURL URLWithString:url]
  361. thumbImage:thumbImg
  362. image:image
  363. musicFileURL:[NSURL URLWithString:musicFileUrl]
  364. extInfo:extInfo
  365. fileData:fileData
  366. emoticonData:emoData
  367. sourceFileExtension:sourceFileExtension
  368. sourceFileData:sourceFileData
  369. type:type
  370. forPlatformSubType:subType];
  371. }
  372. }
  373. void __setQQParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  374. {
  375. NSString *text = nil;
  376. NSString *title = nil;
  377. NSString *url = nil;
  378. NSString *thumbImg = nil;
  379. NSString *audioUrl = nil;
  380. NSString *videoUrl = nil;
  381. NSMutableArray *images = [NSMutableArray array];
  382. SSDKContentType type = SSDKContentTypeText;
  383. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  384. {
  385. text = [value objectForKey:@"text"];
  386. }
  387. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  388. {
  389. title = [value objectForKey:@"title"];
  390. }
  391. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  392. {
  393. url = [value objectForKey:@"url"];
  394. }
  395. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  396. {
  397. thumbImg = [value objectForKey:@"thumbImageUrl"];
  398. }
  399. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  400. {
  401. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  402. }
  403. if ([[value objectForKey:@"audioPath"] isKindOfClass:[NSString class]])
  404. {
  405. audioUrl = [value objectForKey:@"audioPath"];
  406. }
  407. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  408. {
  409. videoUrl = [value objectForKey:@"videoPath"];
  410. }
  411. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  412. {
  413. NSString *imagesStr = [value objectForKey:@"imageArray"];
  414. images = [imagesStr componentsSeparatedByString:@","].mutableCopy;
  415. }
  416. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  417. {
  418. NSString *image = [value objectForKey:@"imageUrl"];
  419. if (image)
  420. {
  421. [images addObject:image];
  422. }
  423. }
  424. //小程序参数
  425. NSString *miniProgramPath = nil;
  426. NSString *miniProgramHdThumbImage = nil;
  427. NSString *miniProgramAppID = nil;
  428. NSString *miniProgramWebpageUrl = nil;
  429. int miniProgramType = 3;
  430. if ([[value objectForKey:@"qqMiniProgramPath"] isKindOfClass:[NSString class]])
  431. {
  432. miniProgramPath = [value objectForKey:@"qqMiniProgramPath"];
  433. }
  434. if ([[value objectForKey:@"qqMiniProgramHdThumbImage"] isKindOfClass:[NSString class]])
  435. {
  436. miniProgramHdThumbImage = [value objectForKey:@"qqMiniProgramHdThumbImage"];
  437. }
  438. if (miniProgramHdThumbImage == nil)
  439. {
  440. if (images.count > 0 && [images[0] isKindOfClass:[NSString class]])
  441. {
  442. miniProgramHdThumbImage = images[0];
  443. }
  444. else
  445. {
  446. miniProgramHdThumbImage = thumbImg;
  447. }
  448. }
  449. if ([[value objectForKey:@"qqMiniProgramAppID"] isKindOfClass:[NSString class]])
  450. {
  451. miniProgramAppID = [value objectForKey:@"qqMiniProgramAppID"];
  452. }
  453. if ([[value objectForKey:@"qqMiniProgramWebpageUrl"] isKindOfClass:[NSString class]])
  454. {
  455. miniProgramWebpageUrl = [value objectForKey:@"qqMiniProgramWebpageUrl"];
  456. }
  457. if ([[value objectForKey:@"qqMiniprogramType"] isKindOfClass:[NSNumber class]])
  458. {
  459. miniProgramType = [[value objectForKey:@"qqMiniprogramType"] intValue];
  460. }
  461. if (type == SSDKContentTypeMiniProgram)
  462. {
  463. [params SSDKSetupQQMiniProgramShareParamsByTitle:title
  464. description:text
  465. webpageUrl:[NSURL URLWithString:url]
  466. hdThumbImage:miniProgramHdThumbImage
  467. miniAppID:miniProgramAppID
  468. miniPath:miniProgramPath
  469. miniWebpageUrl:miniProgramWebpageUrl
  470. miniProgramType:miniProgramType
  471. forPlatformSubType:subType];
  472. }
  473. else
  474. {
  475. [params SSDKSetupQQParamsByText:text
  476. title:title
  477. url:[NSURL URLWithString:url]
  478. audioFlashURL:[NSURL URLWithString:audioUrl]
  479. videoFlashURL:[NSURL URLWithString:videoUrl]
  480. thumbImage:thumbImg
  481. images:images
  482. type:type
  483. forPlatformSubType:subType];
  484. }
  485. }
  486. void __setYixinParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  487. {
  488. NSString *text = nil;
  489. NSString *title = nil;
  490. NSString *url = nil;
  491. NSString *thumbImg = nil;
  492. NSString *image = nil;
  493. NSString *musicFileURL = nil;
  494. NSString *extInfo = nil;
  495. NSString *fileDataPath = nil;
  496. NSString *comment = nil;
  497. NSString *toUserId = nil;
  498. SSDKContentType type = SSDKContentTypeText;
  499. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  500. {
  501. text = [value objectForKey:@"text"];
  502. }
  503. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  504. {
  505. title = [value objectForKey:@"title"];
  506. }
  507. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  508. {
  509. url = [value objectForKey:@"url"];
  510. }
  511. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  512. {
  513. thumbImg = [value objectForKey:@"thumbImageUrl"];
  514. }
  515. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  516. {
  517. image = [value objectForKey:@"imageUrl"];
  518. }
  519. if ([[value objectForKey:@"musicUrl"] isKindOfClass:[NSString class]])
  520. {
  521. musicFileURL = [value objectForKey:@"musicUrl"];
  522. }
  523. if ([[value objectForKey:@"extInfoPath"] isKindOfClass:[NSString class]])
  524. {
  525. extInfo = [value objectForKey:@"extInfoPath"];
  526. }
  527. if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
  528. {
  529. fileDataPath = [value objectForKey:@"filePath"];
  530. }
  531. if ([[value objectForKey:@"comment"] isKindOfClass:[NSString class]])
  532. {
  533. comment = [value objectForKey:@"comment"];
  534. }
  535. if ([[value objectForKey:@"toUserID"] isKindOfClass:[NSString class]])
  536. {
  537. toUserId = [value objectForKey:@"toUserID"];
  538. }
  539. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  540. {
  541. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  542. }
  543. [params SSDKSetupYiXinParamsByText:text
  544. title:title
  545. url:[NSURL URLWithString:url]
  546. thumbImage:thumbImg
  547. image:image
  548. musicFileURL:[NSURL URLWithString:musicFileURL]
  549. musicLowBandUrl:nil
  550. musicDataUrl:nil
  551. musicLowBandDataUrl:nil
  552. extInfo:extInfo
  553. fileData:fileDataPath
  554. videoLowBandUrl:nil
  555. comment:comment
  556. toUserId:toUserId
  557. type:type
  558. forPlatformSubType:subType];
  559. }
  560. void __setKakaoParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
  561. {
  562. NSString *text = nil;
  563. NSMutableArray *images = [NSMutableArray array];
  564. NSString *title = nil;
  565. NSString *url = nil;
  566. NSString *permission = nil;
  567. BOOL enableShare;
  568. NSDictionary *androidExecParam = nil;
  569. NSDictionary *iphoneExecParams = nil;
  570. NSString *templateId = nil;
  571. NSDictionary *templateArgs = nil;
  572. SSDKContentType type = SSDKContentTypeText;
  573. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  574. {
  575. text = [value objectForKey:@"text"];
  576. }
  577. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  578. {
  579. NSString *imgPath = [value objectForKey:@"imageUrl"];
  580. SSDKImage *image = nil;
  581. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  582. options:MOBFRegexOptionsNoOptions
  583. inRange:NSMakeRange(0, imgPath.length)
  584. withString:imgPath])
  585. {
  586. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  587. }
  588. else
  589. {
  590. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  591. image = [[SSDKImage alloc] initWithImage:localImg
  592. format:SSDKImageFormatJpeg
  593. settings:nil];
  594. }
  595. if (image)
  596. {
  597. [images addObject:imgPath];
  598. }
  599. else
  600. {
  601. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  602. }
  603. }
  604. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  605. {
  606. NSArray *paths = [value objectForKey:@"imageUrl"];
  607. for (NSString *path in paths)
  608. {
  609. SSDKImage *image = nil;
  610. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  611. options:MOBFRegexOptionsNoOptions
  612. inRange:NSMakeRange(0, path.length)
  613. withString:path])
  614. {
  615. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  616. }
  617. else
  618. {
  619. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  620. image = [[SSDKImage alloc] initWithImage:localImg
  621. format:SSDKImageFormatJpeg
  622. settings:nil];
  623. }
  624. if (image)
  625. {
  626. [images addObject:path];
  627. }
  628. else
  629. {
  630. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  631. }
  632. }
  633. }
  634. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  635. {
  636. title = [value objectForKey:@"title"];
  637. }
  638. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  639. {
  640. url = [value objectForKey:@"url"];
  641. }
  642. if ([[value objectForKey:@"permission"] isKindOfClass:[NSString class]])
  643. {
  644. permission = [value objectForKey:@"permission"];
  645. }
  646. if ([[value objectForKey:@"enableShare"] boolValue])
  647. {
  648. enableShare = YES;
  649. }
  650. if ([[value objectForKey:@"androidExecParam"] isKindOfClass:[NSDictionary class]])
  651. {
  652. androidExecParam = [value objectForKey:@"androidExecParam"];
  653. }
  654. if ([[value objectForKey:@"iphoneExecParam"] isKindOfClass:[NSDictionary class]])
  655. {
  656. iphoneExecParams = [value objectForKey:@"iphoneExecParam"];
  657. }
  658. if ([[value objectForKey:@"templateArgs"] isKindOfClass:[NSDictionary class]])
  659. {
  660. templateArgs = [value objectForKey:@"templateArgs"];
  661. }
  662. if ([[value objectForKey:@"templateId"] isKindOfClass:[NSString class]])
  663. {
  664. templateId = [value objectForKey:@"templateId"];
  665. }
  666. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  667. {
  668. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  669. }
  670. if (subType == SSDKPlatformSubTypeKakaoStory)
  671. {
  672. [params SSDKSetupKakaoStoryParamsByContent:text
  673. title:title
  674. images:images
  675. url:[NSURL URLWithString:url]
  676. permission:permission.intValue
  677. sharable:enableShare
  678. androidExecParam:androidExecParam
  679. iosExecParam:iphoneExecParams type:type];
  680. }
  681. else
  682. {
  683. [params SSDKSetupKaKaoTalkParamsByUrl:[NSURL URLWithString:url]
  684. templateId:templateId
  685. templateArgs:templateArgs];
  686. }
  687. }
  688. NSMutableDictionary *__getShareParamsWithString(NSString *dataStr)
  689. {
  690. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  691. NSMutableArray *imageArray = [NSMutableArray array];
  692. NSString *text = nil;
  693. NSString *title = nil;
  694. NSString *url = nil;
  695. NSInteger shareAction = 0;
  696. SSDKContentType type = SSDKContentTypeText;
  697. NSDictionary *shareParamsDic = [MOBFJson objectFromJSONString:dataStr];
  698. if (shareParamsDic)
  699. {
  700. if ([[shareParamsDic objectForKey:@"text"] isKindOfClass:[NSString class]])
  701. {
  702. text = [shareParamsDic objectForKey:@"text"];
  703. }
  704. id img = [shareParamsDic objectForKey:@"imageUrl"];
  705. if ([img isKindOfClass:[NSString class]])
  706. {
  707. NSString *imgPath = img;
  708. SSDKImage *image = nil;
  709. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  710. options:MOBFRegexOptionsNoOptions
  711. inRange:NSMakeRange(0, imgPath.length)
  712. withString:imgPath])
  713. {
  714. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  715. }
  716. else
  717. {
  718. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  719. image = [[SSDKImage alloc] initWithImage:localImg
  720. format:SSDKImageFormatJpeg
  721. settings:nil];
  722. }
  723. if (image)
  724. {
  725. [imageArray addObject:imgPath];
  726. }
  727. else
  728. {
  729. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  730. }
  731. }
  732. else if([img isKindOfClass:[NSArray class]])
  733. {
  734. NSArray *paths = [img copy];
  735. for (NSString *path in paths)
  736. {
  737. SSDKImage *image = nil;
  738. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  739. options:MOBFRegexOptionsNoOptions
  740. inRange:NSMakeRange(0, path.length)
  741. withString:path])
  742. {
  743. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  744. }
  745. else
  746. {
  747. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  748. image = [[SSDKImage alloc] initWithImage:localImg
  749. format:SSDKImageFormatJpeg
  750. settings:nil];
  751. }
  752. if (image)
  753. {
  754. [imageArray addObject:path];
  755. }
  756. else
  757. {
  758. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  759. }
  760. }
  761. }
  762. NSArray *imgArray = nil;
  763. if ([[shareParamsDic objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  764. {
  765. NSString *imagesStr = shareParamsDic[@"imageArray"];
  766. imgArray = [imagesStr componentsSeparatedByString:@","];
  767. }
  768. if(imgArray && imgArray.count > 0)
  769. {
  770. NSArray *paths = [imgArray copy];
  771. for (NSString *path in paths)
  772. {
  773. SSDKImage *image = nil;
  774. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  775. options:MOBFRegexOptionsNoOptions
  776. inRange:NSMakeRange(0, path.length)
  777. withString:path])
  778. {
  779. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  780. }
  781. else
  782. {
  783. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  784. image = [[SSDKImage alloc] initWithImage:localImg
  785. format:SSDKImageFormatJpeg
  786. settings:nil];
  787. }
  788. if (image)
  789. {
  790. [imageArray addObject:path];
  791. }
  792. else
  793. {
  794. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  795. }
  796. }
  797. }
  798. if ([[shareParamsDic objectForKey:@"title"] isKindOfClass:[NSString class]])
  799. {
  800. title = [shareParamsDic objectForKey:@"title"];
  801. }
  802. if ([[shareParamsDic objectForKey:@"url"] isKindOfClass:[NSString class]])
  803. {
  804. url = [shareParamsDic objectForKey:@"url"];
  805. }
  806. if ([[shareParamsDic objectForKey:@"shareActionMode"] isKindOfClass:[NSNumber class]])
  807. {
  808. shareAction = [[shareParamsDic objectForKey:@"shareActionMode"] integerValue];
  809. [params setValue:shareAction == 1 ? @(SSDKDouyinOpenSDKShareTypeShareContentToIM) : @(SSDKDouyinOpenSDKShareTypePublishMedia) forKey:SSDKDouYinShareActionKey];
  810. }
  811. if ([[shareParamsDic objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  812. {
  813. type = __convertContentType([[shareParamsDic objectForKey:@"shareType"] integerValue]);
  814. }
  815. NSURL *urlPath;
  816. if ([url containsString:@"http://"] || [url containsString:@"https://"]) {
  817. urlPath = [NSURL URLWithString:url];
  818. }else if(url != nil){
  819. urlPath = [NSURL fileURLWithPath:url];
  820. }
  821. [params SSDKSetupShareParamsByText:text
  822. images:imageArray
  823. url:urlPath
  824. title:title
  825. type:type];
  826. NSDictionary *customizeShareParams = [shareParamsDic objectForKey:@"customizeShareParams"];
  827. if (customizeShareParams && [[customizeShareParams allKeys] count] > 0)
  828. {
  829. //新浪微博
  830. id value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSinaWeibo]]];
  831. if ([value isKindOfClass:[NSDictionary class]])
  832. {
  833. NSString *text = nil;
  834. NSString *title = nil;
  835. NSMutableArray *images = [NSMutableArray array];
  836. NSString *url = nil;
  837. double lat = 0;
  838. double lng = 0;
  839. NSString *objID = nil;
  840. NSString *video = nil;
  841. SSDKContentType type = SSDKContentTypeWebPage;
  842. BOOL linkCard = NO;
  843. NSString *cardTitle = nil;
  844. NSString *cardSummary = nil;
  845. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  846. {
  847. text = [value objectForKey:@"text"];
  848. }
  849. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  850. {
  851. title = [value objectForKey:@"title"];
  852. }
  853. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  854. {
  855. NSString * image = [value objectForKey:@"imageUrl"];
  856. if (image)
  857. {
  858. [images addObject:image];
  859. }
  860. }
  861. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  862. {
  863. url = [value objectForKey:@"url"];
  864. }
  865. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSString class]])
  866. {
  867. lat = [[value objectForKey:@"latitude"] doubleValue];
  868. }
  869. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSString class]])
  870. {
  871. lng = [[value objectForKey:@"longitude"] doubleValue];
  872. }
  873. if ([[value objectForKey:@"objectID"] isKindOfClass:[NSString class]])
  874. {
  875. objID = [value objectForKey:@"objectID"];
  876. }
  877. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  878. {
  879. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  880. }
  881. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  882. {
  883. video = [value objectForKey:@"videoPath"];
  884. }
  885. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  886. {
  887. NSString *imagesStr = value[@"imageArray"];
  888. [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
  889. }
  890. if ([[value objectForKey:@"sina_linkCard"] isKindOfClass:[NSNumber class]])
  891. {
  892. linkCard = [[value objectForKey:@"sina_linkCard"] integerValue]>0?YES:NO;
  893. }
  894. if ([[value objectForKey:@"sina_cardTitle"] isKindOfClass:[NSString class]])
  895. {
  896. cardTitle = [value objectForKey:@"sina_cardTitle"];
  897. }
  898. if ([[value objectForKey:@"sina_cardSummary"] isKindOfClass:[NSString class]])
  899. {
  900. cardSummary = [value objectForKey:@"sina_cardSummary"];
  901. }
  902. if (linkCard == YES)
  903. {
  904. /*
  905. [params SSDKSetupSinaWeiboLinkCardShareParamsByText:text
  906. cardTitle:cardTitle
  907. cardSummary:cardSummary
  908. images:images
  909. url:[NSURL URLWithString:url]];
  910. */
  911. }
  912. else
  913. {
  914. [params SSDKSetupSinaWeiboShareParamsByText:text
  915. title:title
  916. images:images
  917. video:video
  918. url:[NSURL URLWithString:url]
  919. latitude:lat
  920. longitude:lng
  921. objectID:objID
  922. isShareToStory:NO
  923. type:type];
  924. }
  925. }
  926. //QQ系列
  927. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeQQFriend]]];
  928. if ([value isKindOfClass:[NSDictionary class]])
  929. {
  930. __setQQParams(value,params,SSDKPlatformSubTypeQQFriend);
  931. }
  932. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeQZone]]];
  933. if ([value isKindOfClass:[NSDictionary class]])
  934. {
  935. __setQQParams(value,params,SSDKPlatformSubTypeQZone);
  936. }
  937. //微信系列
  938. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatSession]]];
  939. if ([value isKindOfClass:[NSDictionary class]])
  940. {
  941. __setWechatParams(value,params,SSDKPlatformSubTypeWechatSession);
  942. }
  943. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatTimeline]]];
  944. if ([value isKindOfClass:[NSDictionary class]])
  945. {
  946. __setWechatParams(value,params,SSDKPlatformSubTypeWechatTimeline);
  947. }
  948. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatFav]]];
  949. if ([value isKindOfClass:[NSDictionary class]])
  950. {
  951. __setWechatParams(value,params,SSDKPlatformSubTypeWechatFav);
  952. }
  953. //Douyin
  954. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDouyin]]];
  955. if ([value isKindOfClass:[NSDictionary class]])
  956. {
  957. NSArray *asset_localIdsArray = nil;
  958. NSString *douyin_hashtag = nil;
  959. NSDictionary *douyin_extraInfo = nil;
  960. NSInteger dyShareAction = 0;
  961. SSDKContentType type = SSDKContentTypeImage;
  962. if ([[value objectForKey:@"asset_localIds"] isKindOfClass:[NSArray class]])
  963. {
  964. asset_localIdsArray = [value objectForKey:@"asset_localIds"];
  965. }
  966. if ([[value objectForKey:@"douyin_hashtag"] isKindOfClass:[NSString class]])
  967. {
  968. douyin_hashtag = [value objectForKey:@"douyin_hashtag"];
  969. }
  970. if ([[value objectForKey:@"douyin_extraInfo"] isKindOfClass:[NSDictionary class]])
  971. {
  972. douyin_extraInfo = [value objectForKey:@"douyin_extraInfo"];
  973. }
  974. if ([[value objectForKey:@"shareActionMode"] isKindOfClass:[NSNumber class]])
  975. {
  976. dyShareAction = [[value objectForKey:@"shareActionMode"] integerValue];
  977. }
  978. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  979. {
  980. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  981. }
  982. [params SSDKSetupDouyinParamesByAssetLocalIds:asset_localIdsArray hashtag:douyin_hashtag extraInfo:douyin_extraInfo shareActionMode:dyShareAction == 1 ? SSDKDouyinOpenSDKShareTypeShareContentToIM : SSDKDouyinOpenSDKShareTypePublishMedia type:type];
  983. }
  984. //TikTok
  985. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTikTok]]];
  986. if ([value isKindOfClass:[NSDictionary class]])
  987. {
  988. NSString *tiktok_hashtag = nil;
  989. NSDictionary *tiktok_extraInfo = nil;
  990. NSArray *asset_localIdsArray = nil;
  991. NSArray *imageArray = nil;
  992. NSString *videoPath = nil;
  993. SSDKContentType type = SSDKContentTypeText;
  994. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  995. {
  996. NSString *paths = [value objectForKey:@"imageArray"];
  997. if (paths)
  998. {
  999. imageArray = [paths componentsSeparatedByString:@","];
  1000. }
  1001. }
  1002. if ([[value objectForKey:@"asset_localIds"] isKindOfClass:[NSArray class]])
  1003. {
  1004. asset_localIdsArray = [value objectForKey:@"asset_localIds"];
  1005. }
  1006. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1007. {
  1008. videoPath = [value objectForKey:@"url"];
  1009. }
  1010. if ([[value objectForKey:@"tiktok_hashtag"] isKindOfClass:[NSString class]])
  1011. {
  1012. tiktok_hashtag = [value objectForKey:@"tiktok_hashtag"];
  1013. }
  1014. if ([[value objectForKey:@"tiktok_extraInfo"] isKindOfClass:[NSDictionary class]])
  1015. {
  1016. tiktok_extraInfo = [value objectForKey:@"tiktok_extraInfo"];
  1017. }
  1018. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1019. {
  1020. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1021. }
  1022. if(imageArray || url){
  1023. [params SSDKSetupShareParamsByText:nil images:imageArray url:[NSURL URLWithString:url] title:nil type:type];
  1024. }else if(asset_localIdsArray){
  1025. [params SSDKSetupTikTokParamesByAssetLocalIds:asset_localIdsArray hashtag:tiktok_hashtag extraInfo:tiktok_extraInfo type:type];
  1026. }
  1027. }
  1028. //Facebook
  1029. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFacebook]]];
  1030. if ([value isKindOfClass:[NSDictionary class]])
  1031. {
  1032. NSString *text = nil;
  1033. NSMutableArray *images = [NSMutableArray array];
  1034. NSString *title = nil;
  1035. NSString *urlDesc = nil;
  1036. NSString *attachmentPath = nil;
  1037. NSString *quote = nil;
  1038. NSString *hashtag = nil;
  1039. NSInteger shareType = 1;
  1040. SSDKContentType type = SSDKContentTypeText;
  1041. NSArray *shareTypes = nil;
  1042. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1043. {
  1044. text = [value objectForKey:@"text"];
  1045. }
  1046. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1047. {
  1048. NSString *image = [value objectForKey:@"imageUrl"];
  1049. if (image)
  1050. {
  1051. [images addObject:image];
  1052. }
  1053. }
  1054. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1055. {
  1056. url = [value objectForKey:@"url"];
  1057. }
  1058. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1059. {
  1060. title = [value objectForKey:@"title"];
  1061. }
  1062. if ([[value objectForKey:@"urlDescription"] isKindOfClass:[NSString class]])
  1063. {
  1064. urlDesc = [value objectForKey:@"urlDescription"];
  1065. }
  1066. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1067. {
  1068. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1069. }
  1070. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1071. {
  1072. attachmentPath = [value objectForKey:@"attachmentPath"];
  1073. }
  1074. if ([[value objectForKey:@"quote"] isKindOfClass:[NSString class]])
  1075. {
  1076. quote = [value objectForKey:@"quote"];
  1077. }
  1078. if ([[value objectForKey:@"hashtag"] isKindOfClass:[NSString class]])
  1079. {
  1080. hashtag = [value objectForKey:@"hashtag"];
  1081. }
  1082. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  1083. {
  1084. NSString *paths = [value objectForKey:@"imageArray"];
  1085. if (paths)
  1086. {
  1087. [images addObjectsFromArray:[paths componentsSeparatedByString:@","]];
  1088. }
  1089. }
  1090. if ([[value objectForKey:@"facebook_shareType"] isKindOfClass:[NSNumber class]])
  1091. {
  1092. shareType = [[value objectForKey:@"facebook_shareType"] integerValue];
  1093. }
  1094. if ([[value objectForKey:@"facebook_shareTypes"] isKindOfClass:[NSArray class]])
  1095. {
  1096. shareTypes = [value objectForKey:@"facebook_shareTypes"];
  1097. }
  1098. if (!shareTypes) {
  1099. [params SSDKSetupFacebookParamsByText:text
  1100. image:images
  1101. url:[NSURL URLWithString:url]
  1102. urlTitle:title
  1103. urlName:urlDesc
  1104. attachementUrl:[NSURL URLWithString:attachmentPath]
  1105. hashtag:hashtag
  1106. quote:quote
  1107. shareType:shareType
  1108. type:type];
  1109. }else{
  1110. [params SSDKSetupFacebookParamsByText:text
  1111. image:images
  1112. url:[NSURL URLWithString:url]
  1113. urlTitle:title
  1114. urlName:urlDesc
  1115. attachementUrl:[NSURL URLWithString:attachmentPath]
  1116. hashtag:hashtag
  1117. quote:quote
  1118. sortShareTypes:shareTypes
  1119. type:type];
  1120. }
  1121. NSArray * imageAssets = nil;
  1122. if ([[value objectForKey:@"facebook_imageasset"] isKindOfClass:[NSString class]]) {
  1123. imageAssets = [(NSString *)[value objectForKey:@"facebook_imageasset"] componentsSeparatedByString:@","];
  1124. }
  1125. NSArray * videoAsset = nil;
  1126. if ([[value objectForKey:@"facebook_videoasset"] isKindOfClass:[NSString class]]) {
  1127. videoAsset = [value objectForKey:@"facebook_videoasset"];
  1128. }
  1129. [params SSDKSetupFacebookParamsByImagePHAsset:imageAssets videoPHAsset:videoAsset];
  1130. }
  1131. //FacebookMessenger
  1132. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFacebookMessenger]]];
  1133. if ([value isKindOfClass:[NSDictionary class]])
  1134. {
  1135. NSString *title = nil;
  1136. NSString *url = nil;
  1137. NSString *gif = nil;
  1138. NSString *audio = nil;
  1139. NSString *quote = nil;
  1140. NSString *video = nil;
  1141. NSMutableArray *images = [NSMutableArray array];
  1142. SSDKContentType type = SSDKContentTypeText;
  1143. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1144. {
  1145. title = [value objectForKey:@"title"];
  1146. }
  1147. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1148. {
  1149. url = [value objectForKey:@"url"];
  1150. }
  1151. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  1152. {
  1153. video = [value objectForKey:@"videoPath"];
  1154. }
  1155. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1156. {
  1157. NSString *image = [value objectForKey:@"imageUrl"];
  1158. if (image)
  1159. {
  1160. [images addObject:image];
  1161. }
  1162. }
  1163. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  1164. {
  1165. NSString *paths = [value objectForKey:@"imageArray"];
  1166. if (paths)
  1167. {
  1168. [images addObject:[paths componentsSeparatedByString:@","]];
  1169. }
  1170. }
  1171. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1172. {
  1173. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1174. }
  1175. [params SSDKSetupFacebookMessengerParamsByTitle:title url:[NSURL URLWithString:url] images:images video:video type:type];
  1176. }
  1177. //Twitter
  1178. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTwitter]]];
  1179. if ([value isKindOfClass:[NSDictionary class]])
  1180. {
  1181. NSString *text = nil;
  1182. NSMutableArray *images = [NSMutableArray array];
  1183. double lat;
  1184. double lng;
  1185. SSDKContentType type = SSDKContentTypeText;
  1186. NSString *videoPath = nil;
  1187. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1188. {
  1189. text = [value objectForKey:@"text"];
  1190. }
  1191. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1192. {
  1193. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1194. SSDKImage *image = nil;
  1195. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1196. options:MOBFRegexOptionsNoOptions
  1197. inRange:NSMakeRange(0, imgPath.length)
  1198. withString:imgPath])
  1199. {
  1200. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1201. }
  1202. else
  1203. {
  1204. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1205. image = [[SSDKImage alloc] initWithImage:localImg
  1206. format:SSDKImageFormatJpeg
  1207. settings:nil];
  1208. }
  1209. if (image)
  1210. {
  1211. [images addObject:imgPath];
  1212. }
  1213. else
  1214. {
  1215. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1216. }
  1217. }
  1218. if([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  1219. {
  1220. NSString *paths = [value objectForKey:@"imageArray"];
  1221. for (NSString *path in [paths componentsSeparatedByString:@","])
  1222. {
  1223. SSDKImage *image = nil;
  1224. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1225. options:MOBFRegexOptionsNoOptions
  1226. inRange:NSMakeRange(0, path.length)
  1227. withString:path])
  1228. {
  1229. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1230. }
  1231. else
  1232. {
  1233. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1234. image = [[SSDKImage alloc] initWithImage:localImg
  1235. format:SSDKImageFormatJpeg
  1236. settings:nil];
  1237. }
  1238. if (image)
  1239. {
  1240. [images addObject:path];
  1241. }
  1242. else
  1243. {
  1244. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1245. }
  1246. }
  1247. }
  1248. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSNumber class]])
  1249. {
  1250. lat = [[value objectForKey:@"latitude"] doubleValue];
  1251. }
  1252. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSNumber class]])
  1253. {
  1254. lng = [[value objectForKey:@"longitude"] doubleValue];
  1255. }
  1256. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  1257. {
  1258. videoPath = [value objectForKey:@"videoPath"];
  1259. }
  1260. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1261. {
  1262. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1263. }
  1264. [params SSDKSetupTwitterParamsByText:text images:images video:[NSURL URLWithString:videoPath] latitude:lat longitude:lng type:type];
  1265. }
  1266. //YinXiang
  1267. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYinXiang]]];
  1268. if ([value isKindOfClass:[NSDictionary class]])
  1269. {
  1270. NSString *text = nil;
  1271. NSString *title = nil;
  1272. NSMutableArray *images = [NSMutableArray array];
  1273. NSMutableArray *tags = [NSMutableArray array];
  1274. NSString *notebook = nil;
  1275. NSString *video = nil;
  1276. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1277. {
  1278. text = [value objectForKey:@"text"];
  1279. }
  1280. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1281. {
  1282. title = [value objectForKey:@"title"];
  1283. }
  1284. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1285. {
  1286. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1287. SSDKImage *image = nil;
  1288. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1289. options:MOBFRegexOptionsNoOptions
  1290. inRange:NSMakeRange(0, imgPath.length)
  1291. withString:imgPath])
  1292. {
  1293. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1294. }
  1295. else
  1296. {
  1297. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1298. image = [[SSDKImage alloc] initWithImage:localImg
  1299. format:SSDKImageFormatJpeg
  1300. settings:nil];
  1301. }
  1302. if (image)
  1303. {
  1304. [images addObject:imgPath];
  1305. }
  1306. else
  1307. {
  1308. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1309. }
  1310. }
  1311. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1312. {
  1313. NSArray *paths = [value objectForKey:@"imageUrl"];
  1314. for (NSString *path in paths)
  1315. {
  1316. SSDKImage *image = nil;
  1317. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1318. options:MOBFRegexOptionsNoOptions
  1319. inRange:NSMakeRange(0, path.length)
  1320. withString:path])
  1321. {
  1322. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1323. }
  1324. else
  1325. {
  1326. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1327. image = [[SSDKImage alloc] initWithImage:localImg
  1328. format:SSDKImageFormatJpeg
  1329. settings:nil];
  1330. }
  1331. if (image)
  1332. {
  1333. [images addObject:path];
  1334. }
  1335. else
  1336. {
  1337. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1338. }
  1339. }
  1340. }
  1341. if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
  1342. {
  1343. notebook = [value objectForKey:@"notebook"];
  1344. }
  1345. id tagValue = [value objectForKey:@"tags"];
  1346. if ([tagValue isKindOfClass:[NSString class]])
  1347. {
  1348. [tags addObject:tagValue];
  1349. }
  1350. else if ([tagValue isKindOfClass:[NSArray class]])
  1351. {
  1352. tags = [tagValue mutableCopy];
  1353. }
  1354. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  1355. {
  1356. video = [value objectForKey:@"videoPath"];
  1357. }
  1358. [params SSDKSetupEvernoteParamsByText:text
  1359. images:images
  1360. video:[NSURL URLWithString:video]
  1361. title:title
  1362. notebook:notebook
  1363. tags:tags
  1364. platformType:SSDKPlatformTypeYinXiang];
  1365. }
  1366. //GooglePlus
  1367. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeGooglePlus]]];
  1368. if ([value isKindOfClass:[NSDictionary class]])
  1369. {
  1370. NSString *text = nil;
  1371. NSString *url = nil;
  1372. SSDKContentType type = SSDKContentTypeText;
  1373. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1374. {
  1375. text = [value objectForKey:@"text"];
  1376. }
  1377. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1378. {
  1379. url = [value objectForKey:@"url"];
  1380. }
  1381. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1382. {
  1383. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1384. }
  1385. [params SSDKSetupGooglePlusParamsByText:text
  1386. url:[NSURL URLWithString:url]
  1387. type:type];
  1388. }
  1389. //Instagram
  1390. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeInstagram]]];
  1391. if ([value isKindOfClass:[NSDictionary class]])
  1392. {
  1393. NSString *image = nil;
  1394. CGFloat menuX;
  1395. CGFloat menuY;
  1396. SSDKContentType type = SSDKContentTypeText;
  1397. NSString *videoPath = nil;
  1398. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1399. {
  1400. image = [value objectForKey:@"imageUrl"];
  1401. }
  1402. if ([[value objectForKey:@"menuX"] isKindOfClass:[NSString class]])
  1403. {
  1404. menuX = [[value objectForKey:@"menuX"] floatValue];
  1405. }
  1406. if ([[value objectForKey:@"menuY"] isKindOfClass:[NSString class]])
  1407. {
  1408. menuX = [[value objectForKey:@"menuY"] floatValue];
  1409. }
  1410. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1411. {
  1412. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1413. }
  1414. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  1415. {
  1416. videoPath = [value objectForKey:@"videoPath"];
  1417. }
  1418. CGPoint point = CGPointMake(menuX, menuY);
  1419. if (type == SSDKContentTypeVideo)
  1420. {
  1421. [params SSDKSetupInstagramByVideo:[NSURL URLWithString:videoPath]];
  1422. }
  1423. else
  1424. {
  1425. [params SSDKSetupInstagramByImage:image menuDisplayPoint:point];
  1426. }
  1427. }
  1428. //LinkedIn
  1429. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeLinkedIn]]];
  1430. if ([value isKindOfClass:[NSDictionary class]])
  1431. {
  1432. NSString *text = nil;
  1433. NSString *image = nil;
  1434. NSString *title = nil;
  1435. NSString *url = nil;
  1436. NSString *urlDesc = nil;
  1437. NSString *visibility = nil;
  1438. SSDKContentType type = SSDKContentTypeText;
  1439. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1440. {
  1441. text = [value objectForKey:@"text"];
  1442. }
  1443. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1444. {
  1445. image = [value objectForKey:@"imageUrl"];
  1446. }
  1447. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1448. {
  1449. title = [value objectForKey:@"title"];
  1450. }
  1451. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1452. {
  1453. url = [value objectForKey:@"url"];
  1454. }
  1455. if ([[value objectForKey:@"urlDescription"] isKindOfClass:[NSString class]])
  1456. {
  1457. urlDesc = [value objectForKey:@"urlDescription"];
  1458. }
  1459. if ([[value objectForKey:@"visibility"] isKindOfClass:[NSString class]])
  1460. {
  1461. visibility = [value objectForKey:@"visibility"];
  1462. }
  1463. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1464. {
  1465. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1466. }
  1467. [params SSDKSetupLinkedInParamsByText:text
  1468. image:image
  1469. url:[NSURL URLWithString:url]
  1470. title:title
  1471. urlDesc:urlDesc
  1472. visibility:visibility
  1473. type:type];
  1474. }
  1475. //Tumblr
  1476. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTumblr]]];
  1477. if ([value isKindOfClass:[NSDictionary class]])
  1478. {
  1479. NSString *text = nil;
  1480. NSString *image = nil;
  1481. NSString *title = nil;
  1482. NSString *url = nil;
  1483. NSString *blogName = nil;
  1484. NSString *mediaDataPath = nil;
  1485. SSDKContentType type = SSDKContentTypeText;
  1486. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1487. {
  1488. text = [value objectForKey:@"text"];
  1489. }
  1490. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1491. {
  1492. image = [value objectForKey:@"imageUrl"];
  1493. }
  1494. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1495. {
  1496. title = [value objectForKey:@"title"];
  1497. }
  1498. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1499. {
  1500. url = [value objectForKey:@"url"];
  1501. }
  1502. if ([[value objectForKey:@"blogName"] isKindOfClass:[NSString class]])
  1503. {
  1504. blogName = [value objectForKey:@"blogName"];
  1505. }
  1506. if ([[value objectForKey:@"mediaDataPath"] isKindOfClass:[NSString class]])
  1507. {
  1508. mediaDataPath = [value objectForKey:@"mediaDataPath"];
  1509. }
  1510. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1511. {
  1512. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1513. }
  1514. // if(type == 5 || type == 6){
  1515. // [params SSDKSetupTumblrShareParamsByTitle:title
  1516. // dataPath:mediaDataPath
  1517. // type:type];
  1518. // }else{
  1519. [params SSDKSetupTumblrParamsByText:text
  1520. image:image
  1521. url:[NSURL URLWithString:url]
  1522. title:title
  1523. blogName:blogName
  1524. type:type];
  1525. // }
  1526. }
  1527. //Reddit
  1528. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeReddit]]];
  1529. if ([value isKindOfClass:[NSDictionary class]])
  1530. {
  1531. NSString *text = nil;
  1532. NSString *image = nil;
  1533. NSString *title = nil;
  1534. NSString *url = nil;
  1535. SSDKContentType type = SSDKContentTypeText;
  1536. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1537. {
  1538. text = [value objectForKey:@"text"];
  1539. }
  1540. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1541. {
  1542. image = [value objectForKey:@"imageUrl"];
  1543. }
  1544. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1545. {
  1546. title = [value objectForKey:@"title"];
  1547. }
  1548. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1549. {
  1550. url = [value objectForKey:@"url"];
  1551. }
  1552. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1553. {
  1554. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1555. }
  1556. [params SSDKSetupShareParamsByText:text
  1557. images:image
  1558. url:[NSURL URLWithString:url]
  1559. title:title
  1560. type:type];
  1561. }
  1562. //Mail
  1563. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeMail]]];
  1564. if ([value isKindOfClass:[NSDictionary class]])
  1565. {
  1566. NSString *text = nil;
  1567. NSString *title = nil;
  1568. NSMutableArray *images = [NSMutableArray array];
  1569. NSMutableArray *attachments = [NSMutableArray array];
  1570. NSMutableArray *recipients = [NSMutableArray array];
  1571. NSMutableArray *ccRecipients = [NSMutableArray array];
  1572. NSMutableArray *bccRecipients = [NSMutableArray array];
  1573. SSDKContentType type = SSDKContentTypeText;
  1574. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1575. {
  1576. text = [value objectForKey:@"text"];
  1577. }
  1578. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1579. {
  1580. title = [value objectForKey:@"title"];
  1581. }
  1582. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1583. {
  1584. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1585. SSDKImage *image = nil;
  1586. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1587. options:MOBFRegexOptionsNoOptions
  1588. inRange:NSMakeRange(0, imgPath.length)
  1589. withString:imgPath])
  1590. {
  1591. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1592. }
  1593. else
  1594. {
  1595. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1596. image = [[SSDKImage alloc] initWithImage:localImg
  1597. format:SSDKImageFormatJpeg
  1598. settings:nil];
  1599. }
  1600. if (image)
  1601. {
  1602. [images addObject:imgPath];
  1603. }
  1604. else
  1605. {
  1606. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1607. }
  1608. }
  1609. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1610. {
  1611. NSArray *paths = [value objectForKey:@"imageUrl"];
  1612. for (NSString *path in paths)
  1613. {
  1614. SSDKImage *image = nil;
  1615. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1616. options:MOBFRegexOptionsNoOptions
  1617. inRange:NSMakeRange(0, path.length)
  1618. withString:path])
  1619. {
  1620. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1621. }
  1622. else
  1623. {
  1624. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1625. image = [[SSDKImage alloc] initWithImage:localImg
  1626. format:SSDKImageFormatJpeg
  1627. settings:nil];
  1628. }
  1629. if (image)
  1630. {
  1631. [images addObject:path];
  1632. }
  1633. else
  1634. {
  1635. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1636. }
  1637. }
  1638. }
  1639. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1640. {
  1641. NSData *attachementsData = [NSData dataWithContentsOfFile:[value objectForKey:@"attachmentPath"]];
  1642. [attachments addObject:attachementsData];
  1643. }
  1644. else if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSArray class]])
  1645. {
  1646. NSArray *paths = [value objectForKey:@"attachmentPath"];
  1647. for (NSString *path in paths)
  1648. {
  1649. NSData *attachementsData = [NSData dataWithContentsOfFile:path];
  1650. [attachments addObject:attachementsData];
  1651. }
  1652. }
  1653. if ([[value objectForKey:@"recipients"] isKindOfClass:[NSString class]])
  1654. {
  1655. [recipients addObject:[value objectForKey:@"recipients"]];
  1656. }
  1657. else if ([[value objectForKey:@"recipients"] isKindOfClass:[NSArray class]])
  1658. {
  1659. NSArray *recipientsArray = [value objectForKey:@"recipients"];
  1660. for (NSString *recipient in recipientsArray)
  1661. {
  1662. [recipients addObject:recipient];
  1663. }
  1664. }
  1665. if ([[value objectForKey:@"ccRecipients"] isKindOfClass:[NSString class]])
  1666. {
  1667. [ccRecipients addObject:[value objectForKey:@"ccRecipients"]];
  1668. }
  1669. else if ([[value objectForKey:@"ccRecipients"] isKindOfClass:[NSArray class]])
  1670. {
  1671. NSArray *recipientsArray = [value objectForKey:@"ccRecipients"];
  1672. for (NSString *recipient in recipientsArray)
  1673. {
  1674. [ccRecipients addObject:recipient];
  1675. }
  1676. }
  1677. if ([[value objectForKey:@"bccRecipients"] isKindOfClass:[NSString class]])
  1678. {
  1679. [bccRecipients addObject:[value objectForKey:@"bccRecipients"]];
  1680. }
  1681. else if ([[value objectForKey:@"bccRecipients"] isKindOfClass:[NSArray class]])
  1682. {
  1683. NSArray *recipientsArray = [value objectForKey:@"bccRecipients"];
  1684. for (NSString *recipient in recipientsArray)
  1685. {
  1686. [bccRecipients addObject:recipient];
  1687. }
  1688. }
  1689. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1690. {
  1691. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1692. }
  1693. [params SSDKSetupMailParamsByText:text
  1694. title:title
  1695. images:images
  1696. attachments:attachments
  1697. recipients:recipients
  1698. ccRecipients:ccRecipients
  1699. bccRecipients:bccRecipients
  1700. type:type];
  1701. }
  1702. //SMS
  1703. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSMS]]];
  1704. if ([value isKindOfClass:[NSDictionary class]])
  1705. {
  1706. NSString *text = nil;
  1707. NSString *title = nil;
  1708. NSMutableArray *images = [NSMutableArray array];
  1709. NSMutableArray *attachments = [NSMutableArray array];
  1710. NSMutableArray *recipients = [NSMutableArray array];
  1711. SSDKContentType type = SSDKContentTypeText;
  1712. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1713. {
  1714. text = [value objectForKey:@"text"];
  1715. }
  1716. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1717. {
  1718. title = [value objectForKey:@"title"];
  1719. }
  1720. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1721. {
  1722. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1723. SSDKImage *image = nil;
  1724. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1725. options:MOBFRegexOptionsNoOptions
  1726. inRange:NSMakeRange(0, imgPath.length)
  1727. withString:imgPath])
  1728. {
  1729. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1730. }
  1731. else
  1732. {
  1733. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1734. image = [[SSDKImage alloc] initWithImage:localImg
  1735. format:SSDKImageFormatJpeg
  1736. settings:nil];
  1737. }
  1738. if (image)
  1739. {
  1740. [images addObject:imgPath];
  1741. }
  1742. else
  1743. {
  1744. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1745. }
  1746. }
  1747. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1748. {
  1749. NSArray *paths = [value objectForKey:@"imageUrl"];
  1750. for (NSString *path in paths)
  1751. {
  1752. SSDKImage *image = nil;
  1753. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1754. options:MOBFRegexOptionsNoOptions
  1755. inRange:NSMakeRange(0, path.length)
  1756. withString:path])
  1757. {
  1758. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1759. }
  1760. else
  1761. {
  1762. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1763. image = [[SSDKImage alloc] initWithImage:localImg
  1764. format:SSDKImageFormatJpeg
  1765. settings:nil];
  1766. }
  1767. if (image)
  1768. {
  1769. [images addObject:path];
  1770. }
  1771. else
  1772. {
  1773. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1774. }
  1775. }
  1776. }
  1777. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  1778. {
  1779. NSData *attachementsData = [NSData dataWithContentsOfFile:[value objectForKey:@"attachmentPath"]];
  1780. [attachments addObject:attachementsData];
  1781. }
  1782. else if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSArray class]])
  1783. {
  1784. NSArray *paths = [value objectForKey:@"attachmentPath"];
  1785. for (NSString *path in paths)
  1786. {
  1787. NSData *attachementsData = [NSData dataWithContentsOfFile:path];
  1788. [attachments addObject:attachementsData];
  1789. }
  1790. }
  1791. if ([[value objectForKey:@"recipients"] isKindOfClass:[NSString class]])
  1792. {
  1793. [recipients addObject:[value objectForKey:@"recipients"]];
  1794. }
  1795. else if ([[value objectForKey:@"recipients"] isKindOfClass:[NSArray class]])
  1796. {
  1797. NSArray *recipientsArray = [value objectForKey:@"recipients"];
  1798. for (NSString *recipient in recipientsArray)
  1799. {
  1800. [recipients addObject:recipient];
  1801. }
  1802. }
  1803. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1804. {
  1805. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1806. }
  1807. [params SSDKSetupSMSParamsByText:text
  1808. title:title
  1809. images:images
  1810. attachments:attachments
  1811. recipients:recipients
  1812. type:type];
  1813. }
  1814. //Print
  1815. //无定制内容方法
  1816. //Copy
  1817. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeCopy]]];
  1818. if ([value isKindOfClass:[NSDictionary class]])
  1819. {
  1820. NSString *text = nil;
  1821. NSMutableArray *images = [NSMutableArray array];
  1822. NSString *url = nil;
  1823. SSDKContentType type = SSDKContentTypeImage;
  1824. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1825. {
  1826. text = [value objectForKey:@"text"];
  1827. }
  1828. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1829. {
  1830. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1831. SSDKImage *image = nil;
  1832. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1833. options:MOBFRegexOptionsNoOptions
  1834. inRange:NSMakeRange(0, imgPath.length)
  1835. withString:imgPath])
  1836. {
  1837. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  1838. }
  1839. else
  1840. {
  1841. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  1842. image = [[SSDKImage alloc] initWithImage:localImg
  1843. format:SSDKImageFormatJpeg
  1844. settings:nil];
  1845. }
  1846. if (image)
  1847. {
  1848. [images addObject:imgPath];
  1849. }
  1850. else
  1851. {
  1852. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1853. }
  1854. }
  1855. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  1856. {
  1857. NSArray *paths = [value objectForKey:@"imageUrl"];
  1858. for (NSString *path in paths)
  1859. {
  1860. SSDKImage *image = nil;
  1861. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  1862. options:MOBFRegexOptionsNoOptions
  1863. inRange:NSMakeRange(0, path.length)
  1864. withString:path])
  1865. {
  1866. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  1867. }
  1868. else
  1869. {
  1870. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  1871. image = [[SSDKImage alloc] initWithImage:localImg
  1872. format:SSDKImageFormatJpeg
  1873. settings:nil];
  1874. }
  1875. if (image)
  1876. {
  1877. [images addObject:path];
  1878. }
  1879. else
  1880. {
  1881. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  1882. }
  1883. }
  1884. }
  1885. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1886. {
  1887. url = [value objectForKey:@"url"];
  1888. }
  1889. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  1890. {
  1891. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  1892. }
  1893. [params SSDKSetupCopyParamsByText:text
  1894. images:images
  1895. url:[NSURL URLWithString:url]
  1896. type:type];
  1897. }
  1898. //Instapaper
  1899. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeInstapaper]]];
  1900. if ([value isKindOfClass:[NSDictionary class]])
  1901. {
  1902. NSString *url = nil;
  1903. NSString *title = nil;
  1904. NSString *desc = nil;
  1905. NSString *content = nil;
  1906. BOOL isPrivateFromSource;
  1907. NSInteger folderId;
  1908. BOOL resolveFinalUrl;
  1909. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1910. {
  1911. url = [value objectForKey:@"url"];
  1912. }
  1913. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1914. {
  1915. title = [value objectForKey:@"title"];
  1916. }
  1917. if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
  1918. {
  1919. desc = [value objectForKey:@"desc"];
  1920. }
  1921. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1922. {
  1923. content = [value objectForKey:@"text"];
  1924. }
  1925. if ([[value objectForKey:@"isPrivateFromSource"] boolValue])
  1926. {
  1927. isPrivateFromSource = YES;
  1928. }
  1929. if (![[value objectForKey:@"resolveFinalUrl"] boolValue])
  1930. {
  1931. resolveFinalUrl = YES;
  1932. }
  1933. folderId = [[value objectForKey:@"folderId"] integerValue];
  1934. [params SSDKSetupInstapaperParamsByUrl:[NSURL URLWithString:url]
  1935. title:title
  1936. desc:desc
  1937. content:content
  1938. isPrivateFromSource:isPrivateFromSource
  1939. folderId:folderId
  1940. resolveFinalUrl:resolveFinalUrl];
  1941. }
  1942. //Pocket
  1943. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypePocket]]];
  1944. if ([value isKindOfClass:[NSDictionary class]])
  1945. {
  1946. NSString *url = nil;
  1947. NSString *title = nil;
  1948. NSString *tags = nil;
  1949. NSString *tweetId = nil;
  1950. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  1951. {
  1952. url = [value objectForKey:@"url"];
  1953. }
  1954. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1955. {
  1956. title = [value objectForKey:@"title"];
  1957. }
  1958. id tagValue = [value objectForKey:@"tags"];
  1959. if ([tagValue isKindOfClass:[NSString class]])
  1960. {
  1961. tags = tagValue;
  1962. }
  1963. else if ([tagValue isKindOfClass:[NSArray class]])
  1964. {
  1965. NSArray *tagsArr = tagValue;
  1966. tags = [tagsArr componentsJoinedByString:@","];
  1967. }
  1968. if ([[value objectForKey:@"tweetID"] isKindOfClass:[NSString class]])
  1969. {
  1970. tweetId = [value objectForKey:@"tweetID"];
  1971. }
  1972. [params SSDKSetupPocketParamsByUrl:[NSURL URLWithString:url]
  1973. title:title
  1974. tags:tags
  1975. tweetId:tweetId];
  1976. }
  1977. //YouDaoNote
  1978. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYouDaoNote]]];
  1979. if ([value isKindOfClass:[NSDictionary class]])
  1980. {
  1981. NSString *text = nil;
  1982. NSString *title = nil;
  1983. NSMutableArray *images = [NSMutableArray array];
  1984. NSString *source = nil;
  1985. NSString *author = nil;
  1986. NSString *notebook = nil;
  1987. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  1988. {
  1989. text = [value objectForKey:@"text"];
  1990. }
  1991. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  1992. {
  1993. title = [value objectForKey:@"title"];
  1994. }
  1995. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  1996. {
  1997. NSString *imgPath = [value objectForKey:@"imageUrl"];
  1998. SSDKImage *image = nil;
  1999. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2000. options:MOBFRegexOptionsNoOptions
  2001. inRange:NSMakeRange(0, imgPath.length)
  2002. withString:imgPath])
  2003. {
  2004. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  2005. }
  2006. else
  2007. {
  2008. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  2009. image = [[SSDKImage alloc] initWithImage:localImg
  2010. format:SSDKImageFormatJpeg
  2011. settings:nil];
  2012. }
  2013. if (image)
  2014. {
  2015. [images addObject:imgPath];
  2016. }
  2017. else
  2018. {
  2019. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2020. }
  2021. }
  2022. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  2023. {
  2024. NSArray *paths = [value objectForKey:@"imageUrl"];
  2025. for (NSString *path in paths)
  2026. {
  2027. SSDKImage *image = nil;
  2028. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2029. options:MOBFRegexOptionsNoOptions
  2030. inRange:NSMakeRange(0, path.length)
  2031. withString:path])
  2032. {
  2033. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  2034. }
  2035. else
  2036. {
  2037. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  2038. image = [[SSDKImage alloc] initWithImage:localImg
  2039. format:SSDKImageFormatJpeg
  2040. settings:nil];
  2041. }
  2042. if (image)
  2043. {
  2044. [images addObject:path];
  2045. }
  2046. else
  2047. {
  2048. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2049. }
  2050. }
  2051. }
  2052. if ([[value objectForKey:@"source"] isKindOfClass:[NSString class]])
  2053. {
  2054. source = [value objectForKey:@"source"];
  2055. }
  2056. if ([[value objectForKey:@"author"] isKindOfClass:[NSString class]])
  2057. {
  2058. author = [value objectForKey:@"author"];
  2059. }
  2060. if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
  2061. {
  2062. notebook = [value objectForKey:@"notebook"];
  2063. }
  2064. [params SSDKSetupYouDaoNoteParamsByText:text
  2065. images:images
  2066. title:title
  2067. source:source
  2068. author:author
  2069. notebook:notebook];
  2070. }
  2071. //Pinterest
  2072. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypePinterest]]];
  2073. if ([value isKindOfClass:[NSDictionary class]])
  2074. {
  2075. NSString *image = nil;
  2076. NSString *desc = nil;
  2077. NSString *url = nil;
  2078. NSString *board = nil;
  2079. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2080. {
  2081. image = [value objectForKey:@"imageUrl"];
  2082. }
  2083. if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
  2084. {
  2085. desc = [value objectForKey:@"desc"];
  2086. }
  2087. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2088. {
  2089. url = [value objectForKey:@"url"];
  2090. }
  2091. if ([[value objectForKey:@"board"] isKindOfClass:[NSString class]])
  2092. {
  2093. board = [value objectForKey:@"board"];
  2094. }
  2095. [params SSDKSetupPinterestParamsByImageUrl:image desc:desc url:[NSURL URLWithString:url] boardName:board];
  2096. }
  2097. //Flickr
  2098. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFlickr]]];
  2099. if ([value isKindOfClass:[NSDictionary class]])
  2100. {
  2101. NSString *text = nil;
  2102. NSString *image = nil;
  2103. NSString *title = nil;
  2104. NSMutableArray *tags = [NSMutableArray array];
  2105. BOOL isPublic;
  2106. BOOL isFriend;
  2107. BOOL isFamiliy;
  2108. NSInteger safetyLevel;
  2109. NSInteger contentType;
  2110. NSInteger hidden;
  2111. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2112. {
  2113. text = [value objectForKey:@"text"];
  2114. }
  2115. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2116. {
  2117. image = [value objectForKey:@"imageUrl"];
  2118. }
  2119. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2120. {
  2121. title = [value objectForKey:@"title"];
  2122. }
  2123. id tagValue = [value objectForKey:@"tags"];
  2124. if ([tagValue isKindOfClass:[NSString class]])
  2125. {
  2126. [tags addObject:tagValue];
  2127. }
  2128. else if ([tagValue isKindOfClass:[NSArray class]])
  2129. {
  2130. tags = [tagValue mutableCopy];
  2131. }
  2132. if ([[value objectForKey:@"isPublic"] boolValue])
  2133. {
  2134. isPublic = YES;
  2135. }
  2136. if ([[value objectForKey:@"isFriend"] boolValue])
  2137. {
  2138. isFriend = YES;
  2139. }
  2140. if ([[value objectForKey:@"isFamiliy"] boolValue])
  2141. {
  2142. isFamiliy = YES;
  2143. }
  2144. if ([[value objectForKey:@"safetyLevel"] integerValue])
  2145. {
  2146. safetyLevel = [[value objectForKey:@"safetyLevel"] integerValue];
  2147. }
  2148. if ([[value objectForKey:@"contentType"] integerValue])
  2149. {
  2150. contentType = [[value objectForKey:@"contentType"] integerValue];
  2151. }
  2152. if ([[value objectForKey:@"hidden"] integerValue])
  2153. {
  2154. hidden = [[value objectForKey:@"hidden"] integerValue];
  2155. }
  2156. [params SSDKSetupFlickrParamsByText:text
  2157. image:image
  2158. title:title
  2159. tags:tags
  2160. isPublic:isPublic
  2161. isFriend:isFriend
  2162. isFamily:isFamiliy
  2163. safetyLevel:safetyLevel
  2164. contentType:contentType
  2165. hidden:hidden];
  2166. }
  2167. //Dropbox
  2168. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDropbox]]];
  2169. if ([value isKindOfClass:[NSDictionary class]])
  2170. {
  2171. NSString *attachmentPath = nil;
  2172. if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
  2173. {
  2174. attachmentPath = [value objectForKey:@"attachmentPath"];
  2175. }
  2176. [params SSDKSetupDropboxParamsByAttachment:attachmentPath];
  2177. }
  2178. //VKontakte
  2179. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeVKontakte]]];
  2180. if ([value isKindOfClass:[NSDictionary class]])
  2181. {
  2182. NSString *text = nil;
  2183. NSString *url = nil;
  2184. NSMutableArray *images = [NSMutableArray array];
  2185. NSString *groupId = nil;
  2186. BOOL friendsOnly;
  2187. double lat;
  2188. double lng;
  2189. SSDKContentType type = SSDKContentTypeText;
  2190. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2191. {
  2192. text = [value objectForKey:@"text"];
  2193. }
  2194. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2195. {
  2196. url = [value objectForKey:@"url"];
  2197. }
  2198. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2199. {
  2200. NSString *imgPath = [value objectForKey:@"imageUrl"];
  2201. SSDKImage *image = nil;
  2202. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2203. options:MOBFRegexOptionsNoOptions
  2204. inRange:NSMakeRange(0, imgPath.length)
  2205. withString:imgPath])
  2206. {
  2207. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  2208. }
  2209. else
  2210. {
  2211. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  2212. image = [[SSDKImage alloc] initWithImage:localImg
  2213. format:SSDKImageFormatJpeg
  2214. settings:nil];
  2215. }
  2216. if (image)
  2217. {
  2218. [images addObject:imgPath];
  2219. }
  2220. else
  2221. {
  2222. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2223. }
  2224. }
  2225. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  2226. {
  2227. NSArray *paths = [value objectForKey:@"imageUrl"];
  2228. for (NSString *path in paths)
  2229. {
  2230. SSDKImage *image = nil;
  2231. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2232. options:MOBFRegexOptionsNoOptions
  2233. inRange:NSMakeRange(0, path.length)
  2234. withString:path])
  2235. {
  2236. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  2237. }
  2238. else
  2239. {
  2240. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  2241. image = [[SSDKImage alloc] initWithImage:localImg
  2242. format:SSDKImageFormatJpeg
  2243. settings:nil];
  2244. }
  2245. if (image)
  2246. {
  2247. [images addObject:path];
  2248. }
  2249. else
  2250. {
  2251. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2252. }
  2253. }
  2254. }
  2255. if ([[value objectForKey:@"groupID"] isKindOfClass:[NSString class]])
  2256. {
  2257. groupId = [value objectForKey:@"groupID"];
  2258. }
  2259. if ([[value objectForKey:@"friendsOnly"] boolValue])
  2260. {
  2261. friendsOnly = YES;
  2262. }
  2263. if ([[value objectForKey:@"latitude"] isKindOfClass:[NSString class]])
  2264. {
  2265. lat = [[value objectForKey:@"latitude"] doubleValue];
  2266. }
  2267. if ([[value objectForKey:@"longitude"] isKindOfClass:[NSString class]])
  2268. {
  2269. lng = [[value objectForKey:@"longitude"] doubleValue];
  2270. }
  2271. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2272. {
  2273. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2274. }
  2275. [params SSDKSetupVKontakteParamsByText:text
  2276. images:images
  2277. url:[NSURL URLWithString:url]
  2278. groupId:groupId
  2279. friendsOnly:friendsOnly
  2280. latitude:lat
  2281. longitude:lng
  2282. type:type];
  2283. }
  2284. //Yixin系列
  2285. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinSession]]];
  2286. if ([value isKindOfClass:[NSDictionary class]])
  2287. {
  2288. __setYixinParams(value, params, SSDKPlatformSubTypeYiXinSession);
  2289. }
  2290. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinTimeline]]];
  2291. if ([value isKindOfClass:[NSDictionary class]])
  2292. {
  2293. __setYixinParams(value, params, SSDKPlatformSubTypeYiXinTimeline);
  2294. }
  2295. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinFav]]];
  2296. if ([value isKindOfClass:[NSDictionary class]])
  2297. {
  2298. __setYixinParams(value, params, SSDKPlatformSubTypeYiXinFav);
  2299. }
  2300. //MingDao
  2301. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeMingDao]]];
  2302. if ([value isKindOfClass:[NSDictionary class]])
  2303. {
  2304. NSString *text = nil;
  2305. NSString *image = nil;
  2306. NSString *url = nil;
  2307. NSString *title = nil;
  2308. SSDKContentType type = SSDKContentTypeText;
  2309. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2310. {
  2311. text = [value objectForKey:@"text"];
  2312. }
  2313. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2314. {
  2315. image = [value objectForKey:@"imageUrl"];
  2316. }
  2317. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2318. {
  2319. url = [value objectForKey:@"url"];
  2320. }
  2321. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2322. {
  2323. title = [value objectForKey:@"title"];
  2324. }
  2325. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2326. {
  2327. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2328. }
  2329. [params SSDKSetupMingDaoParamsByText:text
  2330. image:image
  2331. url:[NSURL URLWithString:url]
  2332. title:title
  2333. type:type];
  2334. }
  2335. //Line
  2336. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeLine]]];
  2337. if ([value isKindOfClass:[NSDictionary class]])
  2338. {
  2339. NSString *text = nil;
  2340. NSString *image = nil;
  2341. SSDKContentType type = SSDKContentTypeText;
  2342. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2343. {
  2344. text = [value objectForKey:@"text"];
  2345. }
  2346. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2347. {
  2348. image = [value objectForKey:@"imageUrl"];
  2349. }
  2350. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2351. {
  2352. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2353. }
  2354. [params SSDKSetupLineParamsByText:text
  2355. image:image
  2356. type:type];
  2357. }
  2358. //whatsApp
  2359. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeWhatsApp]]];
  2360. if ([value isKindOfClass:[NSDictionary class]])
  2361. {
  2362. NSString *text = nil;
  2363. NSString *image = nil;
  2364. NSString *audioPath = nil;
  2365. NSString *videoPath = nil;
  2366. CGFloat menuX;
  2367. CGFloat menuY;
  2368. SSDKContentType type = SSDKContentTypeText;
  2369. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2370. {
  2371. text = [value objectForKey:@"text"];
  2372. }
  2373. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2374. {
  2375. image = [value objectForKey:@"imageUrl"];
  2376. }
  2377. if ([[value objectForKey:@"audioPath"] isKindOfClass:[NSString class]])
  2378. {
  2379. audioPath = [value objectForKey:@"audioPath"];
  2380. }
  2381. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2382. {
  2383. videoPath = [value objectForKey:@"videoPath"];
  2384. }
  2385. if ([[value objectForKey:@"menuX"] isKindOfClass:[NSString class]])
  2386. {
  2387. menuX = [[value objectForKey:@"menuX"] floatValue];
  2388. }
  2389. if ([[value objectForKey:@"menuY"] isKindOfClass:[NSString class]])
  2390. {
  2391. menuX = [[value objectForKey:@"menuY"] floatValue];
  2392. }
  2393. CGPoint point = CGPointMake(menuX, menuY);
  2394. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2395. {
  2396. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2397. }
  2398. [params SSDKSetupWhatsAppParamsByText:text
  2399. image:image
  2400. audio:audioPath
  2401. video:videoPath
  2402. menuDisplayPoint:point
  2403. type:type];
  2404. }
  2405. //Kakao系列
  2406. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeKakaoTalk]]];
  2407. if ([value isKindOfClass:[NSDictionary class]])
  2408. {
  2409. __setKakaoParams(value,params,SSDKPlatformSubTypeKakaoTalk);
  2410. }
  2411. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeKakaoStory]]];
  2412. if ([value isKindOfClass:[NSDictionary class]])
  2413. {
  2414. __setKakaoParams(value,params,SSDKPlatformSubTypeKakaoStory);
  2415. }
  2416. //支付宝好友
  2417. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliSocial]]];
  2418. if ([value isKindOfClass:[NSDictionary class]])
  2419. {
  2420. NSString *text = nil;
  2421. NSString *image = nil;
  2422. NSString *title = nil;
  2423. NSString *url = nil;
  2424. SSDKContentType type = SSDKContentTypeText;
  2425. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2426. {
  2427. text = [value objectForKey:@"text"];
  2428. }
  2429. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2430. {
  2431. image = [value objectForKey:@"imageUrl"];
  2432. }
  2433. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2434. {
  2435. title = [value objectForKey:@"title"];
  2436. }
  2437. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2438. {
  2439. url = [value objectForKey:@"url"];
  2440. }
  2441. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2442. {
  2443. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2444. }
  2445. [params SSDKSetupAliSocialParamsByText:text
  2446. image:img
  2447. title:title
  2448. url:[NSURL URLWithString:url]
  2449. type:type
  2450. platformType:SSDKPlatformTypeAliSocial];
  2451. }
  2452. //支付宝朋友圈
  2453. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliSocialTimeline]]];
  2454. if ([value isKindOfClass:[NSDictionary class]])
  2455. {
  2456. NSString *text = nil;
  2457. NSString *image = nil;
  2458. NSString *title = nil;
  2459. NSString *url = nil;
  2460. SSDKContentType type = SSDKContentTypeText;
  2461. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2462. {
  2463. text = [value objectForKey:@"text"];
  2464. }
  2465. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2466. {
  2467. image = [value objectForKey:@"imageUrl"];
  2468. }
  2469. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2470. {
  2471. title = [value objectForKey:@"title"];
  2472. }
  2473. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2474. {
  2475. url = [value objectForKey:@"url"];
  2476. }
  2477. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2478. {
  2479. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2480. }
  2481. [params SSDKSetupAliSocialParamsByText:text
  2482. image:img
  2483. title:title
  2484. url:[NSURL URLWithString:url]
  2485. type:type
  2486. platformType:SSDKPlatformTypeAliSocialTimeline];
  2487. }
  2488. //钉钉
  2489. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDingTalk]]];
  2490. if ([value isKindOfClass:[NSDictionary class]])
  2491. {
  2492. NSString *text = nil;
  2493. NSString *image = nil;
  2494. NSString *title = nil;
  2495. NSString *url = nil;
  2496. SSDKContentType type = SSDKContentTypeText;
  2497. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2498. {
  2499. text = [value objectForKey:@"text"];
  2500. }
  2501. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2502. {
  2503. image = [value objectForKey:@"imageUrl"];
  2504. }
  2505. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2506. {
  2507. title = [value objectForKey:@"title"];
  2508. }
  2509. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2510. {
  2511. url = [value objectForKey:@"url"];
  2512. }
  2513. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
  2514. {
  2515. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2516. }
  2517. [params SSDKSetupDingTalkParamsByText:text
  2518. image:image
  2519. title:title
  2520. url:[NSURL URLWithString:url]
  2521. type:type];
  2522. }
  2523. //Evernote
  2524. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeEvernote]]];
  2525. if ([value isKindOfClass:[NSDictionary class]])
  2526. {
  2527. NSString *text = nil;
  2528. NSString *title = nil;
  2529. NSMutableArray *images = [NSMutableArray array];
  2530. NSMutableArray *tags = [NSMutableArray array];
  2531. NSString *notebook = nil;
  2532. NSString *video = nil;
  2533. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2534. {
  2535. text = [value objectForKey:@"text"];
  2536. }
  2537. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2538. {
  2539. title = [value objectForKey:@"title"];
  2540. }
  2541. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2542. {
  2543. NSString *imgPath = [value objectForKey:@"imageUrl"];
  2544. SSDKImage *image = nil;
  2545. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2546. options:MOBFRegexOptionsNoOptions
  2547. inRange:NSMakeRange(0, imgPath.length)
  2548. withString:imgPath])
  2549. {
  2550. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
  2551. }
  2552. else
  2553. {
  2554. UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
  2555. image = [[SSDKImage alloc] initWithImage:localImg
  2556. format:SSDKImageFormatJpeg
  2557. settings:nil];
  2558. }
  2559. if (image)
  2560. {
  2561. [images addObject:imgPath];
  2562. }
  2563. else
  2564. {
  2565. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2566. }
  2567. }
  2568. else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
  2569. {
  2570. NSArray *paths = [value objectForKey:@"imageUrl"];
  2571. for (NSString *path in paths)
  2572. {
  2573. SSDKImage *image = nil;
  2574. if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
  2575. options:MOBFRegexOptionsNoOptions
  2576. inRange:NSMakeRange(0, path.length)
  2577. withString:path])
  2578. {
  2579. image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
  2580. }
  2581. else
  2582. {
  2583. UIImage *localImg = [UIImage imageWithContentsOfFile:path];
  2584. image = [[SSDKImage alloc] initWithImage:localImg
  2585. format:SSDKImageFormatJpeg
  2586. settings:nil];
  2587. }
  2588. if (image)
  2589. {
  2590. [images addObject:path];
  2591. }
  2592. else
  2593. {
  2594. NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
  2595. }
  2596. }
  2597. }
  2598. if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
  2599. {
  2600. notebook = [value objectForKey:@"notebook"];
  2601. }
  2602. id tagValue = [value objectForKey:@"tags"];
  2603. if ([tagValue isKindOfClass:[NSString class]])
  2604. {
  2605. [tags addObject:tagValue];
  2606. }
  2607. else if ([tagValue isKindOfClass:[NSArray class]])
  2608. {
  2609. tags = [tagValue mutableCopy];
  2610. }
  2611. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2612. {
  2613. video = [value objectForKey:@"videoPath"];
  2614. }
  2615. [params SSDKSetupEvernoteParamsByText:text
  2616. images:images
  2617. video:[NSURL URLWithString:video]
  2618. title:title
  2619. notebook:notebook
  2620. tags:tags
  2621. platformType:SSDKPlatformTypeEvernote];
  2622. }
  2623. //Youtube
  2624. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYouTube]]];
  2625. if ([value isKindOfClass:[NSDictionary class]])
  2626. {
  2627. NSString *desc = nil;
  2628. NSString *title = nil;
  2629. NSString *videoPath = nil;
  2630. NSMutableArray *tags = [NSMutableArray array];
  2631. SSDKPrivacyStatus privacyStatus = SSDKPrivacyStatusPrivate;
  2632. if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
  2633. {
  2634. desc = [value objectForKey:@"desc"];
  2635. }
  2636. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2637. {
  2638. title = [value objectForKey:@"title"];
  2639. }
  2640. id tagValue = [value objectForKey:@"tags"];
  2641. if ([tagValue isKindOfClass:[NSString class]])
  2642. {
  2643. NSArray *tagArr = [tagValue componentsSeparatedByString:@","];
  2644. [tags addObjectsFromArray:tagArr];
  2645. }
  2646. else if ([tagValue isKindOfClass:[NSArray class]])
  2647. {
  2648. tags = [tagValue mutableCopy];
  2649. }
  2650. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2651. {
  2652. videoPath = [value objectForKey:@"videoPath"];
  2653. }
  2654. if ([[value objectForKey:@"privateStatus"] integerValue] != 0) {
  2655. privacyStatus = [[value objectForKey:@"privateStatus"] integerValue];
  2656. }
  2657. [params SSDKSetupYouTubeParamsByVideo:videoPath
  2658. title:title
  2659. description:desc
  2660. tags:tags
  2661. privacyStatus:privacyStatus];
  2662. }
  2663. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeWework]]];
  2664. if ([value isKindOfClass:[NSDictionary class]])
  2665. {
  2666. NSString *text = nil;
  2667. NSMutableArray *images = [NSMutableArray array];
  2668. NSString *title = nil;
  2669. NSString *url = nil;
  2670. NSString *video = nil;
  2671. NSString *thumbImg = nil;
  2672. NSData *fileData = nil;
  2673. SSDKContentType type = SSDKContentTypeText;
  2674. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2675. {
  2676. text = [value objectForKey:@"text"];
  2677. }
  2678. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2679. {
  2680. NSString * image = [value objectForKey:@"imageUrl"];
  2681. if (image)
  2682. {
  2683. [images addObject:image];
  2684. }
  2685. }
  2686. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  2687. {
  2688. NSString *imagesStr = value[@"imageArray"];
  2689. [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
  2690. }
  2691. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2692. {
  2693. title = [value objectForKey:@"title"];
  2694. }
  2695. if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
  2696. {
  2697. url = [value objectForKey:@"url"];
  2698. }
  2699. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2700. {
  2701. video = [value objectForKey:@"videoPath"];
  2702. }
  2703. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  2704. {
  2705. thumbImg = [value objectForKey:@"thumbImageUrl"];
  2706. }
  2707. if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
  2708. {
  2709. fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"filePath"]];
  2710. }
  2711. [params SSDKSetupWeWorkParamsByText:text
  2712. title:title
  2713. url:[NSURL URLWithString:url]
  2714. thumbImage:thumbImg
  2715. image:images
  2716. video:video
  2717. fileData:fileData
  2718. type:type];
  2719. }
  2720. //Oasis
  2721. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeOasis]]];
  2722. if ([value isKindOfClass:[NSDictionary class]]) {
  2723. NSString *text = nil;
  2724. NSMutableArray *images = [NSMutableArray array];
  2725. NSString *title = nil;
  2726. NSMutableArray *assetLocalIds = [NSMutableArray array];
  2727. SSDKContentType type = SSDKContentTypeImage;
  2728. NSData *fileData = nil;
  2729. NSString *fileExt = nil;
  2730. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]]) {
  2731. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2732. }
  2733. if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
  2734. {
  2735. text = [value objectForKey:@"text"];
  2736. }
  2737. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2738. {
  2739. title = [value objectForKey:@"title"];
  2740. }
  2741. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2742. {
  2743. fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"videoPath"]];
  2744. }
  2745. if ([[value objectForKey:@"sourceFilePath"] isKindOfClass:[NSString class]])
  2746. {
  2747. fileExt = [value objectForKey:@"sourceFilePath"];
  2748. }
  2749. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2750. {
  2751. NSString * image = [value objectForKey:@"imageUrl"];
  2752. if (image)
  2753. {
  2754. [images addObject:image];
  2755. }
  2756. }
  2757. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  2758. {
  2759. NSString *imagesStr = value[@"imageArray"];
  2760. [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
  2761. }
  2762. if ([[value objectForKey:@"assetLocalIds"] isKindOfClass:[NSString class]])
  2763. {
  2764. NSString *assetLocalIdsStr = value[@"assetLocalIds"];
  2765. [assetLocalIds addObjectsFromArray:[assetLocalIdsStr componentsSeparatedByString:@","]];
  2766. }
  2767. [params SSDKSetupOasisParamsByTitle:title
  2768. text:text
  2769. assetLocalIds:assetLocalIds
  2770. image:images
  2771. video:fileData
  2772. fileExtension:fileExt
  2773. type:type];
  2774. }
  2775. //SnapChat
  2776. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSnapChat]]];
  2777. if ([value isKindOfClass:[NSDictionary class]]) {
  2778. NSMutableArray *images = [NSMutableArray array];
  2779. NSString *title = nil;
  2780. SSDKContentType type = SSDKContentTypeImage;
  2781. NSData *fileData = nil;
  2782. NSString *sticker = nil;
  2783. NSString *attachmentUrl = nil;
  2784. NSNumber *stickerAnimated = @0;
  2785. NSNumber *stickerRotation = @0;
  2786. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]]) {
  2787. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2788. }
  2789. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2790. {
  2791. title = [value objectForKey:@"title"];
  2792. }
  2793. if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
  2794. {
  2795. fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"videoPath"]];
  2796. }
  2797. if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
  2798. {
  2799. NSString * image = [value objectForKey:@"imageUrl"];
  2800. if (image)
  2801. {
  2802. [images addObject:image];
  2803. }
  2804. }
  2805. if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
  2806. {
  2807. NSString *imagesStr = value[@"imageArray"];
  2808. [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
  2809. }
  2810. if ([[value objectForKey:@"attachmentUrl"] isKindOfClass:[NSString class]])
  2811. {
  2812. attachmentUrl = value[@"attachmentUrl"];
  2813. }
  2814. if ([[value objectForKey:@"stickerImage"] isKindOfClass:[NSString class]])
  2815. {
  2816. sticker = value[@"stickerImage"];
  2817. }
  2818. if ([[value objectForKey:@"stickerRotation"] isKindOfClass:[NSNumber class]])
  2819. {
  2820. stickerRotation = value[@"stickerRotation"];
  2821. }
  2822. if ([[value objectForKey:@"stickerAnimated"] isKindOfClass:[NSNumber class]])
  2823. {
  2824. stickerAnimated = value[@"stickerAnimated"];
  2825. }
  2826. [params SSDKSetupSnapChatParamsByCaption:title
  2827. attachmentUrl:attachmentUrl
  2828. image:images
  2829. video:fileData
  2830. sticker:sticker
  2831. stickerAnimated:stickerAnimated.boolValue stickerRotation:stickerRotation.floatValue
  2832. cameraViewState:0
  2833. type:type];
  2834. }
  2835. //快手
  2836. value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeKuaiShou]]];
  2837. if ([value isKindOfClass:[NSDictionary class]]) {
  2838. NSString *title = nil;
  2839. NSString *desc = nil;
  2840. NSString *linkURL = nil;
  2841. NSString *thumbImage = nil;
  2842. NSString *openID = nil;
  2843. NSString *receiverOpenID = nil;
  2844. NSString *localIdentifier = nil;
  2845. NSArray *tags = nil;
  2846. NSString *extraInfo = nil;
  2847. SSDKContentType type = SSDKContentTypeMessage;
  2848. if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
  2849. {
  2850. title = [value objectForKey:@"title"];
  2851. }
  2852. if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
  2853. {
  2854. desc = [value objectForKey:@"desc"];
  2855. }
  2856. if ([[value objectForKey:@"linkUrl"] isKindOfClass:[NSString class]])
  2857. {
  2858. linkURL = [value objectForKey:@"linkUrl"];
  2859. }
  2860. if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
  2861. {
  2862. thumbImage = [value objectForKey:@"thumbImageUrl"];
  2863. }
  2864. if ([[value objectForKey:@"openID"] isKindOfClass:[NSString class]])
  2865. {
  2866. openID = [value objectForKey:@"openID"];
  2867. }
  2868. if ([[value objectForKey:@"receiverOpenID"] isKindOfClass:[NSString class]])
  2869. {
  2870. receiverOpenID = [value objectForKey:@"receiverOpenID"];
  2871. }
  2872. if ([[value objectForKey:@"localIdentifier"] isKindOfClass:[NSString class]])
  2873. {
  2874. localIdentifier = [value objectForKey:@"localIdentifier"];
  2875. }
  2876. if ([[value objectForKey:@"tags"] isKindOfClass:[NSArray class]])
  2877. {
  2878. tags = [value objectForKey:@"tags"];
  2879. }
  2880. if ([[value objectForKey:@"extraInfo"] isKindOfClass:[NSString class]])
  2881. {
  2882. extraInfo = [value objectForKey:@"extraInfo"];
  2883. }
  2884. if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]]) {
  2885. type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
  2886. }
  2887. [params SSDKSetupKuaiShouShareParamsByTitle:title desc:desc linkURL:linkURL thumbImage:thumbImage openID:openID receiverOpenID:receiverOpenID localIdentifier:localIdentifier tags:tags extraInfo:extraInfo type:type];
  2888. }
  2889. }
  2890. }
  2891. return params;
  2892. }
  2893. void __iosShareSDKRegisterAppAndSetPltformsConfig (void *appKey, void*configInfo)
  2894. {
  2895. NSMutableArray *activePlatforms = [NSMutableArray array];
  2896. NSMutableDictionary *platformsDict = [NSMutableDictionary dictionary];
  2897. if (configInfo)
  2898. {
  2899. platformsDict = __parseWithHashtable(configInfo);
  2900. }
  2901. for (id obj in [platformsDict allKeys])
  2902. {
  2903. NSInteger platformInterger = [obj integerValue];
  2904. NSDictionary *dict = [platformsDict objectForKey:[NSString stringWithFormat:@"%@",obj]];
  2905. if ([[dict objectForKey:@"Enable"] isEqualToString:@"true"])
  2906. {
  2907. [activePlatforms addObject:[NSNumber numberWithInteger:platformInterger]];
  2908. }
  2909. }
  2910. [ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
  2911. for (NSString *key in platformsDict.allKeys)
  2912. {
  2913. SSDKPlatformType type = key.integerValue;
  2914. NSDictionary *platformInfo = platformsDict[key];
  2915. if (type == SSDKPlatformTypeSinaWeibo)
  2916. {
  2917. [platformsRegister setupSinaWeiboWithAppkey:platformInfo[@"app_key"] appSecret:platformInfo[@"app_secret"] redirectUrl:platformInfo[@"redirect_uri"] universalLink:platformInfo[@"app_universalLink"]];
  2918. }
  2919. else if (type == SSDKPlatformTypeWechat ||
  2920. type == SSDKPlatformSubTypeWechatSession ||
  2921. type == SSDKPlatformSubTypeWechatTimeline ||
  2922. type == SSDKPlatformSubTypeWechatFav)
  2923. {
  2924. NSString *appsecret = platformInfo[@"app_secret"];
  2925. if ([appsecret isKindOfClass:[NSString class]] && appsecret.length == 0) {
  2926. appsecret = nil;
  2927. }
  2928. [platformsRegister setupWeChatWithAppId:platformInfo[@"app_id"] appSecret:appsecret universalLink:platformInfo[@"app_universalLink"]];
  2929. }
  2930. else if (type == SSDKPlatformTypeQQ ||
  2931. type == SSDKPlatformSubTypeQZone ||
  2932. type == SSDKPlatformSubTypeQQFriend)
  2933. {
  2934. [platformsRegister setupQQWithAppId:platformInfo[@"app_id"] appkey:platformInfo[@"app_key"] enableUniversalLink:YES universalLink:nil];
  2935. }
  2936. else if (type == SSDKPlatformTypeKakao ||
  2937. type == SSDKPlatformSubTypeKakaoTalk ||
  2938. type == SSDKPlatformSubTypeKakaoStory)
  2939. {
  2940. [platformsRegister setupKaKaoWithAppkey:platformInfo[@"app_key"] restApiKey:platformInfo[@"rest_api_key"] redirectUrl:platformInfo[@"redirect_uri"]];
  2941. }
  2942. else if (type == SSDKPlatformTypeYiXin ||
  2943. type == SSDKPlatformSubTypeYiXinSession ||
  2944. type == SSDKPlatformSubTypeYiXinTimeline ||
  2945. type == SSDKPlatformSubTypeYiXinFav)
  2946. {
  2947. [platformsRegister setupYiXinByAppId:platformInfo[@"app_id"] appSecret:platformInfo[@"app_secret"] redirectUrl:platformInfo[@"redirect_uri"]];
  2948. }
  2949. else if (type == SSDKPlatformTypeAliSocial || type == SSDKPlatformTypeAliSocialTimeline)
  2950. {
  2951. [platformsRegister setupAliSocialWithAppId:platformInfo[@"app_id"]];
  2952. }
  2953. else if(type == SSDKPlatformTypeSnapChat){
  2954. [platformsRegister setSnapChatClientId:platformInfo[@"client_id"] clientSecret:@"" redirectUrl:platformInfo[@"redirect_uri"]];
  2955. }else if(type == SSDKPlatformTypeKuaiShou){
  2956. [platformsRegister setupKuaiShouWithAppId:platformInfo[@"app_id"] appSecret:platformInfo[@"app_secret"] universalLink:platformInfo[@"app_universalLink"] delegate:[[UIApplication sharedApplication]delegate]];
  2957. }
  2958. else if(type == SSDKPlatformTypePocket){
  2959. [platformsRegister setupPocketWithConsumerKey:platformInfo[@"consumer_key"] redirectUrl:platformInfo[@"redirect_uri"]];
  2960. }
  2961. else if(type == SSDKPlatformTypeWework){
  2962. [platformsRegister setupWeWorkBySchema:platformInfo[@"schema"] appKey:platformInfo[@"app_Key"] agentId:platformInfo[@"agent_id"] appSecret:platformInfo[@"app_secret"]];
  2963. }
  2964. else if(type == SSDKPlatformTypeDingTalk){
  2965. [platformsRegister setupDingTalkWithAppId:platformInfo[@"shareApp_id"]];
  2966. [platformsRegister setupDingTalkAuthWithAppId:platformInfo[@"authApp_id"] appSecret:platformInfo[@"authApp_Secret"] redirectUrl:platformInfo[@"authApp_RedirectUri"]];
  2967. }
  2968. else if(type == SSDKPlatformTypeReddit){
  2969. [platformsRegister setupRedditByAppKey:platformInfo[@"app_key"] redirectUri:platformInfo[@"redirect_uri"]];
  2970. }
  2971. else if(type == SSDKPlatformTypeTumblr){
  2972. [platformsRegister setupTumblrByConsumerKey:platformInfo[@"consumer_key"] consumerSecret:platformInfo[@"consumer_secret"] redirectUrl:platformInfo[@"callback_url"]];
  2973. }
  2974. // else if(type == SSDKPlatformTypeYouTube){
  2975. // [platformsRegister setupYouTubeWithClientId:platformInfo[@"client_id"] clientSecret:platformInfo[@"client_secret"] redirectUrl:platformInfo[@"redirect_uri"]];
  2976. // }
  2977. else
  2978. {
  2979. NSMutableDictionary *dic = platformsRegister.platformsInfo;
  2980. dic[key] = platformInfo.mutableCopy;
  2981. }
  2982. }
  2983. }];
  2984. }
  2985. void __iosShareSDKAuthorize (int reqID, int platType, void *observer)
  2986. {
  2987. NSString *observerStr = nil;
  2988. if (observer)
  2989. {
  2990. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  2991. }
  2992. NSMutableDictionary *settings = [NSMutableDictionary dictionary];
  2993. //下面这个设置只对Facebook授权获取大icon有效
  2994. [settings setValue:@(CGSizeMake(600, 600)) forKey:@"size"];
  2995. [ShareSDK authorize:platType
  2996. settings:settings
  2997. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
  2998. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  2999. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"action"];
  3000. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3001. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  3002. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3003. if (state == SSDKResponseStateFail && error)
  3004. {
  3005. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3006. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3007. if ([[error userInfo] objectForKey:@"error_message"])
  3008. {
  3009. if ([[error userInfo] objectForKey:@"error_message"])
  3010. {
  3011. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3012. }
  3013. }
  3014. else if ([[error userInfo] objectForKey:@"user_data"])
  3015. {
  3016. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3017. if ([error_data objectForKey:@"error"])
  3018. {
  3019. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3020. }
  3021. if ([error_data objectForKey:@"error_code"])
  3022. {
  3023. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  3024. }
  3025. }
  3026. [resultDict setObject:errorDict forKey:@"res"];
  3027. }
  3028. if (state == SSDKResponseStateSuccess)
  3029. {
  3030. NSMutableDictionary *userData = [user rawData].mutableCopy;
  3031. userData[@"credential"] = [[user credential] rawData];
  3032. if (platType == SSDKPlatformTypeAppleAccount) {
  3033. userData[@"identify"] = user.credential.token;
  3034. userData[@"code"] = user.credential.authCode;
  3035. }
  3036. resultDict[@"res"] = userData;
  3037. }
  3038. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3039. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3040. }];
  3041. }
  3042. void __iosShareSDKCancelAuthorize (int platType)
  3043. {
  3044. [ShareSDK cancelAuthorize:platType result:nil];
  3045. }
  3046. bool __iosShareSDKHasAuthorized (int platType)
  3047. {
  3048. return [ShareSDK hasAuthorized:platType];
  3049. }
  3050. bool __iosShareSDKIsClientInstalled(int platType)
  3051. {
  3052. return [ShareSDK isClientInstalled:platType];
  3053. }
  3054. void __iosShareSDKGetUserInfo (int reqID, int platType, void *observer)
  3055. {
  3056. NSString *observerStr = nil;
  3057. if (observer)
  3058. {
  3059. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3060. }
  3061. [ShareSDK getUserInfo:platType
  3062. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
  3063. {
  3064. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3065. [resultDict setObject:[NSNumber numberWithInteger:8] forKey:@"action"];
  3066. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3067. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  3068. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3069. if (state == SSDKResponseStateFail && error)
  3070. {
  3071. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3072. [errorDict setObject:[NSNumber numberWithInteger:[error code]]
  3073. forKey:@"error_code"];
  3074. if ([[error userInfo] objectForKey:@"error_message"])
  3075. {
  3076. if ([[error userInfo] objectForKey:@"error_message"])
  3077. {
  3078. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3079. forKey:@"error_msg"];
  3080. }
  3081. }
  3082. else if ([[error userInfo] objectForKey:@"user_data"])
  3083. {
  3084. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3085. if ([error_data objectForKey:@"error"])
  3086. {
  3087. [errorDict setObject:[error_data objectForKey:@"error"]
  3088. forKey:@"error_msg"];
  3089. }
  3090. if ([error_data objectForKey:@"error_code"])
  3091. {
  3092. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3093. forKey:@"error_code"];
  3094. }
  3095. }
  3096. [resultDict setObject:errorDict forKey:@"res"];
  3097. }
  3098. if (state == SSDKResponseStateSuccess && user)
  3099. {
  3100. NSMutableDictionary *userData = [user rawData].mutableCopy;
  3101. userData[@"credential"] = [[user credential] rawData];
  3102. resultDict[@"res"] = userData;
  3103. // [resultDict setObject:[user rawData] forKey:@"res"];
  3104. }
  3105. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3106. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3107. }];
  3108. }
  3109. void __iosShareSDKShare (int reqID, int platType, void *content, void *observer)
  3110. {
  3111. NSString *observerStr = nil;
  3112. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  3113. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3114. if (content)
  3115. {
  3116. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  3117. shareParams = __getShareParamsWithString(contentStr);
  3118. }
  3119. [ShareSDK share:platType
  3120. parameters:shareParams
  3121. onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
  3122. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3123. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3124. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3125. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  3126. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3127. if (state == SSDKResponseStateFail && error)
  3128. {
  3129. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3130. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3131. if ([[error userInfo] objectForKey:@"error_message"])
  3132. {
  3133. if ([[error userInfo] objectForKey:@"error_message"])
  3134. {
  3135. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3136. forKey:@"error_msg"];
  3137. }
  3138. }
  3139. else if ([[error userInfo] objectForKey:@"user_data"])
  3140. {
  3141. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3142. if ([error_data objectForKey:@"error"])
  3143. {
  3144. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3145. }
  3146. if ([error_data objectForKey:@"error_code"])
  3147. {
  3148. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3149. forKey:@"error_code"];
  3150. }
  3151. }
  3152. [resultDict setObject:errorDict forKey:@"res"];
  3153. }
  3154. if (state == SSDKResponseStateSuccess)
  3155. {
  3156. if ([contentEntity rawData])
  3157. {
  3158. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3159. }
  3160. }
  3161. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3162. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3163. }];
  3164. }
  3165. void __iosShareSDKShareWithActivity (int reqID, int platType, void *content, void *observer)
  3166. {
  3167. NSString *observerStr = nil;
  3168. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  3169. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3170. if (content)
  3171. {
  3172. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  3173. shareParams = __getShareParamsWithString(contentStr);
  3174. }
  3175. [ShareSDK shareByActivityViewController:platType parameters:shareParams onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
  3176. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3177. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3178. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3179. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  3180. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3181. if (state == SSDKResponseStateFail && error)
  3182. {
  3183. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3184. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3185. if ([[error userInfo] objectForKey:@"error_message"])
  3186. {
  3187. if ([[error userInfo] objectForKey:@"error_message"])
  3188. {
  3189. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3190. forKey:@"error_msg"];
  3191. }
  3192. }
  3193. else if ([[error userInfo] objectForKey:@"user_data"])
  3194. {
  3195. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3196. if ([error_data objectForKey:@"error"])
  3197. {
  3198. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3199. }
  3200. if ([error_data objectForKey:@"error_code"])
  3201. {
  3202. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3203. forKey:@"error_code"];
  3204. }
  3205. }
  3206. [resultDict setObject:errorDict forKey:@"res"];
  3207. }
  3208. if (state == SSDKResponseStateSuccess)
  3209. {
  3210. if ([contentEntity rawData])
  3211. {
  3212. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3213. }
  3214. }
  3215. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3216. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3217. }];
  3218. }
  3219. void __iosShareSDKOneKeyShare (int reqID, void *platTypes, void *content, void *observer)
  3220. {
  3221. NSLog(@"OneKey share deprecate from v4.2.0");
  3222. }
  3223. void __iosShareSDKShareWithCommand (void *content, void *observer)
  3224. {
  3225. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3226. NSDictionary *customFields = nil;
  3227. if (content)
  3228. {
  3229. customFields = __parseWithHashtable(content);
  3230. }
  3231. /*
  3232. [ShareSDK getCommandText:customFields withComplete:^(NSString * _Nullable text, NSError * _Nullable error, void (^ _Nullable complete)(NSString * _Nullable)) {
  3233. NSString *command = [NSString stringWithFormat:@"【复制本段内容%@打开👉页面关键字👈去粘贴给好友】",text];
  3234. if(!error){
  3235. complete(command);
  3236. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3237. [resultDict setObject:[NSNumber numberWithInteger:11] forKey:@"action"];
  3238. [resultDict setObject:@{@"commandText":command} forKey:@"res"];
  3239. [resultDict setObject:@1 forKey:@"status"];
  3240. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3241. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3242. if (_refView)
  3243. {
  3244. //移除视图
  3245. [_refView removeFromSuperview];
  3246. }
  3247. }
  3248. }];
  3249. */
  3250. }
  3251. void __iosShareSDKShowShareMenu (int reqID, void *platTypes, void *content, int x, int y, void *observer)
  3252. {
  3253. NSArray *platTypesArr = nil;
  3254. NSMutableArray *actionSheetItems = [NSMutableArray array];
  3255. NSString *observerStr = nil;
  3256. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  3257. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3258. if (platTypes)
  3259. {
  3260. NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
  3261. platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
  3262. }
  3263. else
  3264. {
  3265. platTypesArr = [ShareSDK activePlatforms];
  3266. for (id obj in platTypesArr)
  3267. {
  3268. NSInteger platformInterger = [obj integerValue];
  3269. [actionSheetItems addObject:[NSNumber numberWithInteger:platformInterger]];
  3270. }
  3271. platTypesArr = [actionSheetItems mutableCopy];
  3272. }
  3273. if (content)
  3274. {
  3275. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  3276. shareParams = __getShareParamsWithString(contentStr);
  3277. }
  3278. if ([MOBFDevice isPad])
  3279. {
  3280. if (!_refView)
  3281. {
  3282. _refView = [[UIView alloc] initWithFrame:CGRectMake(x, y, 10, 10)];
  3283. }
  3284. [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_refView];
  3285. }
  3286. [ShareSDK showShareActionSheet:_refView customItems:platTypesArr shareParams:shareParams sheetConfiguration:nil onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  3287. {
  3288. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3289. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3290. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3291. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  3292. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3293. if (state == SSDKResponseStateFail && error)
  3294. {
  3295. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3296. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3297. if ([[error userInfo] objectForKey:@"error_message"])
  3298. {
  3299. if ([[error userInfo] objectForKey:@"error_message"])
  3300. {
  3301. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3302. forKey:@"error_msg"];
  3303. }
  3304. }
  3305. else if ([[error userInfo] objectForKey:@"user_data"])
  3306. {
  3307. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3308. if ([error_data objectForKey:@"error"])
  3309. {
  3310. [errorDict setObject:[error_data objectForKey:@"error"]
  3311. forKey:@"error_msg"];
  3312. }
  3313. else if ([error_data objectForKey:@"error_message"])
  3314. {
  3315. [errorDict setObject:[error_data objectForKey:@"error_message"]
  3316. forKey:@"error_msg"];
  3317. }
  3318. if ([error_data objectForKey:@"error_code"])
  3319. {
  3320. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3321. forKey:@"error_code"];
  3322. }
  3323. }
  3324. [resultDict setObject:errorDict forKey:@"res"];
  3325. }
  3326. if (state == SSDKResponseStateSuccess)
  3327. {
  3328. if ([contentEntity rawData])
  3329. {
  3330. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3331. }
  3332. }
  3333. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3334. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3335. if (_refView)
  3336. {
  3337. //移除视图
  3338. [_refView removeFromSuperview];
  3339. }
  3340. }
  3341. }];
  3342. }
  3343. void __iosShareSDKShowShareView (int reqID, int platType, void *content, void *observer)
  3344. {
  3345. NSString *observerStr = nil;
  3346. NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
  3347. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3348. if (content)
  3349. {
  3350. NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
  3351. shareParams = __getShareParamsWithString(contentStr);
  3352. }
  3353. [ShareSDK showShareEditor:platType otherPlatforms:nil shareParams:shareParams editorConfiguration:nil onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  3354. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3355. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3356. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3357. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  3358. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3359. if (state == SSDKResponseStateFail && error)
  3360. {
  3361. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3362. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3363. if ([[error userInfo] objectForKey:@"error_message"])
  3364. {
  3365. if ([[error userInfo] objectForKey:@"error_message"])
  3366. {
  3367. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3368. }
  3369. }
  3370. else if ([[error userInfo] objectForKey:@"user_data"])
  3371. {
  3372. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3373. if ([error_data objectForKey:@"error"])
  3374. {
  3375. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3376. }
  3377. if ([error_data objectForKey:@"error_code"])
  3378. {
  3379. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  3380. }
  3381. }
  3382. [resultDict setObject:errorDict forKey:@"res"];
  3383. }
  3384. if (state == SSDKResponseStateSuccess)
  3385. {
  3386. if ([contentEntity rawData])
  3387. {
  3388. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3389. }
  3390. }
  3391. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3392. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3393. }];
  3394. }
  3395. void __iosShareSDKGetFriendsList (int reqID, int platType, int count , int page, void *observer)
  3396. {
  3397. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3398. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3399. NSInteger cursor = page;
  3400. NSInteger size = count;
  3401. if (shareType == SSDKPlatformTypeTwitter)
  3402. {
  3403. cursor = -1;
  3404. }
  3405. [ShareSDK getFriends:platType
  3406. cursor:cursor
  3407. size:size
  3408. onStateChanged:^(SSDKResponseState state, SSEFriendsPaging *paging, NSError *error)
  3409. {
  3410. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3411. [resultDict setObject:[NSNumber numberWithInteger:2] forKey:@"action"];
  3412. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3413. [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"platform"];
  3414. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3415. if (state == SSDKResponseStateFail && error)
  3416. {
  3417. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3418. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3419. if ([[error userInfo] objectForKey:@"error_message"])
  3420. {
  3421. if ([[error userInfo] objectForKey:@"error_message"])
  3422. {
  3423. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3424. }
  3425. }
  3426. else if ([[error userInfo] objectForKey:@"user_data"])
  3427. {
  3428. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3429. if ([error_data objectForKey:@"error"])
  3430. {
  3431. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3432. }
  3433. if ([error_data objectForKey:@"error_code"])
  3434. {
  3435. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  3436. }
  3437. }
  3438. [resultDict setObject:errorDict forKey:@"res"];
  3439. }
  3440. if (state == SSDKResponseStateSuccess)
  3441. {
  3442. if (paging)
  3443. {
  3444. NSArray *friends = [NSArray array];
  3445. friends = paging.users;
  3446. NSMutableDictionary *resDict = [NSMutableDictionary dictionary];
  3447. [resDict setObject:friends forKey:@"users"];
  3448. [resDict setObject:[NSNumber numberWithInteger:paging.prevCursor] forKey:@"prev_cursor"];
  3449. [resDict setObject:[NSNumber numberWithInteger:paging.nextCursor] forKey:@"next_cursor"];
  3450. [resDict setObject:[NSNumber numberWithUnsignedInteger:paging.total] forKey:@"total"];
  3451. [resDict setObject:[NSNumber numberWithBool:paging.hasNext] forKey:@"has_next"];
  3452. [resultDict setObject:resDict forKey:@"res"];
  3453. }
  3454. }
  3455. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3456. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3457. }];
  3458. }
  3459. char * __StringCopy( const char *string)
  3460. {
  3461. if (string != NULL)
  3462. {
  3463. char *copyStr = (char*)malloc(strlen(string)+1);
  3464. strcpy(copyStr, string);
  3465. return copyStr;
  3466. }
  3467. else
  3468. {
  3469. return NULL;
  3470. }
  3471. }
  3472. extern const char* __iosShareSDKGetCredential (int platType)
  3473. {
  3474. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3475. SSDKUser *userInfo = [ShareSDK currentUser:shareType];
  3476. SSDKCredential *credential = userInfo.credential;
  3477. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3478. [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"type"];
  3479. if ([credential available])
  3480. {
  3481. if ([credential uid])
  3482. {
  3483. [resultDict setObject:[credential uid] forKey:@"uid"];
  3484. }
  3485. if ([credential token])
  3486. {
  3487. [resultDict setObject:[credential token] forKey:@"token"];
  3488. }
  3489. if ([credential secret])
  3490. {
  3491. [resultDict setObject:[credential secret] forKey:@"secret"];
  3492. }
  3493. if ([credential expired])
  3494. {
  3495. [resultDict setObject:@(credential.expired) forKey:@"expired"];
  3496. }
  3497. [resultDict setObject:[NSNumber numberWithBool:[credential available]] forKey:@"available"];
  3498. }
  3499. else
  3500. {
  3501. [resultDict setObject:[NSNumber numberWithBool:NO] forKey:@"available"];
  3502. [resultDict setObject:@"Invalid Authorization" forKey:@"error"];
  3503. }
  3504. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3505. return __StringCopy([resultStr UTF8String]);
  3506. }
  3507. void __iosShareSDKFollowFriend (int reqID, int platType,void *account, void *observer)
  3508. {
  3509. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3510. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3511. SSDKUser *user = [[SSDKUser alloc]init];
  3512. user.uid = [NSString stringWithCString:account encoding:NSUTF8StringEncoding];
  3513. [ShareSDK addFriend:shareType
  3514. user:user
  3515. onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
  3516. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3517. [resultDict setObject:[NSNumber numberWithInteger:6] forKey:@"action"];
  3518. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3519. [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"platform"];
  3520. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3521. if (state == SSDKResponseStateFail && error)
  3522. {
  3523. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3524. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3525. if ([[error userInfo] objectForKey:@"error_message"])
  3526. {
  3527. if ([[error userInfo] objectForKey:@"error_message"])
  3528. {
  3529. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3530. }
  3531. }
  3532. else if ([[error userInfo] objectForKey:@"user_data"])
  3533. {
  3534. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3535. if ([error_data objectForKey:@"error"])
  3536. {
  3537. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3538. }
  3539. if ([error_data objectForKey:@"error_code"])
  3540. {
  3541. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3542. forKey:@"error_code"];
  3543. }
  3544. }
  3545. [resultDict setObject:errorDict forKey:@"res"];
  3546. }
  3547. if (state == SSDKResponseStateSuccess)
  3548. {
  3549. NSDictionary *userRawdata = [NSDictionary dictionaryWithDictionary:[user rawData]];
  3550. [resultDict setObject:userRawdata forKey:@"res"];
  3551. }
  3552. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3553. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3554. }];
  3555. }
  3556. void __iosShareSDKShareWithContentName(int reqID, int platType, void *contentName, void *customHashtable, void *observer)
  3557. {
  3558. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3559. NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
  3560. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3561. NSDictionary *customFields = nil;
  3562. if (customHashtable)
  3563. {
  3564. customFields = __parseWithHashtable(customHashtable);
  3565. }
  3566. [ShareSDK shareWithContentName:contentNodeName
  3567. platform:shareType
  3568. customFields:customFields
  3569. onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
  3570. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3571. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3572. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3573. [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
  3574. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3575. if (state == SSDKResponseStateFail && error)
  3576. {
  3577. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3578. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3579. if ([[error userInfo] objectForKey:@"error_message"])
  3580. {
  3581. if ([[error userInfo] objectForKey:@"error_message"])
  3582. {
  3583. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3584. forKey:@"error_msg"];
  3585. }
  3586. }
  3587. else if ([[error userInfo] objectForKey:@"user_data"])
  3588. {
  3589. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3590. if ([error_data objectForKey:@"error"])
  3591. {
  3592. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3593. }
  3594. if ([error_data objectForKey:@"error_code"])
  3595. {
  3596. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3597. forKey:@"error_code"];
  3598. }
  3599. }
  3600. else if([[error userInfo] objectForKey:@"error_msg"])
  3601. {
  3602. if ([[error userInfo] objectForKey:@"error_msg"])
  3603. {
  3604. [errorDict setObject:[[error userInfo] objectForKey:@"error_msg"]
  3605. forKey:@"error_msg"];
  3606. }
  3607. }
  3608. [resultDict setObject:errorDict forKey:@"res"];
  3609. }
  3610. if (state == SSDKResponseStateSuccess)
  3611. {
  3612. if ([contentEntity rawData])
  3613. {
  3614. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3615. }
  3616. }
  3617. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3618. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3619. }];
  3620. }
  3621. void __iosShareSDKShowShareMenuWithContentName(int reqID, void *contentName, void *customHashtable, void *platTypes, int x, int y, void *observer)
  3622. {
  3623. NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
  3624. NSDictionary *customFields = nil;
  3625. if (customHashtable)
  3626. {
  3627. customFields = __parseWithHashtable(customHashtable);
  3628. }
  3629. NSArray *platTypesArr = nil;
  3630. NSMutableArray *actionSheetItems = [NSMutableArray array];
  3631. NSString *observerStr = nil;
  3632. observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3633. if (platTypes)
  3634. {
  3635. NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
  3636. platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
  3637. }
  3638. else
  3639. {
  3640. platTypesArr = [ShareSDK activePlatforms];
  3641. for (id obj in platTypesArr)
  3642. {
  3643. NSInteger platformInterger = [obj integerValue];
  3644. [actionSheetItems addObject:[NSNumber numberWithInteger:platformInterger]];
  3645. }
  3646. platTypesArr = [actionSheetItems mutableCopy];
  3647. }
  3648. if ([MOBFDevice isPad])
  3649. {
  3650. if (!_refView)
  3651. {
  3652. _refView = [[UIView alloc] initWithFrame:CGRectMake(x, y, 10, 10)];
  3653. }
  3654. [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_refView];
  3655. }
  3656. NSMutableDictionary *params = [ShareSDK getShareParamsWithContentName:contentNodeName customFields:customFields];
  3657. [ShareSDK showShareActionSheet:_refView
  3658. customItems:platTypesArr
  3659. shareParams:params
  3660. sheetConfiguration:nil
  3661. onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  3662. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3663. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3664. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3665. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  3666. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3667. if (state == SSDKResponseStateFail && error)
  3668. {
  3669. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3670. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3671. if ([[error userInfo] objectForKey:@"error_message"])
  3672. {
  3673. if ([[error userInfo] objectForKey:@"error_message"])
  3674. {
  3675. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
  3676. forKey:@"error_msg"];
  3677. }
  3678. }
  3679. else if ([[error userInfo] objectForKey:@"user_data"])
  3680. {
  3681. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3682. if ([error_data objectForKey:@"error"])
  3683. {
  3684. [errorDict setObject:[error_data objectForKey:@"error"]
  3685. forKey:@"error_msg"];
  3686. }
  3687. else if ([error_data objectForKey:@"error_message"])
  3688. {
  3689. [errorDict setObject:[error_data objectForKey:@"error_message"]
  3690. forKey:@"error_msg"];
  3691. }
  3692. if ([error_data objectForKey:@"error_code"])
  3693. {
  3694. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
  3695. forKey:@"error_code"];
  3696. }
  3697. }
  3698. [resultDict setObject:errorDict forKey:@"res"];
  3699. }
  3700. if (state == SSDKResponseStateSuccess)
  3701. {
  3702. if ([contentEntity rawData])
  3703. {
  3704. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3705. }
  3706. }
  3707. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3708. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3709. if (_refView)
  3710. {
  3711. //移除视图
  3712. [_refView removeFromSuperview];
  3713. }
  3714. }];
  3715. }
  3716. void __iosShareSDKShowShareViewWithContentName(int reqID, int platType, void *contentName, void *customHashtable, void *observer)
  3717. {
  3718. SSDKPlatformType shareType = (SSDKPlatformType)platType;
  3719. NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
  3720. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3721. NSDictionary *customFields = nil;
  3722. if (customHashtable)
  3723. {
  3724. customFields = __parseWithHashtable(customHashtable);
  3725. }
  3726. NSMutableDictionary *params = [ShareSDK getShareParamsWithContentName:contentNodeName customFields:customFields];
  3727. [ShareSDK showShareEditor:shareType otherPlatforms:nil shareParams:params editorConfiguration:nil onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
  3728. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3729. [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
  3730. [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
  3731. [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
  3732. [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
  3733. if (state == SSDKResponseStateFail && error)
  3734. {
  3735. NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
  3736. [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
  3737. if ([[error userInfo] objectForKey:@"error_message"])
  3738. {
  3739. if ([[error userInfo] objectForKey:@"error_message"])
  3740. {
  3741. [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
  3742. }
  3743. }
  3744. else if ([[error userInfo] objectForKey:@"user_data"])
  3745. {
  3746. NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
  3747. if ([error_data objectForKey:@"error"])
  3748. {
  3749. [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
  3750. }
  3751. if ([error_data objectForKey:@"error_code"])
  3752. {
  3753. [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
  3754. }
  3755. }
  3756. [resultDict setObject:errorDict forKey:@"res"];
  3757. }
  3758. if (state == SSDKResponseStateSuccess)
  3759. {
  3760. if ([contentEntity rawData])
  3761. {
  3762. [resultDict setObject:[contentEntity rawData] forKey:@"res"];
  3763. }
  3764. }
  3765. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3766. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3767. }];
  3768. }
  3769. bool __iosShareSDKOpenMiniProgram(void *userName, void *path, int miniProgramType)
  3770. {
  3771. NSString *userNameStr = nil;
  3772. NSString *pathStr = nil;
  3773. if (userName != NULL)
  3774. {
  3775. userNameStr = [NSString stringWithCString:userName encoding:NSUTF8StringEncoding];
  3776. }
  3777. if (path != NULL)
  3778. {
  3779. pathStr = [NSString stringWithCString:path encoding:NSUTF8StringEncoding];
  3780. }
  3781. NSLog(@"%@,%@,%d",userNameStr,pathStr,miniProgramType);
  3782. Class WeChatConnector = NSClassFromString(@"WeChatConnector");
  3783. if (WeChatConnector == NULL)
  3784. {
  3785. NSLog(@"Warn: WeChatConnector not exsit !");
  3786. }
  3787. ((void(*)(id,SEL,NSString *,NSString *,NSInteger,id,id,id))objc_msgSend)(WeChatConnector,NSSelectorFromString(@"openMiniProgramWithUserName:path:miniProgramType:extMsg:extDic:complete:"),userNameStr,pathStr,miniProgramType,nil,nil,nil);
  3788. return YES;
  3789. }
  3790. static void (^ __iosShareSDKRequestTokenGetUserInfo) (NSString *, NSString *) = nil;
  3791. void __iosShareSDKWXRequestSendTokenToGetUser(void * uid, void *token){
  3792. if (__iosShareSDKRequestTokenGetUserInfo) {
  3793. NSString *ocUid = [NSString stringWithCString:uid encoding:NSUTF8StringEncoding];
  3794. NSString *ocToken = [NSString stringWithCString:token encoding:NSUTF8StringEncoding];
  3795. __iosShareSDKRequestTokenGetUserInfo(ocUid,ocToken);
  3796. }
  3797. __iosShareSDKRequestTokenGetUserInfo = nil;
  3798. }
  3799. void __iosShareSDKWXRequestToken(void *observer){
  3800. Class wechatConnectorClass = NSClassFromString(@"WeChatConnector");
  3801. if (wechatConnectorClass) {
  3802. __iosShareSDKRequestTokenGetUserInfo = nil;
  3803. __block NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3804. void(^block)(id,id) = ^(NSString *authCode, void(^getUserInfo)(NSString *uid,NSString *token)) {
  3805. __iosShareSDKRequestTokenGetUserInfo = getUserInfo;
  3806. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3807. [resultDict setObject:[NSNumber numberWithInteger:10] forKey:@"action"];
  3808. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"status"];
  3809. [resultDict setObject:[NSNumber numberWithInteger:0] forKey:@"isRefreshToken"];
  3810. [resultDict setObject:authCode forKey:@"authCode"];
  3811. [resultDict setObject:[resultDict copy] forKey:@"res"];
  3812. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3813. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3814. };
  3815. ((void (*)(id, SEL,id))objc_msgSend)(wechatConnectorClass,sel_registerName("setRequestAuthTokenOperation:"), block);
  3816. }
  3817. }
  3818. static void (^ __iosShareSDKRefreshTokenGetUserInfo) (NSString *) = nil;
  3819. void __iosShareSDKWXRefreshSendTokenToGetUser(void *token){
  3820. if (__iosShareSDKRefreshTokenGetUserInfo) {
  3821. NSString *ocToken = [NSString stringWithCString:token encoding:NSUTF8StringEncoding];
  3822. __iosShareSDKRefreshTokenGetUserInfo(ocToken);
  3823. }
  3824. __iosShareSDKRefreshTokenGetUserInfo = nil;
  3825. }
  3826. void __iosShareSDKWXRefreshRequestToken(void *observer){
  3827. Class wechatConnectorClass = NSClassFromString(@"WeChatConnector");
  3828. if (wechatConnectorClass) {
  3829. __iosShareSDKRefreshTokenGetUserInfo = nil;
  3830. __block NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3831. void(^block)(id,id) = ^(NSString *uid, void(^getUserInfo)(NSString *token)) {
  3832. __iosShareSDKRefreshTokenGetUserInfo = getUserInfo;
  3833. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3834. [resultDict setObject:[NSNumber numberWithInteger:10] forKey:@"action"];
  3835. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"status"];
  3836. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"isRefreshToken"];
  3837. [resultDict setObject:uid forKey:@"uid"];
  3838. [resultDict setObject:[resultDict copy] forKey:@"res"];
  3839. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3840. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3841. };
  3842. ((void (*)(id, SEL,id))objc_msgSend)(wechatConnectorClass,sel_registerName("setRefreshAuthTokenOperation:"), block);
  3843. }
  3844. }
  3845. static inline NSUInteger SSDKhexStrToInt(NSString *str) {
  3846. uint32_t result = 0;
  3847. sscanf([str UTF8String], "%X", &result);
  3848. return result;
  3849. }
  3850. static BOOL SSDKhexStrToRGBA(NSString *str,
  3851. CGFloat *r, CGFloat *g, CGFloat *b, CGFloat *a) {
  3852. NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
  3853. str = [[str stringByTrimmingCharactersInSet:set] uppercaseString];
  3854. if ([str hasPrefix:@"#"]) {
  3855. str = [str substringFromIndex:1];
  3856. } else if ([str hasPrefix:@"0X"]) {
  3857. str = [str substringFromIndex:2];
  3858. }
  3859. NSUInteger length = [str length];
  3860. if (length != 3 && length != 4 && length != 6 && length != 8) {
  3861. return NO;
  3862. }
  3863. if (length < 5) {
  3864. *r = SSDKhexStrToInt([str substringWithRange:NSMakeRange(0, 1)]) / 255.0f;
  3865. *g = SSDKhexStrToInt([str substringWithRange:NSMakeRange(1, 1)]) / 255.0f;
  3866. *b = SSDKhexStrToInt([str substringWithRange:NSMakeRange(2, 1)]) / 255.0f;
  3867. if (length == 4) *a = SSDKhexStrToInt([str substringWithRange:NSMakeRange(3, 1)]) / 255.0f;
  3868. else *a = 1;
  3869. } else {
  3870. *r = SSDKhexStrToInt([str substringWithRange:NSMakeRange(0, 2)]) / 255.0f;
  3871. *g = SSDKhexStrToInt([str substringWithRange:NSMakeRange(2, 2)]) / 255.0f;
  3872. *b = SSDKhexStrToInt([str substringWithRange:NSMakeRange(4, 2)]) / 255.0f;
  3873. if (length == 8) *a = SSDKhexStrToInt([str substringWithRange:NSMakeRange(6, 2)]) / 255.0f;
  3874. else *a = 1;
  3875. }
  3876. return YES;
  3877. }
  3878. static UIColor * SSDKColorWithHexStr(NSString * hexStr){
  3879. CGFloat r, g, b, a;
  3880. if (SSDKhexStrToRGBA(hexStr, &r, &g, &b, &a)) {
  3881. if (@available(iOS 10.0, *)) {
  3882. return [UIColor colorWithDisplayP3Red:r green:g blue:b alpha:a];
  3883. }else{
  3884. return [UIColor colorWithRed:r green:g blue:b alpha:a];
  3885. }
  3886. }
  3887. return [UIColor whiteColor];
  3888. }
  3889. extern void __iosMobSDKGetPolicy(int type , void * language, void * observer){
  3890. NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
  3891. NSString *languageStr = [NSString stringWithCString:language encoding:NSUTF8StringEncoding];
  3892. [MobSDK getPrivacyPolicy:[NSString stringWithFormat:@"%d",type] language:languageStr compeletion:^(NSDictionary * dic, NSError *error){
  3893. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3894. if (!error) {
  3895. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"status"];
  3896. }else{
  3897. [resultDict setObject:[NSNumber numberWithInteger:2] forKey:@"status"];
  3898. }
  3899. [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"action"];
  3900. [resultDict setObject:@{@"url":dic[@"content"]?:@""} forKey:@"res"];
  3901. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3902. UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
  3903. }];
  3904. }
  3905. extern void __iosMobSDKSubmitPolicyGrantResult(int granted){
  3906. [MobSDK uploadPrivacyPermissionStatus:granted onResult:nil];
  3907. }
  3908. extern void __iosMobSDKSetAllowDialog(int allow){
  3909. // [MobSDK setAllowShowPrivacyWindow:allow];
  3910. }
  3911. extern void __iosMobSDKSetPolicyUI(void * backgroundColorRes , void * positiveBtnColorRes, void * negativeBtnColorRes){
  3912. // NSString *backgroundColorResString = [NSString stringWithCString:backgroundColorRes encoding:NSUTF8StringEncoding];
  3913. // NSString *positiveBtnColorResString = [NSString stringWithCString:positiveBtnColorRes encoding:NSUTF8StringEncoding];
  3914. // NSString *negativeBtnColorResString = [NSString stringWithCString:negativeBtnColorRes encoding:NSUTF8StringEncoding];
  3915. // [MobSDK setPrivacyBackgroundColor:SSDKColorWithHexStr(backgroundColorResString) operationButtonColor:@[SSDKColorWithHexStr(negativeBtnColorResString),SSDKColorWithHexStr(positiveBtnColorResString)]];
  3916. }
  3917. char* SSDKMakeCString(NSString *str) {
  3918. const char* string = [str UTF8String];
  3919. if (string == NULL) {
  3920. return NULL;
  3921. }
  3922. char* res = (char*)malloc(strlen(string) + 1);
  3923. strcpy(res, string);
  3924. return res;
  3925. }
  3926. extern char * __iosMobSDKGetCurrentLanguage(){
  3927. NSString * language = [NSLocale preferredLanguages][0];
  3928. return SSDKMakeCString(language);
  3929. }
  3930. #if defined (__cplusplus)
  3931. }
  3932. #endif
  3933. @implementation ShareSDKUnity3DBridge
  3934. @end
  3935. @implementation UnityAppController (ShareSDKRestoreSceneInit)
  3936. + (void)initialize
  3937. {
  3938. //[ShareSDK setRestoreSceneDelegate:[ShareSDKUnityRestoreSceneCallback defaultCallBack]];
  3939. [ShareSDK setBanGetIdfa:NO];
  3940. }
  3941. @end
  3942. /*
  3943. @implementation ShareSDKUnityRestoreSceneCallback
  3944. + (ShareSDKUnityRestoreSceneCallback *)defaultCallBack
  3945. {
  3946. static ShareSDKUnityRestoreSceneCallback * _instance = nil;
  3947. static dispatch_once_t onceToken;
  3948. dispatch_once(&onceToken, ^{
  3949. _instance = [[ShareSDKUnityRestoreSceneCallback alloc] init];
  3950. });
  3951. return _instance;
  3952. }
  3953. #pragma mark - ISSERestoreSceneDelegate
  3954. - (void)ISSEWillAlertCommand:(NSDictionary *)parameters error:(NSError *)error
  3955. {
  3956. if(parameters.count > 0){
  3957. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3958. [resultDict setObject:parameters forKey:@"res"];
  3959. NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3960. UIPasteboard *board = [UIPasteboard generalPasteboard];
  3961. board.string = @"";
  3962. UnitySendMessage([@"ShareSDKRestoreScene" UTF8String], "_AnalysisCommandCallBack", [resultStr UTF8String]);
  3963. }
  3964. }
  3965. - (void)ISSEWillRestoreScene:(SSERestoreScene *)scene Restore:(void (^)(BOOL))restoreHandler
  3966. {
  3967. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3968. if (scene.path.length > 0)
  3969. {
  3970. resultDict[@"path"] = scene.path;
  3971. }
  3972. if (scene.params && scene.params.count > 0)
  3973. {
  3974. resultDict[@"params"] = scene.params;
  3975. }
  3976. NSString *resultStr = @"";
  3977. if (resultDict.count > 0)
  3978. {
  3979. resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3980. }
  3981. UnitySendMessage([@"ShareSDKRestoreScene" UTF8String], "_RestoreCallBack", [resultStr UTF8String]);
  3982. }
  3983. - (void)ISSEWillRestoreScene:(SSERestoreScene *)scene error:(NSError *)error
  3984. {
  3985. NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
  3986. if (scene.path.length > 0)
  3987. {
  3988. resultDict[@"path"] = scene.path;
  3989. }
  3990. if (scene.params && scene.params.count > 0)
  3991. {
  3992. resultDict[@"params"] = scene.params;
  3993. }
  3994. NSString *resultStr = @"";
  3995. if (resultDict.count > 0)
  3996. {
  3997. resultStr = [MOBFJson jsonStringFromObject:resultDict];
  3998. }
  3999. UnitySendMessage([@"ShareSDKRestoreScene" UTF8String], "_RestoreCallBack", [resultStr UTF8String]);
  4000. }
  4001. @end
  4002. __attribute__((constructor)) static void _SSDKUnityiOSApplicationExcImp(){
  4003. static dispatch_once_t onceToken;
  4004. dispatch_once(&onceToken, ^{
  4005. SEL sel = sel_registerName("addChannelWithSdkName:channel:");
  4006. Method method = class_getClassMethod([MobSDK class],sel) ;
  4007. if (method && method_getImplementation(method) != _objc_msgForward) {
  4008. ((void (*)(id, SEL,id,id))objc_msgSend)([MobSDK class],sel,@"SHARESDK",@"2");
  4009. }
  4010. });
  4011. }
  4012. */