- Installation
- Supported APIs
- Setup
- Create Zalo Application
- React Native CLI Project
- iOS
- Android
- Expo
- Usage
- Login
- Check if authenticated
- Get User Profile
- Logout
- Troubleshooting
- Demo
- Thank you
With npm: $ npm install react-native-zalo-kit
With yarn: $ yarn add react-native-zalo-kit
After that:
Below is list of supported APIs:
- Login
- isAuthenticated
- getUserProfile
- logout
See more here:
- iOS: https://developers.zalo.me/docs/sdk/ios-sdk/references/ma-loi
- Android: https://developers.zalo.me/docs/sdk/android-sdk/tong-quan
First of all you need to create Zalo application on Zalo Developer Portal
Note: when setting up Android platform for your application, it’ll ask you for a Hash key. We provide you a helper function to get that key
Next, go to Sản phẩm>Đăng nhập and configure for Android and iOS:
Enter your app package name, hash key, and bundle ID
After that you’ll get your Zalo App Key, and you’ll need to use it for next sections
Note 1: you’re recommended to turn your Zalo app to Live Mode in order to get full functionalities.
Run the following command to setup for iOS:
After that, open ios/<your_app_name>/AppDelegate.mm (or .swift), and add the following:
Swift:
Next, Open your app in Xcode (you have to use .xcworkspace file) -> Select your project under Targets -> select tab Info, select the last line and click +:
Then key in LSApplicationQueriesSchemes:
After that hit Enter, it’ll automatically change key name to Queried URL Schemes (type Array), then insert 2 items with value zalosdk and zaloshareext like below:
Next, still under tab Info -> URL Types -> Click + to add new with identifier zalo and URL Schemes is zalo-your_app_id
- Open android/build.gradle, and check the minSdkVersion if it’s < 18 then make it 18 otherwise leave default:
- Open android/app/src/main/java/<your_app_package>/MainActivity.(java|kt), and add the following:
Java:
Kotlin
- After that, open android/app/src/main/java/<your_app_package>/MainApplication.(java|kt), and add the following:
Java:
Kotlin:
- Add appID to android/app/src/main/res/values/strings.xml
- Add the following to android/app/src/main/AndroidManifest.xml :
- In android/app/src/proguard-rules.pro add the following:
First you need to eject ios/android native code:
Then following the same steps as RN CLI project above
login supports the following methods:
- AUTH_VIA_APP_OR_WEB: login via app or web. If user has Zalo app then login with app, otherwise using web
- AUTH_VIA_APP: login using Zalo app only
- AUTH_VIA_WEB: login using Zalo web only
This method is only available for IP in Vietnam
- Android: the parameter pkg_name and sign_key are required
This error happens because of your configuration on Zalo Developer Portal for Android is not correct, review your setup and make sure they’re correct:
- Check your package name
- Check your Application Hash Key: you can use the function getApplicationHashKey to check the key of your app.
- “Application is not registered for this request”
Make sure that you have request for all permissions needed from Zalo Developer portal:
Approval process is easy, so just request for everything 🙂
Check Supported APIs also
- “The application is not approved”
Check that your configuration on Zalo Developer Portal is correct: Bundle/Package ID, app hash key, request for permissions, app ID is correct,…
- “Bạn chưa cài Zalo”
Make sure in Manifest.xml you add the following:
To run the demo project, run the following commands:
If you like this project, encourage me by giving me a ⭐️. Happy hacking