JSPM

react-native-zalo-share

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 33
  • Score
    100M100P100Q59869F
  • License MIT

share message, share feed zalo in app

Package Exports

  • react-native-zalo-share

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-zalo-share) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-native-zalo-share

Installation

yarn add react-native-zalo-share
  • React Native 0.60 and higher
 cd ios
 pod install
 cd ..
  • React Native 0.59 and lower
react-native link react-native-zalo-share

ANDROID

  • add implementation "com.zing.zalo.zalosdk:auth:+" => android/app/build.gradle
    dependencies {
        ...
        implementation "com.zing.zalo.zalosdk:auth:+"
        ...
    }
  • add appZaloID => res/values/strings/xml
    <resources>
      <string name="app_name">example</string>
      <string name="appZaloID">{"appID"}</string>
    </resources>
  • edit file AndroidManifest.xml
    <application
      ...
      <activity android:name="com.zing.zalo.zalosdk.oauth.OpenAPIActivity" />
      <meta-data
          android:name="com.zing.zalo.zalosdk.appID"
          android:value="@string/appZaloID" />
        ...
    </application>
  • edit file MainApplication.java
    import com.zing.zalo.zalosdk.oauth.ZaloSDKApplication;
    ...
    @Override
    public void onCreate() {
        ...
        ZaloSDKApplication.wrap(this);
        ...
    }

IOS

  • edit file AppDelegate.m
   #import <ZaloSDK/ZaloSDK.h>
   ...
   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {
     ...

     [[ZaloSDK sharedInstance] initializeWithAppId:@"yourappID"];

     return YES;
   }
   
   // add override func
   - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id>        *)options {
       return [
         [ZDKApplicationDelegate sharedInstance]
         application:app
         openURL:url
         sourceApplication:nil
         annotation:nil
       ];
}
  • add URL Type Main target setting -> info -> URL types -> click + identifier = “zalo”, URL Schemes = “zalo-yourappid”

  • add Schemes LSApplicationQueriesSchemes Info.plist Info.plist -> + LSApplicationQueriesSchemes -> item -> "zalo"

Usage

import ZaloShare from 'react-native-zalo-share';

const config = {
  msg: 'message',
  link: '',
  linkTitle: '',
  linkSource: '',
  linkThumb: '',
   appName: '', // appname back to app when cancel
};

const App: () => React$Node = () => {
  const onShareMessage = () => {
    ZaloShare.shareMessage(config)
      .then(console.log(' 👉🏼 send data to zalo success'))
      .catch(error => console.log(' 👉🏼 error message', error.message));
  };

  const onShareFeed = () => {
    ZaloShare.shareFeed(config)
      .then(console.log(' 👉🏼 send data to zalo success'))
      .catch(error => console.log(' 👉🏼 error message', error.message));
  };

  return (
    <SafeAreaView style={styles.container}>
      <Button title="share Message" onPress={onShareMessage} />
      <Button title="share Feed" onPress={onShareFeed} />
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    alignItems: 'center',
    justifyContent: 'center',
    flex: 1,
  },
});

export default App;