React Native Third Party Platform Instance (Android, IOS Dual Platform)

This article mainly introduces the instance of React Native third-party platform sharing (Android, IOS double platform), share it to everyone, specifically:

Source code has been opened to Github, address, please click: React-native- Share [a line of code, double platform sharing]

There are currently supported platforms with [QQ] [QQ space] [WeChat] [friends circle] [microblogging] [Facebook] Welcome everyone Star, fork …..


1. Create a libs folder in the app directory, add a dependent file [Direct copy source code “Libs Directory is


2. Create a jnilibs directory in the app / src / main directory, add the JNI file [Direct copy source JNILIBS directory]


3. In the name directory, introduce the required interactive code [Direct copy source, wxapi, wbsharactivity, module, pay attention to whether the path of the import is correct]


4. Add the AndroidMainfest.xml file Permission [Direct copy source code]


        5. Add a sharing platform in   under AndroidMainfest.xml file [directly copy the source code]   


            6. Use [Keytool -Genkey -V -KEYSTORE-RELESE-Key.KeyStore -Alaias My-Key-Alias ​​-Keyalg RSA -keysize 2048 -Validity 10000】 Generate a signature file and put the signature file into the app directory    7. Under the gradle.properties file, add signage information [Direct copy source code     <= 改为自己申请的QQkey 
    MYAPP_RELEASE_STORE_FILE = my-release-key.keystore MYAPP_RELEASE_KEY_ALIAS = my-key-alias MYAPP_RELEASE_STORE_PASSWORD = 123456 (fill your set password) MYAPP_RELEASE_KEY_PASSWORD = 123456 (fill your set password    8. Add signature configuration under App / Build.gradle file [Direct copy source code] <= 改为自己申请的友盟Key 
  

Android {… defaultconfig {…} SigningConfigs {Release {storeFile file (MYAPP_RELEASE_STORE_FILE) storePassword MYAPP_RELEASE_STORE_PASSWORD keyAlias ​​MYAPP_RELEASE_KEY_ALIAS keyPassword MYAPP_RELEASE_KEY_PASSWORD}} buildTypes {release {… signingConfig signingConfigs.release}}}


9. [initialize shared MainApplication Direct copy source code
 @Override protected list  getPackages () {return arrays.  AsList (New MainreactPackage (), New SharePackage () [New MAINREACTPACKAGE () 


@Override public void oncreate () {super.oncreate (); SOLOADER.INIT (this, false); config.sharetype = “React native”; umshareapi.get (this);} // Configure platform {PlatformConfig.setWeixin (“wx083bf496cbc48aec”, “750E9075fa521c82274a9d548c399825 “); PlatformConfig.setQQZone (” 1106207359 “,” 3JjbG8aXMuh6w0sV “); PlatformConfig.setSinaWeibo (” 2733400964 “,” fac50980a44e3e3afd4bc968ea572887 “,” www.baidu.com “);}

  10. In the initialization of MainActivity, share callback [Direct copy source code]  
@Override protected void oncreate (bundle savedinstancestate) {super.oncreate (Savedinstancestate); ShareModule.initActivity (this);}

  1. The UMSocial in the iOS directory in the source code is added to the project, dragging directly   <= 添加引用 
 ); 
}  2. Select the project under Target, find the Other Linker Flags to add -Objc under Build Setting, pay attention not to -Objc 
3. Join the U-Share SDK-dependent system library
 Sypiced as follows:   SystemConfiguration .framework 
Coregraphics.framework Coretelephony.framewORK
Framework

libc ++. TBD
libz.tbd

4. Configuring SSO White List under Info.plist file [Direct copy
   LsApplicationQueriessChemes 

WeChat Weixin

SINAWEIBOHD

SINAWEIBOSSO


WeibosDK

WeibosDK2.5

MQQAPi React Native第三方平台分享的实例(Android,IOS双平台)

MQQ

mqqOpensdkSSoLogin


mqqconnect

mqqopensdkdataline

mqqopensdkgrouptribeshare

mqqopensdkfriend

mqqopensdkapi

mqqopensdkapiV2
    MQZoneOpenSDK   WTLoginmqqqq   WTLoginmqq2   MQQWPA   Mqzonev2   WTLoginqzone   MQZONEWX   MqZoneOpensdkapiv2   mqzoneOpensdkapi19   MqZoneOpenSDKAPI    MTTBROWSER   TIM   TIMOPI   TimopensdkFriend   TIMWPA   timgamebindinggroup   timapiwallet   timOpensdkSSoLogin   wtlogintim   timopensdkgrouptribeshare   timopensdkapiV4   timgamebindinggroup   timopensdkdataline   Timapiv1     FBAPI   FB-Messenger-API   FBauth3   FBShareExtension     5. Configure URL Scheme     WeChat   WeChat AppKey   WXDC1E388C3822C80B      QQ / QZONE / TIM   Need to add two URL Scheme:  1, "Tencent" + Tencent QQ Internet App AppID  2, "QQ" + Tencent QQ Internet Application AppID into a hexadecimal (less than 8 front to supplement 0)   such as Appid: 100424468 1, Tencent100424468  2, QQ05FC5B14   QQ05FC5B14 is 100424468 to sixteen Come, due to less than 8 bits, then add "QQ" prefix     Sina Weibo   "WB" + Sina APPKEY     6. In the initialization of U-Share and third-party platforms    (1) introduced in appdelegate.m    (1) Header: #import  [Direct copy]    (2) Setting Friends Key in LaunchOption [Direct copying】    
/ * Open debug log * /[[UMSocialManager DefaultManager] OpenLog: YES]; / * set Friends of the AU appkey * /[[UMSocialManager defaultManager] setUmSocialAppkey: USHARE_DEMO_APPKEY]; [self configUSharePlatforms]; [self confitUShareSettings];

React Native第三方平台分享的实例(Android,IOS双平台) ( 3) Add the following code under the appdelegate.m file, configure a third party platform [directly copy]

LaunchOptions: / * turn on debug logging * /[[UMSocialManager defaultManager] openLog: YES]; / * set the League of Friends appkey * /[[UMSocialManager defaultManager] setUmSocialAppkey: @ “59783b11f29d981b2f000984”]; [self configUSharePlatforms]; [self confitUShareSettings]; nsappTransportSecurity – (void) ConfigusharPlatforms {/ * Setting WeChat AppKey and AppSecret [WeChat platform from U-Share 4/5 upgrade] http://dev.umeng.com/social/ios/%E8%BF%9B% E9% 98% B6% E6% 96% 87% E6% A1% A3 # 1_1 * /[[UMSocialManager defaultManager] setPlaform: UMSocialPlatformType_WechatSession appKey: @ “wxdc1e388c3822c80b” appSecret: @ “3baf1193c85774b3fd9d18447d76cab0” redirectURL: nil]; / * * shift in addition to sharing the appropriate platform, such as a micro-channel Favorites * / //[[UMSocialManager defaultManager] removePlatformProviderWithPlatformTypes: @ [@ (UMSocialPlatformType_WechatFavorite)]]; / * set share QQ interconnected appID * U-Share SDK platform to be compatible with most of the named Unified use appKey and Appsecret parameter settings, while the QQ platform only needs AppID as U-Share AppKeThe Y parameter is passed. 100424468.No Permission of union ID [QQ / QZONE platform integration] http://dev.umeng.com/social/ios/%e8%BF%9B%E9%98%B6%E6%96%87%E6% A1% A3 # 1_3 * /[[UMSocialManager defaultManager] setPlaform: UMSocialPlatformType_QQ appKey: @ “1105821097” / * set appID QQ platform * / appSecret: nil redirectURL: @ “http://mobile.umeng.com/social”] ; / * Set Sina’s AppKey and AppsecRet [Sina Weibo Integration Description] http://dev.umeng.com/social/ios/%E8%BF%9B%E9%98%B6%E6%96%87%E6 % A1% A3 # 1_2 * /[[UMSocialManager defaultManager] setPlaform: UMSocialPlatformType_Sina appKey: @ “3921700954” appSecret: @ “04b48b094faeb16683c32669824ebdad” redirectURL: @ “https://sns.whalecloud.com/sina2/callback”]; / * Set Facebook AppKey and UrlString * / [UMSocialManager DefaultManager] setPlaform: umsocialPlatformType_Facebook AppKey: @ “506027402887373” Appsecret: Nil RedirectURL: NIL];}
– (VOID) Confitusharesettings {/ * * Opens Picture Water Print * / // [UMSocialglobal ShareInstance] .isusingwatermark = YES; / * * Close Forced Verification HTTPS, allow http images to be shared, but you need to set security domain name in Info.pl



(4) Setting up callback [Direct copy]


[OBJC] View Plain Copy- (Bool) Application: (UIApplication *) Application OpenURL: (NSURL *) URL SourceApplication: (NSString *) SourceApplication Annotation: (ID) Annotation {//6.3 New API call, for Compatible foreign platform (for example: new FacebookSDK, VK, etc.) call [If there is no callback with 6.2 API call], there is no impact on the domestic platform. BOOL RESULT =[[UMSocialManager DefaultManager] Handleopenurl: URL SourceApplication: SourceApplication Annotation: Annotation]; If (! result) {// other SDK, such as payment, etc., Return Result;}


7. In the iOS directory [ShareModule.h], [ShareModule. m] Document can be dragged into your project
[Sharing]
  Import us/share '; import shareplatform from'. / share / shareplatform ';  

/ ** * Parameter Description: * 1. Title * 2. Content * 3. Jump link * 4. Picture link * 5. Share platform * 6. Share results callback * / ushare.share (‘ Title ‘,’ content ‘,’ http://baidu.com ‘,’Http: //dev.umeng.com/images/tab2_1.png’, SharePlatform.qq, (Code, Message) => {// Share Success: code = 200 // TOASTANDROID.SHOW (Message, ToaStroid.short);});

The above is all the contents of this article, I hope to learn from everyone Help, I hope everyone will support Tumi Clouds.


© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment