npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zalo-auth-capacitor-plugin

v1.0.1

Published

Authenticate by Zalo through Capacitor

Downloads

25

Readme

zalo-auth-capacitor-plugin

Zalo Authenticate through CapacitorJS

Currently, I don't plan for maintainance. Instead, mail to me ([email protected]) if need any help. Thanks for using my plugins!

🎉 Happy to check your Pull Request at anytime.

Installation:

npm install zalo-auth-capacitor-plugin
npx cap sync

Configuration:

1. iOS:

1. In ios/App/Podfile:

Inside target 'App', append:

target 'App' do
  capacitor_pods
  # Add your Pods here
  ...
  pod 'ZaloSDK'
  ...
end

2. In ios/App/App/AppDelegate.swift:

  1. Add to import list:
import ZaloSDK
  1. Inside AppDelegate class, take changes in 2 methods below:
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ...
    ZaloSDK.sharedInstance()?.initialize(withAppId: "APP_ID_FROM_ZALO_DEVELOPER");
    ...
    return true
  }
  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    ...
    if CAPBridge.handleOpenUrl(url, options) {
      if url.absoluteString.hasPrefix("zalo-APP_ID_FROM_ZALO_DEVELOPER") {
        return ((ZDKApplicationDelegate.sharedInstance()?.application(app, open: url, options: options)) != nil);
      }
    }
    ...
    return false;
  }

2. In ios/App/App/Info.plist:

Append or fill out these lines:

...
<key>CFBundleURLTypes</key>
<array>
  ...
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>zalo</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>zalo-APP_ID_FROM_ZALO_DEVELOPER</string>
    </array>
  </dict>
  ...
</array>
...

2. Android:

1. In android/src/build.gradle:

Inside dependencies { ... }, append:

implementation "com.zing.zalo.zalosdk:core:+"
implementation "com.zing.zalo.zalosdk:auth:+"
implementation "com.zing.zalo.zalosdk:openapi:+"

2. In android/src/main/java/..../MainActivity.java:

  1. Import class.
    import com.zing.zalo.zalosdk.oauth.ZaloSDK;
  2. In the callback of `this.init(savedInstanceState, ....), append:
    add(com.rin.zaloauth.ZaloAuthCapacitorPlugin.class);
  3. In onActivityResult method, under super.onActivityResult(requestCode, resultCode, data); append:
    ZaloSDK.Instance.onActivityResult(this, requestCode, resultCode, data);

3. In android/src/main/res/values/strings.xml:

Inside resources, create Zalo App on Zalo Developer, get back APP_ID (may be similar 42735613396xxxx150):

<resources>
    ...
    <string name="zalo_app_id">APP_ID_FROM_ZALO_DEVELOPER</string>
    <string name="zalo_login_protocol_scheme">zalo-APP_ID_FROM_ZALO_DEVELOPER</string>
    ...
</resources>

4. In android/src/main/AndroidManifest.xml:

  1. Add name attribute to your application.
<application
    android:name="com.zing.zalo.zalosdk.oauth.ZaloSDKApplication"
    ...
>
    ...
    <meta-data 
        android:name="com.zing.zalo.zalosdk.appID"   
        android:value="@string/zalo_app_id" 
    />
    <activity
        android:name="com.zing.zalo.zalosdk.oauth.BrowserLoginActivity"
    >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/zalo_login_protocol_scheme" />
        </intent-filter>
    </activity>

    ...
</application>

5. Create Zalo Service for using in your application: (web has not implemented yet)

import { Injectable } from '@angular/core';
import { Plugins } from '@capacitor/core';
import { isPlatform } from '@ionic/angular';
import {
  ShareInput,
  ZaloAuthCapacitorPlugin,
  ZaloAuthCapacitorPluginPlugin,
} from 'zalo-auth-capacitor-plugin';

@Injectable({ providedIn: 'root' })
export class LoginZaloService {
  private _zaloLogin: ZaloAuthCapacitorPluginPlugin;

  constructor() {
    this._setupZaloLogin();
  }
  async login() {
    return this._zaloLogin.login();
  }
  async getUserProfileFromZalo() {
    return this._zaloLogin.getUserProfile();
  }
  logout() {
    return this._zaloLogin.logout();
  }
  share(input: ShareInput) {
    return this._zaloLogin.share(input);
  }
  private _setupZaloLogin() {
    if (isPlatform('desktop')) {
      this._zaloLogin = ZaloAuthCapacitorPlugin;
    } else {
      this._zaloLogin = Plugins.ZaloAuthCapacitorPlugin as ZaloAuthCapacitorPluginPlugin;
    }
  }
}