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

nativescript-wechat-login-knotes

v1.0.8

Published

Wechat Login plugin for nativescript. it is forked from https://github.com/jibon57/nativescript-wechat-login.git with fix for universal link

Downloads

17

Readme

NativeScript WeChat login plugin

npm npm npm

Using this plugin you will be able implement wechat login feature in your APP. You can read more details from here

Installation

tns plugin add nativescript-wechat-login-knotes

If you are using NativeScript 5.4.X then you can have a look this branch

Android

If installation was successful then wxapi.WXEntryActivity.android.ts file should be create to your src or app (based on nsconfig.json or webpack.config.js appPath value) directory with your APP ID. If it wasn't successfully created then you will have to create that file manually. You can get code of that file from here. In this case you will require to change YOUR_APP_ID to your app's ID.

If you don't have wxapi.WXEntryActivity.android.ts file in your src or app directory then Android won't receive notification from wechat.

Webpack

You will have to add wxapi.WXEntryActivity.android.ts in your webpack.config.js file so that android runtime can generate appropriate java class. Check the demo custom-webpack.config.js file. You can read here for details.

If you are using NativeScript version 6.4.0 or newer then you can create custom custom-webpack.config.js file & add that file in your nsconfig.json file as below

custom-webpack.config.js

const webpackConfig = require("./webpack.config");
const path = require("path");

module.exports = env => {

    env = env || {};

    const cnf = webpackConfig(env);

    env.appComponents = env.appComponents || [];
    env.appComponents.push(path.resolve(cnf.context, "wxapi.WXEntryActivity.android.ts")); 

    const config = webpackConfig(env);

    return config;
}

nsconfig.json

...
"webpackConfigPath": "./custom-webpack.config.js"

For NativeScript version 6.3.0 or older edit webpack.config.js manually.

const appComponents = [
    "tns-core-modules/ui/frame",
    "tns-core-modules/ui/frame/activity",
    resolve(__dirname, "src/wxapi.WXEntryActivity.android.ts") // or resolve(__dirname, "app/wxapi.WXEntryActivity.android.ts") depends on nsconfig.json or webpack.config.js file's appPath value.
];

iOS

Open your Info.plist file from App_Resources/iOS location & add following lines

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLName</key>
		<string>weixin</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>WECHAT_APP_ID</string>
		</array>
	</dict>
</array>

Change WECHAT_APP_ID with your Wechat App ID. Check demo project demo/App_Resources/iOS/Info.plist

Usage

For details you can check the demo project.

In your main.ts or app.ts need to import initWechatSdk(WECHAT_APP_ID, UNIVERSAL_LINK) method with wechat app id.

....
import { initWechatSdk } from "nativescript-wechat-login-knotes";

initWechatSdk("wxd930ea5d5a258f4f", "https://www.your.app.universal.link");

In any other page

....
import { WechatLogin } from "nativescript-wechat-login-knotes";
import * as app from "tns-core-modules/application";

Now call in a method

let wechat = new WechatLogin();

if (wechat.isWechatInstalled()) {
    wechat.doLogin("nativescript_demo");
} else {
    console.log("wechat isn't installed")
}

You will get response from wxApiResponse event. So, you can register in that event like this:

app.on('wxApiResponse', function(res){
	console.dir(res) // you will get wechat notification here.
	console.dir(res.object) // information from wechat
}, this);

Ref:

https://open.wechat.com/cgi-bin/newreadtemplate?t=overseas_open/docs/mobile/login/guide#login_guide

https://github.com/aaronbruckner/wechatAndroidLoginDemo

License

Apache License Version 2.0, January 2004