12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469 |
- //
- // ShareSDKUnity3DBridge.m
- // Unity-iPhone
- //
- // Created by 陈 剑东 on 15/7/28.
- // Copyright (c) 2015年 mob. All rights reserved.
- //
- #import "ShareSDKUnity3DBridge.h"
- #import <objc/message.h>
- #import <ShareSDK/ShareSDK.h>
- #import <ShareSDKUI/ShareSDKUI.h>
- #import <ShareSDK/ShareSDK+Base.h>
- #import <MOBFoundation/MOBFJson.h>
- #import <MOBFoundation/MOBFoundation.h>
- #import <MOBFoundation/MobSDK+Privacy.h>
- #import <ShareSDKExtension/ShareSDK+Extension.h>
- #import <ShareSDKExtension/SSEFriendsPaging.h>
- #import <ShareSDKExtension/SSEShareHelper.h>
- #import <ShareSDKConfigFile/ShareSDK+XML.h>
- #import <ShareSDK/NSMutableDictionary+SSDKShare.h>
- //#import <ShareSDKExtension/SSERestoreSceneHeader.h>
- //static ShareSDKUnityRestoreSceneCallback *_callback = nil;
- static UIView *_refView = nil;
- #if defined (__cplusplus)
- extern "C" {
- #endif
-
- /**
- * @brief 配置SDK并初始化
- *
- * @param appKey ShareSDK的AppKey
- * @param configInfo 配置信息
- */
- extern void __iosShareSDKRegisterAppAndSetPltformsConfig (void *appKey, void*configInfo);
-
- /**
- * 用户授权
- *
- * @param reqID 流水号
- * @param platType 平台类型
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKAuthorize (int reqID, int platType, void *observer);
-
- /**
- * @brief 取消用户授权
- *
- * @param platType 平台类型
- */
- extern void __iosShareSDKCancelAuthorize (int platType);
-
- /**
- * @brief 判断用户是否授权
- *
- * @param platType 平台类型
- *
- * @return YES 表示已经授权,NO 表示尚未授权
- */
- extern bool __iosShareSDKHasAuthorized (int platType);
-
- /**
- * @brief 检测是否安装客户端
- *
- * @param platType 平台类型
- *
- * @return YES 表示已经安装,NO 表示尚未安装
- */
- extern bool __iosShareSDKIsClientInstalled (int platType);
-
- /**
- * @brief 获取用户信息
- *
- * @param reqID 流水号
- * @param platType 平台类型
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKGetUserInfo (int reqID, int platType, void *observer);
-
- /**
- * @brief 分享内容
- *
- * @param reqID 流水号
- * @param platType 平台类型
- * @param content 分享内容
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShare (int reqID, int platType, void *content, void *observer);
- /**
- * @brief 系统分享内容
- *
- * @param reqID 流水号
- * @param platType 平台类型
- * @param content 分享内容
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShareWithActivity (int reqID, int platType, void *content, void *observer);
-
- /**
- * @brief 一键分享内容
- *
- * @param reqID 流水号
- * @param platTypes 平台类型列表
- * @param content 分享内容
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKOneKeyShare (int reqID, void *platTypes, void *content, void *observer);
-
- /**
- * @brief 口令分享
- *
- * @param content 分享内容
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShareWithCommand (void *content, void *observer);
-
- /**
- * @brief 显示分享菜单
- *
- * @param reqID 流水号
- * @param platTypes 平台类型列表
- * @param content 分享内容
- * @param x 弹出菜单的箭头的横坐标,仅用于iPad
- * @param y 弹出菜单的箭头的纵坐标,仅用于iPad
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShowShareMenu (int reqID, void *platTypes, void *content, int x, int y, void *observer);
-
- /**
- * @brief 显示分享编辑界面
- *
- * @param reqID 流水号
- * @param platType 平台类型
- * @param content 分享内容
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShowShareView (int reqID, int platType, void *content, void *observer);
-
- /**
- * @brief 获取授权用户好友列表
- *
- * @param reqID 流水号
- * @param platType 平台类型
- * @param count 单页好友数量
- * @param page 页码/游标cusor
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKGetFriendsList (int reqID, int platType, int count , int page, void *observer);
-
- /**
- * @brief 获取授权信息
- *
- * @param platType 平台类型
- * @param observer 观察回调对象名称
- */
- extern const char* __iosShareSDKGetCredential (int platType);
-
- /**
- * @brief 关注/添加好友
- *
- * @param platType 平台类型
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKFollowFriend (int reqID, int platType, void *account, void *observer);
-
-
- /**
- * @brief 根据配置文件分享
- *
- * @param reqID 流水号
- * @param contentName 配置文件节点标识
- * @param customHashtable 自定义字段表
- * @param platType 平台类型
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShareWithContentName(int reqID,
- int platType,
- void *contentName,
- void *customHashtable,
- void *observer);
-
- /**
- * @brief 根据配置文件展示分享菜单
- *
- * @param reqID 流水号
- * @param contentName 配置文件节点标识
- * @param customHashtable 自定义字段表
- * @param platTypes 平台类型列表
- * @param x 弹出菜单的箭头的横坐标,仅用于iPad
- * @param y 弹出菜单的箭头的纵坐标,仅用于iPad
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShowShareMenuWithContentName(int reqID,
- void *contentName,
- void *customHashtable,
- void *platTypes,
- int x,
- int y,
- void *observer);
-
- /**
- * @brief 根据配置文件展示分享编辑界面
- *
- * @param reqID 流水号
- * @param contentName 配置文件节点标识
- * @param customHashtable 自定义字段表
- * @param platType 平台类型
- * @param observer 观察回调对象名称
- */
- extern void __iosShareSDKShowShareViewWithContentName(int reqID,
- int platType,
- void *contentName,
- void *customHashtable,
- void *observer);
-
-
- /**
- 打开小程序
- @param userName 小程序userName
- @param path 路径
- @param miniProgramType 版本
- @return 是否成功打开
- */
- extern bool __iosShareSDKOpenMiniProgram(void *userName, void *path, int miniProgramType);
-
- extern void __iosShareSDKWXRefreshRequestToken(void *observer);
- extern void __iosShareSDKWXRefreshSendTokenToGetUser(void *token);
- extern void __iosShareSDKWXRequestToken(void *observer);
- extern void __iosShareSDKWXRequestSendTokenToGetUser(void * uid, void *token);
-
- extern void __iosMobSDKGetPolicy(int type, void * language , void * observer);
- extern void __iosMobSDKSubmitPolicyGrantResult(int granted);
- extern void __iosMobSDKSetAllowDialog(int allow);
- extern void __iosMobSDKSetPolicyUI(void * backgroundColorRes , void * positiveBtnColorRes, void * negativeBtnColorRes);
-
- extern char * __iosMobSDKGetCurrentLanguage();
-
- #if defined (__cplusplus)
- }
- #endif
- #if defined (__cplusplus)
- extern "C" {
- #endif
-
- NSMutableDictionary *__parseWithHashtable (void*configInfo)
- {
- NSString *confCs = [NSString stringWithCString:configInfo encoding:NSUTF8StringEncoding];
- NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[MOBFJson objectFromJSONString:confCs]];
- return dic;
- }
-
- SSDKPlatformType __convertContentType(NSInteger type)
- {
- switch (type)
- {
- case 0:
- return SSDKContentTypeAuto;
- case 1:
- return SSDKContentTypeText;
- case 2:
- return SSDKContentTypeImage;
- case 4:
- return SSDKContentTypeWebPage;
- case 5:
- return SSDKContentTypeAudio;
- case 6:
- return SSDKContentTypeVideo;
- case 7:
- return SSDKContentTypeApp;
- case 8:
- return SSDKContentTypeFile;
- case 9:
- return SSDKContentTypeImage;
- case 10:
- return SSDKContentTypeMiniProgram;
- case 11:
- return SSDKContentTypeMessage;
- default:
- return SSDKContentTypeText;
- }
- }
-
- void __setWechatParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
- {
- NSString *text = nil;
- NSString *title = nil;
- NSString *url = nil;
- NSString *thumbImg = nil;
- NSString *image = nil;
- NSString *musicFileUrl = nil;
- NSString *extInfo = nil;
- NSData *fileData = nil;
- NSData *emoData = nil;
- NSString *sourceFileExtension = nil;
- NSData *sourceFileData = nil;
-
- //小程序参数
- NSString *path = nil;
- NSString *hdThumbImage = nil;
- NSString *username = nil;
- BOOL withShareTicket = NO;
- int miniProgramType = 0;
-
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
- {
- thumbImg = [value objectForKey:@"thumbImageUrl"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"musicUrl"] isKindOfClass:[NSString class]])
- {
- musicFileUrl = [value objectForKey:@"musicUrl"];
- }
- if ([[value objectForKey:@"extInfoPath"] isKindOfClass:[NSString class]])
- {
- extInfo = [value objectForKey:@"extInfoPath"];
- }
- if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
- {
- fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"filePath"]];
- }
- if ([[value objectForKey:@"emotionPath"] isKindOfClass:[NSString class]])
- {
- emoData = [NSData dataWithContentsOfFile:[value objectForKey:@"emotionPath"]];
- }
-
- if ([[value objectForKey:@"sourceFileExtension"] isKindOfClass:[NSString class]])
- {
- sourceFileExtension = [value objectForKey:@"sourceFileExtension"];
- }
- if ([[value objectForKey:@"sourceFilePath"] isKindOfClass:[NSString class]])
- {
- sourceFileData = [NSData dataWithContentsOfFile:[value objectForKey:@"sourceFilePath"]];
- }
-
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- if ([[value objectForKey:@"wxUserName"] isKindOfClass:[NSString class]])
- {
- username = [value objectForKey:@"wxUserName"];
- }
- if ([[value objectForKey:@"wxPath"] isKindOfClass:[NSString class]])
- {
- path = [value objectForKey:@"wxPath"];
- }
- if ([[value objectForKey:@"wxMiniProgramHdThumbImage"] isKindOfClass:[NSString class]])
- {
- hdThumbImage = [value objectForKey:@"wxMiniProgramHdThumbImage"];
- }
- if ([[value objectForKey:@"wxWithShareTicket"] isKindOfClass:[NSNumber class]])
- {
- withShareTicket = [[value objectForKey:@"wxWithShareTicket"] boolValue];
- }
- if ([[value objectForKey:@"wxMiniProgramType"] isKindOfClass:[NSNumber class]])
- {
- miniProgramType = [[value objectForKey:@"wxMiniProgramType"] intValue];
- }
-
- if (type == SSDKContentTypeMiniProgram)
- {
- [params SSDKSetupWeChatMiniProgramShareParamsByTitle:title
- description:text
- webpageUrl:[NSURL URLWithString:url]
- path:path
- thumbImage:thumbImg
- hdThumbImage:hdThumbImage
- userName:username
- withShareTicket:withShareTicket
- miniProgramType:miniProgramType
- forPlatformSubType:subType];
- }
- else
- {
- [params SSDKSetupWeChatParamsByText:text
- title:title
- url:[NSURL URLWithString:url]
- thumbImage:thumbImg
- image:image
- musicFileURL:[NSURL URLWithString:musicFileUrl]
- extInfo:extInfo
- fileData:fileData
- emoticonData:emoData
- sourceFileExtension:sourceFileExtension
- sourceFileData:sourceFileData
- type:type
- forPlatformSubType:subType];
- }
- }
-
- void __setQQParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
- {
- NSString *text = nil;
- NSString *title = nil;
- NSString *url = nil;
- NSString *thumbImg = nil;
- NSString *audioUrl = nil;
- NSString *videoUrl = nil;
- NSMutableArray *images = [NSMutableArray array];
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
- {
- thumbImg = [value objectForKey:@"thumbImageUrl"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- if ([[value objectForKey:@"audioPath"] isKindOfClass:[NSString class]])
- {
- audioUrl = [value objectForKey:@"audioPath"];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- videoUrl = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *imagesStr = [value objectForKey:@"imageArray"];
- images = [imagesStr componentsSeparatedByString:@","].mutableCopy;
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
-
-
- //小程序参数
- NSString *miniProgramPath = nil;
- NSString *miniProgramHdThumbImage = nil;
- NSString *miniProgramAppID = nil;
- NSString *miniProgramWebpageUrl = nil;
- int miniProgramType = 3;
- if ([[value objectForKey:@"qqMiniProgramPath"] isKindOfClass:[NSString class]])
- {
- miniProgramPath = [value objectForKey:@"qqMiniProgramPath"];
- }
-
- if ([[value objectForKey:@"qqMiniProgramHdThumbImage"] isKindOfClass:[NSString class]])
- {
- miniProgramHdThumbImage = [value objectForKey:@"qqMiniProgramHdThumbImage"];
- }
- if (miniProgramHdThumbImage == nil)
- {
- if (images.count > 0 && [images[0] isKindOfClass:[NSString class]])
- {
- miniProgramHdThumbImage = images[0];
- }
- else
- {
- miniProgramHdThumbImage = thumbImg;
- }
- }
- if ([[value objectForKey:@"qqMiniProgramAppID"] isKindOfClass:[NSString class]])
- {
- miniProgramAppID = [value objectForKey:@"qqMiniProgramAppID"];
- }
- if ([[value objectForKey:@"qqMiniProgramWebpageUrl"] isKindOfClass:[NSString class]])
- {
- miniProgramWebpageUrl = [value objectForKey:@"qqMiniProgramWebpageUrl"];
- }
- if ([[value objectForKey:@"qqMiniprogramType"] isKindOfClass:[NSNumber class]])
- {
- miniProgramType = [[value objectForKey:@"qqMiniprogramType"] intValue];
- }
-
-
- if (type == SSDKContentTypeMiniProgram)
- {
- [params SSDKSetupQQMiniProgramShareParamsByTitle:title
- description:text
- webpageUrl:[NSURL URLWithString:url]
- hdThumbImage:miniProgramHdThumbImage
- miniAppID:miniProgramAppID
- miniPath:miniProgramPath
- miniWebpageUrl:miniProgramWebpageUrl
- miniProgramType:miniProgramType
- forPlatformSubType:subType];
- }
- else
- {
-
- [params SSDKSetupQQParamsByText:text
- title:title
- url:[NSURL URLWithString:url]
- audioFlashURL:[NSURL URLWithString:audioUrl]
- videoFlashURL:[NSURL URLWithString:videoUrl]
- thumbImage:thumbImg
- images:images
- type:type
- forPlatformSubType:subType];
- }
- }
-
- void __setYixinParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
- {
- NSString *text = nil;
- NSString *title = nil;
- NSString *url = nil;
- NSString *thumbImg = nil;
- NSString *image = nil;
- NSString *musicFileURL = nil;
- NSString *extInfo = nil;
- NSString *fileDataPath = nil;
- NSString *comment = nil;
- NSString *toUserId = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
- {
- thumbImg = [value objectForKey:@"thumbImageUrl"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"musicUrl"] isKindOfClass:[NSString class]])
- {
- musicFileURL = [value objectForKey:@"musicUrl"];
- }
- if ([[value objectForKey:@"extInfoPath"] isKindOfClass:[NSString class]])
- {
- extInfo = [value objectForKey:@"extInfoPath"];
- }
- if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
- {
- fileDataPath = [value objectForKey:@"filePath"];
- }
- if ([[value objectForKey:@"comment"] isKindOfClass:[NSString class]])
- {
- comment = [value objectForKey:@"comment"];
- }
- if ([[value objectForKey:@"toUserID"] isKindOfClass:[NSString class]])
- {
- toUserId = [value objectForKey:@"toUserID"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupYiXinParamsByText:text
- title:title
- url:[NSURL URLWithString:url]
- thumbImage:thumbImg
- image:image
- musicFileURL:[NSURL URLWithString:musicFileURL]
- musicLowBandUrl:nil
- musicDataUrl:nil
- musicLowBandDataUrl:nil
- extInfo:extInfo
- fileData:fileDataPath
- videoLowBandUrl:nil
- comment:comment
- toUserId:toUserId
- type:type
- forPlatformSubType:subType];
- }
-
- void __setKakaoParams(NSDictionary *value,NSMutableDictionary *params,SSDKPlatformType subType)
- {
- NSString *text = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *title = nil;
- NSString *url = nil;
- NSString *permission = nil;
- BOOL enableShare;
- NSDictionary *androidExecParam = nil;
- NSDictionary *iphoneExecParams = nil;
- NSString *templateId = nil;
- NSDictionary *templateArgs = nil;
-
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
-
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
- for (NSString *path in paths)
- {
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
- }
- }
-
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"permission"] isKindOfClass:[NSString class]])
- {
- permission = [value objectForKey:@"permission"];
- }
- if ([[value objectForKey:@"enableShare"] boolValue])
- {
- enableShare = YES;
- }
- if ([[value objectForKey:@"androidExecParam"] isKindOfClass:[NSDictionary class]])
- {
- androidExecParam = [value objectForKey:@"androidExecParam"];
- }
- if ([[value objectForKey:@"iphoneExecParam"] isKindOfClass:[NSDictionary class]])
- {
- iphoneExecParams = [value objectForKey:@"iphoneExecParam"];
- }
- if ([[value objectForKey:@"templateArgs"] isKindOfClass:[NSDictionary class]])
- {
- templateArgs = [value objectForKey:@"templateArgs"];
- }
- if ([[value objectForKey:@"templateId"] isKindOfClass:[NSString class]])
- {
- templateId = [value objectForKey:@"templateId"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
-
- }
- if (subType == SSDKPlatformSubTypeKakaoStory)
- {
- [params SSDKSetupKakaoStoryParamsByContent:text
- title:title
- images:images
- url:[NSURL URLWithString:url]
- permission:permission.intValue
- sharable:enableShare
- androidExecParam:androidExecParam
- iosExecParam:iphoneExecParams type:type];
- }
- else
- {
- [params SSDKSetupKaKaoTalkParamsByUrl:[NSURL URLWithString:url]
- templateId:templateId
- templateArgs:templateArgs];
- }
- }
-
-
- NSMutableDictionary *__getShareParamsWithString(NSString *dataStr)
- {
- NSMutableDictionary *params = [NSMutableDictionary dictionary];
-
- NSMutableArray *imageArray = [NSMutableArray array];
- NSString *text = nil;
- NSString *title = nil;
- NSString *url = nil;
- NSInteger shareAction = 0;
-
- SSDKContentType type = SSDKContentTypeText;
-
- NSDictionary *shareParamsDic = [MOBFJson objectFromJSONString:dataStr];
- if (shareParamsDic)
- {
-
- if ([[shareParamsDic objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [shareParamsDic objectForKey:@"text"];
- }
-
- id img = [shareParamsDic objectForKey:@"imageUrl"];
- if ([img isKindOfClass:[NSString class]])
- {
- NSString *imgPath = img;
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
-
- [imageArray addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
- }
- else if([img isKindOfClass:[NSArray class]])
- {
- NSArray *paths = [img copy];
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
-
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [imageArray addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
- }
- }
- NSArray *imgArray = nil;
- if ([[shareParamsDic objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *imagesStr = shareParamsDic[@"imageArray"];
- imgArray = [imagesStr componentsSeparatedByString:@","];
- }
-
- if(imgArray && imgArray.count > 0)
- {
- NSArray *paths = [imgArray copy];
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
-
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [imageArray addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
- }
- }
-
- if ([[shareParamsDic objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [shareParamsDic objectForKey:@"title"];
-
- }
-
- if ([[shareParamsDic objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [shareParamsDic objectForKey:@"url"];
-
- }
-
- if ([[shareParamsDic objectForKey:@"shareActionMode"] isKindOfClass:[NSNumber class]])
- {
- shareAction = [[shareParamsDic objectForKey:@"shareActionMode"] integerValue];
- [params setValue:shareAction == 1 ? @(SSDKDouyinOpenSDKShareTypeShareContentToIM) : @(SSDKDouyinOpenSDKShareTypePublishMedia) forKey:SSDKDouYinShareActionKey];
- }
-
- if ([[shareParamsDic objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[shareParamsDic objectForKey:@"shareType"] integerValue]);
- }
-
- NSURL *urlPath;
- if ([url containsString:@"http://"] || [url containsString:@"https://"]) {
- urlPath = [NSURL URLWithString:url];
- }else if(url != nil){
- urlPath = [NSURL fileURLWithPath:url];
- }
- [params SSDKSetupShareParamsByText:text
- images:imageArray
- url:urlPath
- title:title
- type:type];
-
- NSDictionary *customizeShareParams = [shareParamsDic objectForKey:@"customizeShareParams"];
-
- if (customizeShareParams && [[customizeShareParams allKeys] count] > 0)
- {
- //新浪微博
- id value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSinaWeibo]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *title = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *url = nil;
- double lat = 0;
- double lng = 0;
- NSString *objID = nil;
- NSString *video = nil;
- SSDKContentType type = SSDKContentTypeWebPage;
-
- BOOL linkCard = NO;
- NSString *cardTitle = nil;
- NSString *cardSummary = nil;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString * image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"latitude"] isKindOfClass:[NSString class]])
- {
- lat = [[value objectForKey:@"latitude"] doubleValue];
- }
- if ([[value objectForKey:@"longitude"] isKindOfClass:[NSString class]])
- {
- lng = [[value objectForKey:@"longitude"] doubleValue];
- }
- if ([[value objectForKey:@"objectID"] isKindOfClass:[NSString class]])
- {
- objID = [value objectForKey:@"objectID"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- video = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *imagesStr = value[@"imageArray"];
- [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
- }
-
- if ([[value objectForKey:@"sina_linkCard"] isKindOfClass:[NSNumber class]])
- {
- linkCard = [[value objectForKey:@"sina_linkCard"] integerValue]>0?YES:NO;
- }
- if ([[value objectForKey:@"sina_cardTitle"] isKindOfClass:[NSString class]])
- {
- cardTitle = [value objectForKey:@"sina_cardTitle"];
- }
- if ([[value objectForKey:@"sina_cardSummary"] isKindOfClass:[NSString class]])
- {
- cardSummary = [value objectForKey:@"sina_cardSummary"];
- }
-
- if (linkCard == YES)
- {
- /*
- [params SSDKSetupSinaWeiboLinkCardShareParamsByText:text
- cardTitle:cardTitle
- cardSummary:cardSummary
- images:images
- url:[NSURL URLWithString:url]];
- */
- }
- else
- {
- [params SSDKSetupSinaWeiboShareParamsByText:text
- title:title
- images:images
- video:video
- url:[NSURL URLWithString:url]
- latitude:lat
- longitude:lng
- objectID:objID
- isShareToStory:NO
- type:type];
- }
- }
-
-
- //QQ系列
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeQQFriend]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setQQParams(value,params,SSDKPlatformSubTypeQQFriend);
-
- }
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeQZone]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setQQParams(value,params,SSDKPlatformSubTypeQZone);
- }
-
- //微信系列
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatSession]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setWechatParams(value,params,SSDKPlatformSubTypeWechatSession);
- }
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatTimeline]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setWechatParams(value,params,SSDKPlatformSubTypeWechatTimeline);
- }
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeWechatFav]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setWechatParams(value,params,SSDKPlatformSubTypeWechatFav);
- }
-
- //Douyin
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDouyin]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSArray *asset_localIdsArray = nil;
- NSString *douyin_hashtag = nil;
- NSDictionary *douyin_extraInfo = nil;
- NSInteger dyShareAction = 0;
- SSDKContentType type = SSDKContentTypeImage;
-
- if ([[value objectForKey:@"asset_localIds"] isKindOfClass:[NSArray class]])
- {
- asset_localIdsArray = [value objectForKey:@"asset_localIds"];
- }
-
- if ([[value objectForKey:@"douyin_hashtag"] isKindOfClass:[NSString class]])
- {
- douyin_hashtag = [value objectForKey:@"douyin_hashtag"];
- }
-
- if ([[value objectForKey:@"douyin_extraInfo"] isKindOfClass:[NSDictionary class]])
- {
- douyin_extraInfo = [value objectForKey:@"douyin_extraInfo"];
- }
-
- if ([[value objectForKey:@"shareActionMode"] isKindOfClass:[NSNumber class]])
- {
- dyShareAction = [[value objectForKey:@"shareActionMode"] integerValue];
- }
-
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupDouyinParamesByAssetLocalIds:asset_localIdsArray hashtag:douyin_hashtag extraInfo:douyin_extraInfo shareActionMode:dyShareAction == 1 ? SSDKDouyinOpenSDKShareTypeShareContentToIM : SSDKDouyinOpenSDKShareTypePublishMedia type:type];
- }
- //TikTok
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTikTok]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *tiktok_hashtag = nil;
- NSDictionary *tiktok_extraInfo = nil;
- NSArray *asset_localIdsArray = nil;
- NSArray *imageArray = nil;
- NSString *videoPath = nil;
- SSDKContentType type = SSDKContentTypeText;
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *paths = [value objectForKey:@"imageArray"];
- if (paths)
- {
- imageArray = [paths componentsSeparatedByString:@","];
- }
- }
- if ([[value objectForKey:@"asset_localIds"] isKindOfClass:[NSArray class]])
- {
- asset_localIdsArray = [value objectForKey:@"asset_localIds"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- videoPath = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"tiktok_hashtag"] isKindOfClass:[NSString class]])
- {
- tiktok_hashtag = [value objectForKey:@"tiktok_hashtag"];
- }
- if ([[value objectForKey:@"tiktok_extraInfo"] isKindOfClass:[NSDictionary class]])
- {
- tiktok_extraInfo = [value objectForKey:@"tiktok_extraInfo"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- if(imageArray || url){
- [params SSDKSetupShareParamsByText:nil images:imageArray url:[NSURL URLWithString:url] title:nil type:type];
- }else if(asset_localIdsArray){
- [params SSDKSetupTikTokParamesByAssetLocalIds:asset_localIdsArray hashtag:tiktok_hashtag extraInfo:tiktok_extraInfo type:type];
- }
- }
-
- //Facebook
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFacebook]]];
-
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *title = nil;
- NSString *urlDesc = nil;
- NSString *attachmentPath = nil;
- NSString *quote = nil;
- NSString *hashtag = nil;
- NSInteger shareType = 1;
- SSDKContentType type = SSDKContentTypeText;
- NSArray *shareTypes = nil;
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"urlDescription"] isKindOfClass:[NSString class]])
- {
- urlDesc = [value objectForKey:@"urlDescription"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
- {
- attachmentPath = [value objectForKey:@"attachmentPath"];
- }
- if ([[value objectForKey:@"quote"] isKindOfClass:[NSString class]])
- {
- quote = [value objectForKey:@"quote"];
- }
- if ([[value objectForKey:@"hashtag"] isKindOfClass:[NSString class]])
- {
- hashtag = [value objectForKey:@"hashtag"];
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *paths = [value objectForKey:@"imageArray"];
- if (paths)
- {
- [images addObjectsFromArray:[paths componentsSeparatedByString:@","]];
- }
- }
- if ([[value objectForKey:@"facebook_shareType"] isKindOfClass:[NSNumber class]])
- {
- shareType = [[value objectForKey:@"facebook_shareType"] integerValue];
- }
- if ([[value objectForKey:@"facebook_shareTypes"] isKindOfClass:[NSArray class]])
- {
- shareTypes = [value objectForKey:@"facebook_shareTypes"];
- }
- if (!shareTypes) {
- [params SSDKSetupFacebookParamsByText:text
- image:images
- url:[NSURL URLWithString:url]
- urlTitle:title
- urlName:urlDesc
- attachementUrl:[NSURL URLWithString:attachmentPath]
- hashtag:hashtag
- quote:quote
- shareType:shareType
- type:type];
- }else{
- [params SSDKSetupFacebookParamsByText:text
- image:images
- url:[NSURL URLWithString:url]
- urlTitle:title
- urlName:urlDesc
- attachementUrl:[NSURL URLWithString:attachmentPath]
- hashtag:hashtag
- quote:quote
- sortShareTypes:shareTypes
- type:type];
- }
-
-
- NSArray * imageAssets = nil;
- if ([[value objectForKey:@"facebook_imageasset"] isKindOfClass:[NSString class]]) {
- imageAssets = [(NSString *)[value objectForKey:@"facebook_imageasset"] componentsSeparatedByString:@","];
- }
- NSArray * videoAsset = nil;
- if ([[value objectForKey:@"facebook_videoasset"] isKindOfClass:[NSString class]]) {
- videoAsset = [value objectForKey:@"facebook_videoasset"];
- }
- [params SSDKSetupFacebookParamsByImagePHAsset:imageAssets videoPHAsset:videoAsset];
- }
-
- //FacebookMessenger
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFacebookMessenger]]];
-
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *title = nil;
- NSString *url = nil;
- NSString *gif = nil;
- NSString *audio = nil;
- NSString *quote = nil;
- NSString *video = nil;
- NSMutableArray *images = [NSMutableArray array];
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- video = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *paths = [value objectForKey:@"imageArray"];
- if (paths)
- {
- [images addObject:[paths componentsSeparatedByString:@","]];
- }
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupFacebookMessengerParamsByTitle:title url:[NSURL URLWithString:url] images:images video:video type:type];
- }
-
- //Twitter
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTwitter]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSMutableArray *images = [NSMutableArray array];
- double lat;
- double lng;
- SSDKContentType type = SSDKContentTypeText;
- NSString *videoPath = nil;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
-
- if([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
-
- NSString *paths = [value objectForKey:@"imageArray"];
-
- for (NSString *path in [paths componentsSeparatedByString:@","])
- {
-
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
-
- if ([[value objectForKey:@"latitude"] isKindOfClass:[NSNumber class]])
- {
- lat = [[value objectForKey:@"latitude"] doubleValue];
- }
- if ([[value objectForKey:@"longitude"] isKindOfClass:[NSNumber class]])
- {
- lng = [[value objectForKey:@"longitude"] doubleValue];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- videoPath = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupTwitterParamsByText:text images:images video:[NSURL URLWithString:videoPath] latitude:lat longitude:lng type:type];
-
- }
-
- //YinXiang
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYinXiang]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *title = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSMutableArray *tags = [NSMutableArray array];
- NSString *notebook = nil;
- NSString *video = nil;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
- for (NSString *path in paths)
- {
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
- if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
- {
- notebook = [value objectForKey:@"notebook"];
- }
- id tagValue = [value objectForKey:@"tags"];
- if ([tagValue isKindOfClass:[NSString class]])
- {
- [tags addObject:tagValue];
- }
- else if ([tagValue isKindOfClass:[NSArray class]])
- {
- tags = [tagValue mutableCopy];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- video = [value objectForKey:@"videoPath"];
- }
-
- [params SSDKSetupEvernoteParamsByText:text
- images:images
- video:[NSURL URLWithString:video]
- title:title
- notebook:notebook
- tags:tags
- platformType:SSDKPlatformTypeYinXiang];
- }
-
- //GooglePlus
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeGooglePlus]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
-
- NSString *text = nil;
- NSString *url = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupGooglePlusParamsByText:text
- url:[NSURL URLWithString:url]
- type:type];
-
- }
-
- //Instagram
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeInstagram]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *image = nil;
- CGFloat menuX;
- CGFloat menuY;
- SSDKContentType type = SSDKContentTypeText;
- NSString *videoPath = nil;
-
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"menuX"] isKindOfClass:[NSString class]])
- {
- menuX = [[value objectForKey:@"menuX"] floatValue];
- }
- if ([[value objectForKey:@"menuY"] isKindOfClass:[NSString class]])
- {
- menuX = [[value objectForKey:@"menuY"] floatValue];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- videoPath = [value objectForKey:@"videoPath"];
- }
-
- CGPoint point = CGPointMake(menuX, menuY);
-
- if (type == SSDKContentTypeVideo)
- {
- [params SSDKSetupInstagramByVideo:[NSURL URLWithString:videoPath]];
- }
- else
- {
- [params SSDKSetupInstagramByImage:image menuDisplayPoint:point];
- }
- }
-
- //LinkedIn
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeLinkedIn]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSString *url = nil;
- NSString *urlDesc = nil;
- NSString *visibility = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"urlDescription"] isKindOfClass:[NSString class]])
- {
- urlDesc = [value objectForKey:@"urlDescription"];
- }
- if ([[value objectForKey:@"visibility"] isKindOfClass:[NSString class]])
- {
- visibility = [value objectForKey:@"visibility"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupLinkedInParamsByText:text
- image:image
- url:[NSURL URLWithString:url]
- title:title
- urlDesc:urlDesc
- visibility:visibility
- type:type];
- }
- //Tumblr
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeTumblr]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSString *url = nil;
- NSString *blogName = nil;
- NSString *mediaDataPath = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"blogName"] isKindOfClass:[NSString class]])
- {
- blogName = [value objectForKey:@"blogName"];
- }
- if ([[value objectForKey:@"mediaDataPath"] isKindOfClass:[NSString class]])
- {
- mediaDataPath = [value objectForKey:@"mediaDataPath"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- // if(type == 5 || type == 6){
- // [params SSDKSetupTumblrShareParamsByTitle:title
- // dataPath:mediaDataPath
- // type:type];
- // }else{
- [params SSDKSetupTumblrParamsByText:text
- image:image
- url:[NSURL URLWithString:url]
- title:title
- blogName:blogName
- type:type];
- // }
- }
-
- //Reddit
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeReddit]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSString *url = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupShareParamsByText:text
- images:image
- url:[NSURL URLWithString:url]
- title:title
- type:type];
- }
- //Mail
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeMail]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *title = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSMutableArray *attachments = [NSMutableArray array];
- NSMutableArray *recipients = [NSMutableArray array];
- NSMutableArray *ccRecipients = [NSMutableArray array];
- NSMutableArray *bccRecipients = [NSMutableArray array];
- SSDKContentType type = SSDKContentTypeText;
-
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
-
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
-
- if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
- {
- NSData *attachementsData = [NSData dataWithContentsOfFile:[value objectForKey:@"attachmentPath"]];
- [attachments addObject:attachementsData];
- }
- else if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSArray class]])
- {
- NSArray *paths = [value objectForKey:@"attachmentPath"];
- for (NSString *path in paths)
- {
-
- NSData *attachementsData = [NSData dataWithContentsOfFile:path];
- [attachments addObject:attachementsData];
- }
- }
- if ([[value objectForKey:@"recipients"] isKindOfClass:[NSString class]])
- {
- [recipients addObject:[value objectForKey:@"recipients"]];
- }
- else if ([[value objectForKey:@"recipients"] isKindOfClass:[NSArray class]])
- {
- NSArray *recipientsArray = [value objectForKey:@"recipients"];
- for (NSString *recipient in recipientsArray)
- {
- [recipients addObject:recipient];
- }
- }
- if ([[value objectForKey:@"ccRecipients"] isKindOfClass:[NSString class]])
- {
- [ccRecipients addObject:[value objectForKey:@"ccRecipients"]];
- }
- else if ([[value objectForKey:@"ccRecipients"] isKindOfClass:[NSArray class]])
- {
- NSArray *recipientsArray = [value objectForKey:@"ccRecipients"];
- for (NSString *recipient in recipientsArray)
- {
- [ccRecipients addObject:recipient];
- }
- }
- if ([[value objectForKey:@"bccRecipients"] isKindOfClass:[NSString class]])
- {
- [bccRecipients addObject:[value objectForKey:@"bccRecipients"]];
- }
- else if ([[value objectForKey:@"bccRecipients"] isKindOfClass:[NSArray class]])
- {
- NSArray *recipientsArray = [value objectForKey:@"bccRecipients"];
- for (NSString *recipient in recipientsArray)
- {
- [bccRecipients addObject:recipient];
- }
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupMailParamsByText:text
- title:title
- images:images
- attachments:attachments
- recipients:recipients
- ccRecipients:ccRecipients
- bccRecipients:bccRecipients
- type:type];
- }
-
- //SMS
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSMS]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *title = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSMutableArray *attachments = [NSMutableArray array];
- NSMutableArray *recipients = [NSMutableArray array];
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
-
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
-
- if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
- {
- NSData *attachementsData = [NSData dataWithContentsOfFile:[value objectForKey:@"attachmentPath"]];
- [attachments addObject:attachementsData];
- }
- else if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSArray class]])
- {
- NSArray *paths = [value objectForKey:@"attachmentPath"];
- for (NSString *path in paths)
- {
-
- NSData *attachementsData = [NSData dataWithContentsOfFile:path];
- [attachments addObject:attachementsData];
- }
- }
- if ([[value objectForKey:@"recipients"] isKindOfClass:[NSString class]])
- {
- [recipients addObject:[value objectForKey:@"recipients"]];
- }
- else if ([[value objectForKey:@"recipients"] isKindOfClass:[NSArray class]])
- {
- NSArray *recipientsArray = [value objectForKey:@"recipients"];
- for (NSString *recipient in recipientsArray)
- {
- [recipients addObject:recipient];
- }
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupSMSParamsByText:text
- title:title
- images:images
- attachments:attachments
- recipients:recipients
- type:type];
- }
-
- //Print
- //无定制内容方法
-
- //Copy
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeCopy]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *url = nil;
- SSDKContentType type = SSDKContentTypeImage;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
-
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupCopyParamsByText:text
- images:images
- url:[NSURL URLWithString:url]
- type:type];
- }
-
- //Instapaper
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeInstapaper]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *url = nil;
- NSString *title = nil;
- NSString *desc = nil;
- NSString *content = nil;
- BOOL isPrivateFromSource;
- NSInteger folderId;
- BOOL resolveFinalUrl;
-
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
- {
- desc = [value objectForKey:@"desc"];
- }
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- content = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"isPrivateFromSource"] boolValue])
- {
- isPrivateFromSource = YES;
- }
- if (![[value objectForKey:@"resolveFinalUrl"] boolValue])
- {
- resolveFinalUrl = YES;
- }
-
- folderId = [[value objectForKey:@"folderId"] integerValue];
-
- [params SSDKSetupInstapaperParamsByUrl:[NSURL URLWithString:url]
- title:title
- desc:desc
- content:content
- isPrivateFromSource:isPrivateFromSource
- folderId:folderId
- resolveFinalUrl:resolveFinalUrl];
- }
-
- //Pocket
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypePocket]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *url = nil;
- NSString *title = nil;
- NSString *tags = nil;
- NSString *tweetId = nil;
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- id tagValue = [value objectForKey:@"tags"];
- if ([tagValue isKindOfClass:[NSString class]])
- {
- tags = tagValue;
- }
- else if ([tagValue isKindOfClass:[NSArray class]])
- {
- NSArray *tagsArr = tagValue;
- tags = [tagsArr componentsJoinedByString:@","];
- }
- if ([[value objectForKey:@"tweetID"] isKindOfClass:[NSString class]])
- {
- tweetId = [value objectForKey:@"tweetID"];
- }
- [params SSDKSetupPocketParamsByUrl:[NSURL URLWithString:url]
- title:title
- tags:tags
- tweetId:tweetId];
- }
-
- //YouDaoNote
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYouDaoNote]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *title = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *source = nil;
- NSString *author = nil;
- NSString *notebook = nil;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
-
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
- if ([[value objectForKey:@"source"] isKindOfClass:[NSString class]])
- {
- source = [value objectForKey:@"source"];
- }
- if ([[value objectForKey:@"author"] isKindOfClass:[NSString class]])
- {
- author = [value objectForKey:@"author"];
- }
- if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
- {
- notebook = [value objectForKey:@"notebook"];
- }
-
- [params SSDKSetupYouDaoNoteParamsByText:text
- images:images
- title:title
- source:source
- author:author
- notebook:notebook];
- }
-
- //Pinterest
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypePinterest]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *image = nil;
- NSString *desc = nil;
- NSString *url = nil;
- NSString *board = nil;
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
- {
- desc = [value objectForKey:@"desc"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"board"] isKindOfClass:[NSString class]])
- {
- board = [value objectForKey:@"board"];
- }
- [params SSDKSetupPinterestParamsByImageUrl:image desc:desc url:[NSURL URLWithString:url] boardName:board];
- }
-
- //Flickr
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeFlickr]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSMutableArray *tags = [NSMutableArray array];
- BOOL isPublic;
- BOOL isFriend;
- BOOL isFamiliy;
- NSInteger safetyLevel;
- NSInteger contentType;
- NSInteger hidden;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- id tagValue = [value objectForKey:@"tags"];
- if ([tagValue isKindOfClass:[NSString class]])
- {
- [tags addObject:tagValue];
- }
- else if ([tagValue isKindOfClass:[NSArray class]])
- {
- tags = [tagValue mutableCopy];
- }
- if ([[value objectForKey:@"isPublic"] boolValue])
- {
- isPublic = YES;
- }
- if ([[value objectForKey:@"isFriend"] boolValue])
- {
- isFriend = YES;
- }
- if ([[value objectForKey:@"isFamiliy"] boolValue])
- {
- isFamiliy = YES;
- }
- if ([[value objectForKey:@"safetyLevel"] integerValue])
- {
- safetyLevel = [[value objectForKey:@"safetyLevel"] integerValue];
- }
- if ([[value objectForKey:@"contentType"] integerValue])
- {
- contentType = [[value objectForKey:@"contentType"] integerValue];
- }
- if ([[value objectForKey:@"hidden"] integerValue])
- {
- hidden = [[value objectForKey:@"hidden"] integerValue];
- }
-
- [params SSDKSetupFlickrParamsByText:text
- image:image
- title:title
- tags:tags
- isPublic:isPublic
- isFriend:isFriend
- isFamily:isFamiliy
- safetyLevel:safetyLevel
- contentType:contentType
- hidden:hidden];
- }
-
- //Dropbox
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDropbox]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *attachmentPath = nil;
- if ([[value objectForKey:@"attachmentPath"] isKindOfClass:[NSString class]])
- {
- attachmentPath = [value objectForKey:@"attachmentPath"];
- }
- [params SSDKSetupDropboxParamsByAttachment:attachmentPath];
- }
-
- //VKontakte
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeVKontakte]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *url = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *groupId = nil;
- BOOL friendsOnly;
- double lat;
- double lng;
- SSDKContentType type = SSDKContentTypeText;
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
- for (NSString *path in paths)
- {
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
- if ([[value objectForKey:@"groupID"] isKindOfClass:[NSString class]])
- {
- groupId = [value objectForKey:@"groupID"];
- }
- if ([[value objectForKey:@"friendsOnly"] boolValue])
- {
- friendsOnly = YES;
- }
- if ([[value objectForKey:@"latitude"] isKindOfClass:[NSString class]])
- {
- lat = [[value objectForKey:@"latitude"] doubleValue];
- }
- if ([[value objectForKey:@"longitude"] isKindOfClass:[NSString class]])
- {
- lng = [[value objectForKey:@"longitude"] doubleValue];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
-
- }
-
- [params SSDKSetupVKontakteParamsByText:text
- images:images
- url:[NSURL URLWithString:url]
- groupId:groupId
- friendsOnly:friendsOnly
- latitude:lat
- longitude:lng
- type:type];
- }
-
- //Yixin系列
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinSession]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setYixinParams(value, params, SSDKPlatformSubTypeYiXinSession);
- }
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinTimeline]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setYixinParams(value, params, SSDKPlatformSubTypeYiXinTimeline);
- }
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeYiXinFav]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setYixinParams(value, params, SSDKPlatformSubTypeYiXinFav);
- }
-
- //MingDao
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeMingDao]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *url = nil;
- NSString *title = nil;
- SSDKContentType type = SSDKContentTypeText;
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
-
- }
-
- [params SSDKSetupMingDaoParamsByText:text
- image:image
- url:[NSURL URLWithString:url]
- title:title
- type:type];
- }
-
- //Line
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeLine]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
-
- }
- [params SSDKSetupLineParamsByText:text
- image:image
- type:type];
- }
-
- //whatsApp
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeWhatsApp]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *audioPath = nil;
- NSString *videoPath = nil;
- CGFloat menuX;
- CGFloat menuY;
- SSDKContentType type = SSDKContentTypeText;
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"audioPath"] isKindOfClass:[NSString class]])
- {
- audioPath = [value objectForKey:@"audioPath"];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- videoPath = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"menuX"] isKindOfClass:[NSString class]])
- {
- menuX = [[value objectForKey:@"menuX"] floatValue];
- }
- if ([[value objectForKey:@"menuY"] isKindOfClass:[NSString class]])
- {
- menuX = [[value objectForKey:@"menuY"] floatValue];
- }
- CGPoint point = CGPointMake(menuX, menuY);
-
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
-
- }
-
- [params SSDKSetupWhatsAppParamsByText:text
- image:image
- audio:audioPath
- video:videoPath
- menuDisplayPoint:point
- type:type];
-
- }
-
-
- //Kakao系列
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeKakaoTalk]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setKakaoParams(value,params,SSDKPlatformSubTypeKakaoTalk);
- }
-
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformSubTypeKakaoStory]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- __setKakaoParams(value,params,SSDKPlatformSubTypeKakaoStory);
- }
-
-
- //支付宝好友
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliSocial]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSString *url = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupAliSocialParamsByText:text
- image:img
- title:title
- url:[NSURL URLWithString:url]
- type:type
- platformType:SSDKPlatformTypeAliSocial];
-
- }
-
- //支付宝朋友圈
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeAliSocialTimeline]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSString *url = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
-
- [params SSDKSetupAliSocialParamsByText:text
- image:img
- title:title
- url:[NSURL URLWithString:url]
- type:type
- platformType:SSDKPlatformTypeAliSocialTimeline];
-
- }
-
- //钉钉
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeDingTalk]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *image = nil;
- NSString *title = nil;
- NSString *url = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- image = [value objectForKey:@"imageUrl"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]])
- {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupDingTalkParamsByText:text
- image:image
- title:title
- url:[NSURL URLWithString:url]
- type:type];
-
- }
-
- //Evernote
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeEvernote]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSString *title = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSMutableArray *tags = [NSMutableArray array];
- NSString *notebook = nil;
- NSString *video = nil;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString *imgPath = [value objectForKey:@"imageUrl"];
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, imgPath.length)
- withString:imgPath])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:imgPath]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:imgPath];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:imgPath];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- else if([[value objectForKey:@"imageUrl"] isKindOfClass:[NSArray class]])
- {
-
- NSArray *paths = [value objectForKey:@"imageUrl"];
-
- for (NSString *path in paths)
- {
-
- SSDKImage *image = nil;
- if ([MOBFRegex isMatchedByRegex:@"\\w://.*"
- options:MOBFRegexOptionsNoOptions
- inRange:NSMakeRange(0, path.length)
- withString:path])
- {
- image = [[SSDKImage alloc]initWithURL:[NSURL URLWithString:path]];
- }
- else
- {
- UIImage *localImg = [UIImage imageWithContentsOfFile:path];
- image = [[SSDKImage alloc] initWithImage:localImg
- format:SSDKImageFormatJpeg
- settings:nil];
- }
-
- if (image)
- {
- [images addObject:path];
- }
- else
- {
- NSLog(@"#waring : 检测不到有效图片路径,请检查传入图片的路径的有效性");
- }
-
- }
- }
- if ([[value objectForKey:@"notebook"] isKindOfClass:[NSString class]])
- {
- notebook = [value objectForKey:@"notebook"];
- }
- id tagValue = [value objectForKey:@"tags"];
- if ([tagValue isKindOfClass:[NSString class]])
- {
- [tags addObject:tagValue];
- }
- else if ([tagValue isKindOfClass:[NSArray class]])
- {
- tags = [tagValue mutableCopy];
- }
-
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- video = [value objectForKey:@"videoPath"];
- }
- [params SSDKSetupEvernoteParamsByText:text
- images:images
- video:[NSURL URLWithString:video]
- title:title
- notebook:notebook
- tags:tags
- platformType:SSDKPlatformTypeEvernote];
-
-
- }
-
- //Youtube
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeYouTube]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *desc = nil;
- NSString *title = nil;
- NSString *videoPath = nil;
- NSMutableArray *tags = [NSMutableArray array];
- SSDKPrivacyStatus privacyStatus = SSDKPrivacyStatusPrivate;
-
- if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
- {
- desc = [value objectForKey:@"desc"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- id tagValue = [value objectForKey:@"tags"];
- if ([tagValue isKindOfClass:[NSString class]])
- {
- NSArray *tagArr = [tagValue componentsSeparatedByString:@","];
- [tags addObjectsFromArray:tagArr];
- }
- else if ([tagValue isKindOfClass:[NSArray class]])
- {
- tags = [tagValue mutableCopy];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- videoPath = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"privateStatus"] integerValue] != 0) {
- privacyStatus = [[value objectForKey:@"privateStatus"] integerValue];
- }
-
- [params SSDKSetupYouTubeParamsByVideo:videoPath
- title:title
- description:desc
- tags:tags
- privacyStatus:privacyStatus];
-
- }
-
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeWework]]];
- if ([value isKindOfClass:[NSDictionary class]])
- {
- NSString *text = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *title = nil;
- NSString *url = nil;
- NSString *video = nil;
- NSString *thumbImg = nil;
- NSData *fileData = nil;
- SSDKContentType type = SSDKContentTypeText;
-
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString * image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *imagesStr = value[@"imageArray"];
- [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
- }
-
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"url"] isKindOfClass:[NSString class]])
- {
- url = [value objectForKey:@"url"];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- video = [value objectForKey:@"videoPath"];
- }
- if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
- {
- thumbImg = [value objectForKey:@"thumbImageUrl"];
- }
- if ([[value objectForKey:@"filePath"] isKindOfClass:[NSString class]])
- {
- fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"filePath"]];
- }
- [params SSDKSetupWeWorkParamsByText:text
- title:title
- url:[NSURL URLWithString:url]
- thumbImage:thumbImg
- image:images
- video:video
- fileData:fileData
- type:type];
- }
- //Oasis
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeOasis]]];
-
- if ([value isKindOfClass:[NSDictionary class]]) {
- NSString *text = nil;
- NSMutableArray *images = [NSMutableArray array];
- NSString *title = nil;
- NSMutableArray *assetLocalIds = [NSMutableArray array];
- SSDKContentType type = SSDKContentTypeImage;
- NSData *fileData = nil;
- NSString *fileExt = nil;
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]]) {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- if ([[value objectForKey:@"text"] isKindOfClass:[NSString class]])
- {
- text = [value objectForKey:@"text"];
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"videoPath"]];
- }
-
- if ([[value objectForKey:@"sourceFilePath"] isKindOfClass:[NSString class]])
- {
- fileExt = [value objectForKey:@"sourceFilePath"];
- }
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString * image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *imagesStr = value[@"imageArray"];
- [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
- }
- if ([[value objectForKey:@"assetLocalIds"] isKindOfClass:[NSString class]])
- {
- NSString *assetLocalIdsStr = value[@"assetLocalIds"];
- [assetLocalIds addObjectsFromArray:[assetLocalIdsStr componentsSeparatedByString:@","]];
- }
- [params SSDKSetupOasisParamsByTitle:title
- text:text
- assetLocalIds:assetLocalIds
- image:images
- video:fileData
- fileExtension:fileExt
- type:type];
- }
- //SnapChat
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeSnapChat]]];
-
- if ([value isKindOfClass:[NSDictionary class]]) {
- NSMutableArray *images = [NSMutableArray array];
- NSString *title = nil;
- SSDKContentType type = SSDKContentTypeImage;
- NSData *fileData = nil;
- NSString *sticker = nil;
- NSString *attachmentUrl = nil;
- NSNumber *stickerAnimated = @0;
- NSNumber *stickerRotation = @0;
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]]) {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"videoPath"] isKindOfClass:[NSString class]])
- {
- fileData = [NSData dataWithContentsOfFile:[value objectForKey:@"videoPath"]];
- }
-
- if ([[value objectForKey:@"imageUrl"] isKindOfClass:[NSString class]])
- {
- NSString * image = [value objectForKey:@"imageUrl"];
- if (image)
- {
- [images addObject:image];
- }
- }
- if ([[value objectForKey:@"imageArray"] isKindOfClass:[NSString class]])
- {
- NSString *imagesStr = value[@"imageArray"];
- [images addObjectsFromArray:[imagesStr componentsSeparatedByString:@","]];
- }
-
- if ([[value objectForKey:@"attachmentUrl"] isKindOfClass:[NSString class]])
- {
- attachmentUrl = value[@"attachmentUrl"];
- }
-
- if ([[value objectForKey:@"stickerImage"] isKindOfClass:[NSString class]])
- {
- sticker = value[@"stickerImage"];
-
- }
- if ([[value objectForKey:@"stickerRotation"] isKindOfClass:[NSNumber class]])
- {
- stickerRotation = value[@"stickerRotation"];
- }
- if ([[value objectForKey:@"stickerAnimated"] isKindOfClass:[NSNumber class]])
- {
- stickerAnimated = value[@"stickerAnimated"];
- }
- [params SSDKSetupSnapChatParamsByCaption:title
- attachmentUrl:attachmentUrl
- image:images
- video:fileData
- sticker:sticker
- stickerAnimated:stickerAnimated.boolValue stickerRotation:stickerRotation.floatValue
- cameraViewState:0
- type:type];
- }
- //快手
- value = [MOBFJson objectFromJSONString:[customizeShareParams objectForKey:[NSString stringWithFormat:@"%lu",(unsigned long)SSDKPlatformTypeKuaiShou]]];
-
- if ([value isKindOfClass:[NSDictionary class]]) {
- NSString *title = nil;
- NSString *desc = nil;
- NSString *linkURL = nil;
- NSString *thumbImage = nil;
- NSString *openID = nil;
- NSString *receiverOpenID = nil;
- NSString *localIdentifier = nil;
- NSArray *tags = nil;
- NSString *extraInfo = nil;
-
- SSDKContentType type = SSDKContentTypeMessage;
-
- if ([[value objectForKey:@"title"] isKindOfClass:[NSString class]])
- {
- title = [value objectForKey:@"title"];
- }
- if ([[value objectForKey:@"desc"] isKindOfClass:[NSString class]])
- {
- desc = [value objectForKey:@"desc"];
- }
- if ([[value objectForKey:@"linkUrl"] isKindOfClass:[NSString class]])
- {
- linkURL = [value objectForKey:@"linkUrl"];
- }
- if ([[value objectForKey:@"thumbImageUrl"] isKindOfClass:[NSString class]])
- {
- thumbImage = [value objectForKey:@"thumbImageUrl"];
- }
- if ([[value objectForKey:@"openID"] isKindOfClass:[NSString class]])
- {
- openID = [value objectForKey:@"openID"];
- }
- if ([[value objectForKey:@"receiverOpenID"] isKindOfClass:[NSString class]])
- {
- receiverOpenID = [value objectForKey:@"receiverOpenID"];
- }
- if ([[value objectForKey:@"localIdentifier"] isKindOfClass:[NSString class]])
- {
- localIdentifier = [value objectForKey:@"localIdentifier"];
- }
- if ([[value objectForKey:@"tags"] isKindOfClass:[NSArray class]])
- {
- tags = [value objectForKey:@"tags"];
- }
- if ([[value objectForKey:@"extraInfo"] isKindOfClass:[NSString class]])
- {
- extraInfo = [value objectForKey:@"extraInfo"];
- }
- if ([[value objectForKey:@"shareType"] isKindOfClass:[NSNumber class]]) {
- type = __convertContentType([[value objectForKey:@"shareType"] integerValue]);
- }
- [params SSDKSetupKuaiShouShareParamsByTitle:title desc:desc linkURL:linkURL thumbImage:thumbImage openID:openID receiverOpenID:receiverOpenID localIdentifier:localIdentifier tags:tags extraInfo:extraInfo type:type];
- }
- }
- }
- return params;
- }
-
- void __iosShareSDKRegisterAppAndSetPltformsConfig (void *appKey, void*configInfo)
- {
- NSMutableArray *activePlatforms = [NSMutableArray array];
- NSMutableDictionary *platformsDict = [NSMutableDictionary dictionary];
- if (configInfo)
- {
- platformsDict = __parseWithHashtable(configInfo);
- }
- for (id obj in [platformsDict allKeys])
- {
- NSInteger platformInterger = [obj integerValue];
- NSDictionary *dict = [platformsDict objectForKey:[NSString stringWithFormat:@"%@",obj]];
-
- if ([[dict objectForKey:@"Enable"] isEqualToString:@"true"])
- {
- [activePlatforms addObject:[NSNumber numberWithInteger:platformInterger]];
- }
- }
-
- [ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
-
- for (NSString *key in platformsDict.allKeys)
- {
- SSDKPlatformType type = key.integerValue;
- NSDictionary *platformInfo = platformsDict[key];
-
- if (type == SSDKPlatformTypeSinaWeibo)
- {
- [platformsRegister setupSinaWeiboWithAppkey:platformInfo[@"app_key"] appSecret:platformInfo[@"app_secret"] redirectUrl:platformInfo[@"redirect_uri"] universalLink:platformInfo[@"app_universalLink"]];
- }
- else if (type == SSDKPlatformTypeWechat ||
- type == SSDKPlatformSubTypeWechatSession ||
- type == SSDKPlatformSubTypeWechatTimeline ||
- type == SSDKPlatformSubTypeWechatFav)
- {
- NSString *appsecret = platformInfo[@"app_secret"];
- if ([appsecret isKindOfClass:[NSString class]] && appsecret.length == 0) {
- appsecret = nil;
- }
- [platformsRegister setupWeChatWithAppId:platformInfo[@"app_id"] appSecret:appsecret universalLink:platformInfo[@"app_universalLink"]];
- }
- else if (type == SSDKPlatformTypeQQ ||
- type == SSDKPlatformSubTypeQZone ||
- type == SSDKPlatformSubTypeQQFriend)
- {
- [platformsRegister setupQQWithAppId:platformInfo[@"app_id"] appkey:platformInfo[@"app_key"] enableUniversalLink:YES universalLink:nil];
- }
- else if (type == SSDKPlatformTypeKakao ||
- type == SSDKPlatformSubTypeKakaoTalk ||
- type == SSDKPlatformSubTypeKakaoStory)
- {
- [platformsRegister setupKaKaoWithAppkey:platformInfo[@"app_key"] restApiKey:platformInfo[@"rest_api_key"] redirectUrl:platformInfo[@"redirect_uri"]];
- }
- else if (type == SSDKPlatformTypeYiXin ||
- type == SSDKPlatformSubTypeYiXinSession ||
- type == SSDKPlatformSubTypeYiXinTimeline ||
- type == SSDKPlatformSubTypeYiXinFav)
- {
- [platformsRegister setupYiXinByAppId:platformInfo[@"app_id"] appSecret:platformInfo[@"app_secret"] redirectUrl:platformInfo[@"redirect_uri"]];
- }
- else if (type == SSDKPlatformTypeAliSocial || type == SSDKPlatformTypeAliSocialTimeline)
- {
- [platformsRegister setupAliSocialWithAppId:platformInfo[@"app_id"]];
- }
- else if(type == SSDKPlatformTypeSnapChat){
- [platformsRegister setSnapChatClientId:platformInfo[@"client_id"] clientSecret:@"" redirectUrl:platformInfo[@"redirect_uri"]];
- }else if(type == SSDKPlatformTypeKuaiShou){
- [platformsRegister setupKuaiShouWithAppId:platformInfo[@"app_id"] appSecret:platformInfo[@"app_secret"] universalLink:platformInfo[@"app_universalLink"] delegate:[[UIApplication sharedApplication]delegate]];
- }
- else if(type == SSDKPlatformTypePocket){
- [platformsRegister setupPocketWithConsumerKey:platformInfo[@"consumer_key"] redirectUrl:platformInfo[@"redirect_uri"]];
- }
- else if(type == SSDKPlatformTypeWework){
- [platformsRegister setupWeWorkBySchema:platformInfo[@"schema"] appKey:platformInfo[@"app_Key"] agentId:platformInfo[@"agent_id"] appSecret:platformInfo[@"app_secret"]];
- }
- else if(type == SSDKPlatformTypeDingTalk){
- [platformsRegister setupDingTalkWithAppId:platformInfo[@"shareApp_id"]];
- [platformsRegister setupDingTalkAuthWithAppId:platformInfo[@"authApp_id"] appSecret:platformInfo[@"authApp_Secret"] redirectUrl:platformInfo[@"authApp_RedirectUri"]];
- }
- else if(type == SSDKPlatformTypeReddit){
- [platformsRegister setupRedditByAppKey:platformInfo[@"app_key"] redirectUri:platformInfo[@"redirect_uri"]];
- }
- else if(type == SSDKPlatformTypeTumblr){
- [platformsRegister setupTumblrByConsumerKey:platformInfo[@"consumer_key"] consumerSecret:platformInfo[@"consumer_secret"] redirectUrl:platformInfo[@"callback_url"]];
- }
- // else if(type == SSDKPlatformTypeYouTube){
- // [platformsRegister setupYouTubeWithClientId:platformInfo[@"client_id"] clientSecret:platformInfo[@"client_secret"] redirectUrl:platformInfo[@"redirect_uri"]];
- // }
- else
- {
- NSMutableDictionary *dic = platformsRegister.platformsInfo;
- dic[key] = platformInfo.mutableCopy;
- }
- }
- }];
- }
-
-
- void __iosShareSDKAuthorize (int reqID, int platType, void *observer)
- {
- NSString *observerStr = nil;
- if (observer)
- {
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- }
- NSMutableDictionary *settings = [NSMutableDictionary dictionary];
- //下面这个设置只对Facebook授权获取大icon有效
- [settings setValue:@(CGSizeMake(600, 600)) forKey:@"size"];
- [ShareSDK authorize:platType
- settings:settings
- onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
-
- }
- if (state == SSDKResponseStateSuccess)
- {
- NSMutableDictionary *userData = [user rawData].mutableCopy;
- userData[@"credential"] = [[user credential] rawData];
- if (platType == SSDKPlatformTypeAppleAccount) {
- userData[@"identify"] = user.credential.token;
- userData[@"code"] = user.credential.authCode;
- }
- resultDict[@"res"] = userData;
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
-
- }];
- }
-
- void __iosShareSDKCancelAuthorize (int platType)
- {
- [ShareSDK cancelAuthorize:platType result:nil];
- }
-
- bool __iosShareSDKHasAuthorized (int platType)
- {
- return [ShareSDK hasAuthorized:platType];
- }
-
- bool __iosShareSDKIsClientInstalled(int platType)
- {
- return [ShareSDK isClientInstalled:platType];
- }
-
- void __iosShareSDKGetUserInfo (int reqID, int platType, void *observer)
- {
- NSString *observerStr = nil;
- if (observer)
- {
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- }
-
- [ShareSDK getUserInfo:platType
- onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error)
- {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:8] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]]
- forKey:@"error_code"];
-
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
- forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"]
- forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
-
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
- if (state == SSDKResponseStateSuccess && user)
- {
- NSMutableDictionary *userData = [user rawData].mutableCopy;
- userData[@"credential"] = [[user credential] rawData];
- resultDict[@"res"] = userData;
- // [resultDict setObject:[user rawData] forKey:@"res"];
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
-
- }];
- }
-
- void __iosShareSDKShare (int reqID, int platType, void *content, void *observer)
- {
- NSString *observerStr = nil;
- NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
-
- if (content)
- {
- NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
- shareParams = __getShareParamsWithString(contentStr);
- }
-
- [ShareSDK share:platType
- parameters:shareParams
- onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
- forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
-
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
-
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
-
- }];
-
- }
- void __iosShareSDKShareWithActivity (int reqID, int platType, void *content, void *observer)
- {
- NSString *observerStr = nil;
- NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
-
- if (content)
- {
- NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
- shareParams = __getShareParamsWithString(contentStr);
- }
-
- [ShareSDK shareByActivityViewController:platType parameters:shareParams onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
- forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
-
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
-
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
-
- }];
-
- }
-
- void __iosShareSDKOneKeyShare (int reqID, void *platTypes, void *content, void *observer)
- {
- NSLog(@"OneKey share deprecate from v4.2.0");
- }
-
- void __iosShareSDKShareWithCommand (void *content, void *observer)
- {
- NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- NSDictionary *customFields = nil;
-
- if (content)
- {
- customFields = __parseWithHashtable(content);
- }
- /*
- [ShareSDK getCommandText:customFields withComplete:^(NSString * _Nullable text, NSError * _Nullable error, void (^ _Nullable complete)(NSString * _Nullable)) {
- NSString *command = [NSString stringWithFormat:@"【复制本段内容%@打开👉页面关键字👈去粘贴给好友】",text];
- if(!error){
- complete(command);
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:11] forKey:@"action"];
- [resultDict setObject:@{@"commandText":command} forKey:@"res"];
- [resultDict setObject:@1 forKey:@"status"];
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- if (_refView)
- {
- //移除视图
- [_refView removeFromSuperview];
- }
- }
- }];
- */
- }
-
- void __iosShareSDKShowShareMenu (int reqID, void *platTypes, void *content, int x, int y, void *observer)
- {
- NSArray *platTypesArr = nil;
- NSMutableArray *actionSheetItems = [NSMutableArray array];
- NSString *observerStr = nil;
- NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
-
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
-
- if (platTypes)
- {
- NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
- platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
- }
- else
- {
- platTypesArr = [ShareSDK activePlatforms];
- for (id obj in platTypesArr)
- {
- NSInteger platformInterger = [obj integerValue];
- [actionSheetItems addObject:[NSNumber numberWithInteger:platformInterger]];
- }
- platTypesArr = [actionSheetItems mutableCopy];
-
- }
-
- if (content)
- {
- NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
- shareParams = __getShareParamsWithString(contentStr);
- }
-
- if ([MOBFDevice isPad])
- {
- if (!_refView)
- {
- _refView = [[UIView alloc] initWithFrame:CGRectMake(x, y, 10, 10)];
- }
-
- [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_refView];
-
- }
-
- [ShareSDK showShareActionSheet:_refView customItems:platTypesArr shareParams:shareParams sheetConfiguration:nil onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
- {
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
- forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"]
- forKey:@"error_msg"];
- }
- else if ([error_data objectForKey:@"error_message"])
- {
- [errorDict setObject:[error_data objectForKey:@"error_message"]
- forKey:@"error_msg"];
- }
-
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- if (_refView)
- {
- //移除视图
- [_refView removeFromSuperview];
- }
-
- }
- }];
- }
-
- void __iosShareSDKShowShareView (int reqID, int platType, void *content, void *observer)
- {
- NSString *observerStr = nil;
- NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
-
-
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
-
- if (content)
- {
- NSString *contentStr = [NSString stringWithCString:content encoding:NSUTF8StringEncoding];
- shareParams = __getShareParamsWithString(contentStr);
- }
-
- [ShareSDK showShareEditor:platType otherPlatforms:nil shareParams:shareParams editorConfiguration:nil onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
-
- if (state == SSDKResponseStateSuccess)
- {
-
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- }];
- }
-
- void __iosShareSDKGetFriendsList (int reqID, int platType, int count , int page, void *observer)
- {
-
- SSDKPlatformType shareType = (SSDKPlatformType)platType;
- NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- NSInteger cursor = page;
- NSInteger size = count;
-
- if (shareType == SSDKPlatformTypeTwitter)
- {
- cursor = -1;
- }
-
- [ShareSDK getFriends:platType
- cursor:cursor
- size:size
- onStateChanged:^(SSDKResponseState state, SSEFriendsPaging *paging, NSError *error)
- {
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:2] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
-
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- if (paging)
- {
- NSArray *friends = [NSArray array];
- friends = paging.users;
- NSMutableDictionary *resDict = [NSMutableDictionary dictionary];
- [resDict setObject:friends forKey:@"users"];
- [resDict setObject:[NSNumber numberWithInteger:paging.prevCursor] forKey:@"prev_cursor"];
- [resDict setObject:[NSNumber numberWithInteger:paging.nextCursor] forKey:@"next_cursor"];
- [resDict setObject:[NSNumber numberWithUnsignedInteger:paging.total] forKey:@"total"];
- [resDict setObject:[NSNumber numberWithBool:paging.hasNext] forKey:@"has_next"];
- [resultDict setObject:resDict forKey:@"res"];
-
- }
- }
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
-
- }];
-
- }
- char * __StringCopy( const char *string)
- {
- if (string != NULL)
- {
- char *copyStr = (char*)malloc(strlen(string)+1);
- strcpy(copyStr, string);
- return copyStr;
- }
- else
- {
- return NULL;
- }
- }
-
- extern const char* __iosShareSDKGetCredential (int platType)
- {
- SSDKPlatformType shareType = (SSDKPlatformType)platType;
- SSDKUser *userInfo = [ShareSDK currentUser:shareType];
- SSDKCredential *credential = userInfo.credential;
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"type"];
-
- if ([credential available])
- {
- if ([credential uid])
- {
- [resultDict setObject:[credential uid] forKey:@"uid"];
- }
- if ([credential token])
- {
- [resultDict setObject:[credential token] forKey:@"token"];
- }
- if ([credential secret])
- {
- [resultDict setObject:[credential secret] forKey:@"secret"];
- }
- if ([credential expired])
- {
- [resultDict setObject:@(credential.expired) forKey:@"expired"];
- }
-
- [resultDict setObject:[NSNumber numberWithBool:[credential available]] forKey:@"available"];
-
- }
- else
- {
- [resultDict setObject:[NSNumber numberWithBool:NO] forKey:@"available"];
- [resultDict setObject:@"Invalid Authorization" forKey:@"error"];
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- return __StringCopy([resultStr UTF8String]);
- }
-
- void __iosShareSDKFollowFriend (int reqID, int platType,void *account, void *observer)
- {
- SSDKPlatformType shareType = (SSDKPlatformType)platType;
- NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- SSDKUser *user = [[SSDKUser alloc]init];
- user.uid = [NSString stringWithCString:account encoding:NSUTF8StringEncoding];
-
- [ShareSDK addFriend:shareType
- user:user
- onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:6] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:shareType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- NSDictionary *userRawdata = [NSDictionary dictionaryWithDictionary:[user rawData]];
- [resultDict setObject:userRawdata forKey:@"res"];
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- }];
- }
-
- void __iosShareSDKShareWithContentName(int reqID, int platType, void *contentName, void *customHashtable, void *observer)
- {
- SSDKPlatformType shareType = (SSDKPlatformType)platType;
- NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
- NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- NSDictionary *customFields = nil;
-
- if (customHashtable)
- {
- customFields = __parseWithHashtable(customHashtable);
- }
-
- [ShareSDK shareWithContentName:contentNodeName
- platform:shareType
- customFields:customFields
- onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
- forKey:@"error_msg"];
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
- else if([[error userInfo] objectForKey:@"error_msg"])
- {
- if ([[error userInfo] objectForKey:@"error_msg"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_msg"]
- forKey:@"error_msg"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- }];
-
- }
-
- void __iosShareSDKShowShareMenuWithContentName(int reqID, void *contentName, void *customHashtable, void *platTypes, int x, int y, void *observer)
- {
- NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
- NSDictionary *customFields = nil;
- if (customHashtable)
- {
- customFields = __parseWithHashtable(customHashtable);
- }
- NSArray *platTypesArr = nil;
- NSMutableArray *actionSheetItems = [NSMutableArray array];
- NSString *observerStr = nil;
-
- observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
-
- if (platTypes)
- {
- NSString *platTypesStr = [NSString stringWithCString:platTypes encoding:NSUTF8StringEncoding];
- platTypesArr = [MOBFJson objectFromJSONString:platTypesStr];
- }
- else
- {
- platTypesArr = [ShareSDK activePlatforms];
- for (id obj in platTypesArr)
- {
- NSInteger platformInterger = [obj integerValue];
- [actionSheetItems addObject:[NSNumber numberWithInteger:platformInterger]];
- }
- platTypesArr = [actionSheetItems mutableCopy];
-
- }
-
- if ([MOBFDevice isPad])
- {
- if (!_refView)
- {
- _refView = [[UIView alloc] initWithFrame:CGRectMake(x, y, 10, 10)];
- }
-
- [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:_refView];
-
- }
-
- NSMutableDictionary *params = [ShareSDK getShareParamsWithContentName:contentNodeName customFields:customFields];
-
- [ShareSDK showShareActionSheet:_refView
- customItems:platTypesArr
- shareParams:params
- sheetConfiguration:nil
- onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
-
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"]
- forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"]
- forKey:@"error_msg"];
- }
- else if ([error_data objectForKey:@"error_message"])
- {
- [errorDict setObject:[error_data objectForKey:@"error_message"]
- forKey:@"error_msg"];
- }
-
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]]
- forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
-
- if (state == SSDKResponseStateSuccess)
- {
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- if (_refView)
- {
- //移除视图
- [_refView removeFromSuperview];
- }
-
- }];
- }
-
- void __iosShareSDKShowShareViewWithContentName(int reqID, int platType, void *contentName, void *customHashtable, void *observer)
- {
- SSDKPlatformType shareType = (SSDKPlatformType)platType;
- NSString *contentNodeName = [NSString stringWithCString:contentName encoding:NSUTF8StringEncoding];
- NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- NSDictionary *customFields = nil;
-
- if (customHashtable)
- {
- customFields = __parseWithHashtable(customHashtable);
- }
-
- NSMutableDictionary *params = [ShareSDK getShareParamsWithContentName:contentNodeName customFields:customFields];
-
- [ShareSDK showShareEditor:shareType otherPlatforms:nil shareParams:params editorConfiguration:nil onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:9] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:state] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:platformType] forKey:@"platform"];
- [resultDict setObject:[NSNumber numberWithInteger:reqID] forKey:@"reqID"];
-
- if (state == SSDKResponseStateFail && error)
- {
- NSMutableDictionary *errorDict = [NSMutableDictionary dictionary];
- [errorDict setObject:[NSNumber numberWithInteger:[error code]] forKey:@"error_code"];
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- if ([[error userInfo] objectForKey:@"error_message"])
- {
- [errorDict setObject:[[error userInfo] objectForKey:@"error_message"] forKey:@"error_msg"];
-
- }
- }
- else if ([[error userInfo] objectForKey:@"user_data"])
- {
- NSDictionary *error_data = [[error userInfo] objectForKey:@"user_data"];
- if ([error_data objectForKey:@"error"])
- {
- [errorDict setObject:[error_data objectForKey:@"error"] forKey:@"error_msg"];
- }
- if ([error_data objectForKey:@"error_code"])
- {
- [errorDict setObject:[NSNumber numberWithInteger:[[error_data objectForKey:@"error_code"] integerValue]] forKey:@"error_code"];
- }
- }
-
- [resultDict setObject:errorDict forKey:@"res"];
- }
-
- if (state == SSDKResponseStateSuccess)
- {
-
- if ([contentEntity rawData])
- {
- [resultDict setObject:[contentEntity rawData] forKey:@"res"];
- }
- }
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
-
- }];
- }
-
- bool __iosShareSDKOpenMiniProgram(void *userName, void *path, int miniProgramType)
- {
- NSString *userNameStr = nil;
- NSString *pathStr = nil;
-
- if (userName != NULL)
- {
- userNameStr = [NSString stringWithCString:userName encoding:NSUTF8StringEncoding];
- }
-
- if (path != NULL)
- {
- pathStr = [NSString stringWithCString:path encoding:NSUTF8StringEncoding];
- }
-
- NSLog(@"%@,%@,%d",userNameStr,pathStr,miniProgramType);
-
- Class WeChatConnector = NSClassFromString(@"WeChatConnector");
-
- if (WeChatConnector == NULL)
- {
- NSLog(@"Warn: WeChatConnector not exsit !");
- }
-
- ((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);
- return YES;
- }
-
-
- static void (^ __iosShareSDKRequestTokenGetUserInfo) (NSString *, NSString *) = nil;
-
- void __iosShareSDKWXRequestSendTokenToGetUser(void * uid, void *token){
- if (__iosShareSDKRequestTokenGetUserInfo) {
- NSString *ocUid = [NSString stringWithCString:uid encoding:NSUTF8StringEncoding];
- NSString *ocToken = [NSString stringWithCString:token encoding:NSUTF8StringEncoding];
- __iosShareSDKRequestTokenGetUserInfo(ocUid,ocToken);
- }
- __iosShareSDKRequestTokenGetUserInfo = nil;
- }
- void __iosShareSDKWXRequestToken(void *observer){
- Class wechatConnectorClass = NSClassFromString(@"WeChatConnector");
- if (wechatConnectorClass) {
- __iosShareSDKRequestTokenGetUserInfo = nil;
- __block NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- void(^block)(id,id) = ^(NSString *authCode, void(^getUserInfo)(NSString *uid,NSString *token)) {
- __iosShareSDKRequestTokenGetUserInfo = getUserInfo;
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:10] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:0] forKey:@"isRefreshToken"];
- [resultDict setObject:authCode forKey:@"authCode"];
- [resultDict setObject:[resultDict copy] forKey:@"res"];
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- };
- ((void (*)(id, SEL,id))objc_msgSend)(wechatConnectorClass,sel_registerName("setRequestAuthTokenOperation:"), block);
- }
- }
- static void (^ __iosShareSDKRefreshTokenGetUserInfo) (NSString *) = nil;
-
- void __iosShareSDKWXRefreshSendTokenToGetUser(void *token){
- if (__iosShareSDKRefreshTokenGetUserInfo) {
- NSString *ocToken = [NSString stringWithCString:token encoding:NSUTF8StringEncoding];
- __iosShareSDKRefreshTokenGetUserInfo(ocToken);
- }
- __iosShareSDKRefreshTokenGetUserInfo = nil;
- }
- void __iosShareSDKWXRefreshRequestToken(void *observer){
- Class wechatConnectorClass = NSClassFromString(@"WeChatConnector");
- if (wechatConnectorClass) {
- __iosShareSDKRefreshTokenGetUserInfo = nil;
- __block NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- void(^block)(id,id) = ^(NSString *uid, void(^getUserInfo)(NSString *token)) {
- __iosShareSDKRefreshTokenGetUserInfo = getUserInfo;
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:[NSNumber numberWithInteger:10] forKey:@"action"];
- [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"status"];
- [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"isRefreshToken"];
- [resultDict setObject:uid forKey:@"uid"];
- [resultDict setObject:[resultDict copy] forKey:@"res"];
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- };
- ((void (*)(id, SEL,id))objc_msgSend)(wechatConnectorClass,sel_registerName("setRefreshAuthTokenOperation:"), block);
- }
- }
- static inline NSUInteger SSDKhexStrToInt(NSString *str) {
- uint32_t result = 0;
- sscanf([str UTF8String], "%X", &result);
- return result;
- }
- static BOOL SSDKhexStrToRGBA(NSString *str,
- CGFloat *r, CGFloat *g, CGFloat *b, CGFloat *a) {
- NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
- str = [[str stringByTrimmingCharactersInSet:set] uppercaseString];
- if ([str hasPrefix:@"#"]) {
- str = [str substringFromIndex:1];
- } else if ([str hasPrefix:@"0X"]) {
- str = [str substringFromIndex:2];
- }
-
- NSUInteger length = [str length];
- if (length != 3 && length != 4 && length != 6 && length != 8) {
- return NO;
- }
-
- if (length < 5) {
- *r = SSDKhexStrToInt([str substringWithRange:NSMakeRange(0, 1)]) / 255.0f;
- *g = SSDKhexStrToInt([str substringWithRange:NSMakeRange(1, 1)]) / 255.0f;
- *b = SSDKhexStrToInt([str substringWithRange:NSMakeRange(2, 1)]) / 255.0f;
- if (length == 4) *a = SSDKhexStrToInt([str substringWithRange:NSMakeRange(3, 1)]) / 255.0f;
- else *a = 1;
- } else {
- *r = SSDKhexStrToInt([str substringWithRange:NSMakeRange(0, 2)]) / 255.0f;
- *g = SSDKhexStrToInt([str substringWithRange:NSMakeRange(2, 2)]) / 255.0f;
- *b = SSDKhexStrToInt([str substringWithRange:NSMakeRange(4, 2)]) / 255.0f;
- if (length == 8) *a = SSDKhexStrToInt([str substringWithRange:NSMakeRange(6, 2)]) / 255.0f;
- else *a = 1;
- }
- return YES;
- }
-
- static UIColor * SSDKColorWithHexStr(NSString * hexStr){
- CGFloat r, g, b, a;
- if (SSDKhexStrToRGBA(hexStr, &r, &g, &b, &a)) {
- if (@available(iOS 10.0, *)) {
- return [UIColor colorWithDisplayP3Red:r green:g blue:b alpha:a];
- }else{
- return [UIColor colorWithRed:r green:g blue:b alpha:a];
- }
- }
- return [UIColor whiteColor];
- }
- extern void __iosMobSDKGetPolicy(int type , void * language, void * observer){
- NSString *observerStr = [NSString stringWithCString:observer encoding:NSUTF8StringEncoding];
- NSString *languageStr = [NSString stringWithCString:language encoding:NSUTF8StringEncoding];
- [MobSDK getPrivacyPolicy:[NSString stringWithFormat:@"%d",type] language:languageStr compeletion:^(NSDictionary * dic, NSError *error){
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- if (!error) {
- [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"status"];
- }else{
- [resultDict setObject:[NSNumber numberWithInteger:2] forKey:@"status"];
- }
- [resultDict setObject:[NSNumber numberWithInteger:1] forKey:@"action"];
- [resultDict setObject:@{@"url":dic[@"content"]?:@""} forKey:@"res"];
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UnitySendMessage([observerStr UTF8String], "_Callback", [resultStr UTF8String]);
- }];
- }
- extern void __iosMobSDKSubmitPolicyGrantResult(int granted){
- [MobSDK uploadPrivacyPermissionStatus:granted onResult:nil];
- }
- extern void __iosMobSDKSetAllowDialog(int allow){
- // [MobSDK setAllowShowPrivacyWindow:allow];
- }
- extern void __iosMobSDKSetPolicyUI(void * backgroundColorRes , void * positiveBtnColorRes, void * negativeBtnColorRes){
- // NSString *backgroundColorResString = [NSString stringWithCString:backgroundColorRes encoding:NSUTF8StringEncoding];
- // NSString *positiveBtnColorResString = [NSString stringWithCString:positiveBtnColorRes encoding:NSUTF8StringEncoding];
- // NSString *negativeBtnColorResString = [NSString stringWithCString:negativeBtnColorRes encoding:NSUTF8StringEncoding];
- // [MobSDK setPrivacyBackgroundColor:SSDKColorWithHexStr(backgroundColorResString) operationButtonColor:@[SSDKColorWithHexStr(negativeBtnColorResString),SSDKColorWithHexStr(positiveBtnColorResString)]];
- }
-
- char* SSDKMakeCString(NSString *str) {
- const char* string = [str UTF8String];
- if (string == NULL) {
- return NULL;
- }
- char* res = (char*)malloc(strlen(string) + 1);
- strcpy(res, string);
- return res;
- }
-
- extern char * __iosMobSDKGetCurrentLanguage(){
- NSString * language = [NSLocale preferredLanguages][0];
- return SSDKMakeCString(language);
- }
-
-
- #if defined (__cplusplus)
- }
- #endif
- @implementation ShareSDKUnity3DBridge
- @end
- @implementation UnityAppController (ShareSDKRestoreSceneInit)
- + (void)initialize
- {
- //[ShareSDK setRestoreSceneDelegate:[ShareSDKUnityRestoreSceneCallback defaultCallBack]];
- [ShareSDK setBanGetIdfa:NO];
- }
- @end
- /*
- @implementation ShareSDKUnityRestoreSceneCallback
- + (ShareSDKUnityRestoreSceneCallback *)defaultCallBack
- {
- static ShareSDKUnityRestoreSceneCallback * _instance = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- _instance = [[ShareSDKUnityRestoreSceneCallback alloc] init];
- });
- return _instance;
- }
- #pragma mark - ISSERestoreSceneDelegate
- - (void)ISSEWillAlertCommand:(NSDictionary *)parameters error:(NSError *)error
- {
- if(parameters.count > 0){
-
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
- [resultDict setObject:parameters forKey:@"res"];
-
- NSString *resultStr = [MOBFJson jsonStringFromObject:resultDict];
- UIPasteboard *board = [UIPasteboard generalPasteboard];
- board.string = @"";
- UnitySendMessage([@"ShareSDKRestoreScene" UTF8String], "_AnalysisCommandCallBack", [resultStr UTF8String]);
- }
- }
- - (void)ISSEWillRestoreScene:(SSERestoreScene *)scene Restore:(void (^)(BOOL))restoreHandler
- {
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
-
- if (scene.path.length > 0)
- {
- resultDict[@"path"] = scene.path;
- }
-
- if (scene.params && scene.params.count > 0)
- {
- resultDict[@"params"] = scene.params;
- }
-
- NSString *resultStr = @"";
- if (resultDict.count > 0)
- {
- resultStr = [MOBFJson jsonStringFromObject:resultDict];
- }
-
- UnitySendMessage([@"ShareSDKRestoreScene" UTF8String], "_RestoreCallBack", [resultStr UTF8String]);
- }
- - (void)ISSEWillRestoreScene:(SSERestoreScene *)scene error:(NSError *)error
- {
- NSMutableDictionary *resultDict = [NSMutableDictionary dictionary];
-
- if (scene.path.length > 0)
- {
- resultDict[@"path"] = scene.path;
- }
-
- if (scene.params && scene.params.count > 0)
- {
- resultDict[@"params"] = scene.params;
- }
-
- NSString *resultStr = @"";
- if (resultDict.count > 0)
- {
- resultStr = [MOBFJson jsonStringFromObject:resultDict];
- }
-
- UnitySendMessage([@"ShareSDKRestoreScene" UTF8String], "_RestoreCallBack", [resultStr UTF8String]);
- }
- @end
- __attribute__((constructor)) static void _SSDKUnityiOSApplicationExcImp(){
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- SEL sel = sel_registerName("addChannelWithSdkName:channel:");
- Method method = class_getClassMethod([MobSDK class],sel) ;
- if (method && method_getImplementation(method) != _objc_msgForward) {
- ((void (*)(id, SEL,id,id))objc_msgSend)([MobSDK class],sel,@"SHARESDK",@"2");
- }
- });
- }
- */
|