完善facebook登录

This commit is contained in:
zhl 2023-02-08 16:21:52 +08:00
parent e055eaba7f
commit 2cd244f3d3
4 changed files with 35 additions and 0 deletions

3
src/JCWallet.d.ts vendored
View File

@ -18,6 +18,9 @@ declare namespace jsb {
export function signWithGoogle(id: number); export function signWithGoogle(id: number);
export function signWithApple(id: number); export function signWithApple(id: number);
export function signWithTikTok(id: number); export function signWithTikTok(id: number);
export function signWithFacebook(id: number);
export function callJcVoidMethodJNI(id: number, methodName: string);
export function signWithTwitter(id: number);
export function signOutGoogle(id: number); export function signOutGoogle(id: number);
export function scanQRCode(id: number, title: string); export function scanQRCode(id: number, title: string);
export function restoreKey(id: number, oid: string); export function restoreKey(id: number, oid: string);

View File

@ -16,6 +16,16 @@ export function tikTokAuth(idToken: string) {
return POST_JSON(url, { code: idToken }); return POST_JSON(url, { code: idToken });
} }
export function facebookAuth(idToken: string) {
const url = `${WALLET_API_HOST}/wallet/login/facebook`;
return POST_JSON(url, { code: idToken });
}
export function twitterAuth(idToken: string) {
const url = `${WALLET_API_HOST}/wallet/login/twitter`;
return POST_JSON(url, { code: idToken });
}
export function getWalletInfo() { export function getWalletInfo() {
const url = `${WALLET_API_HOST}/wallet/info`; const url = `${WALLET_API_HOST}/wallet/info`;
return GET_JSON(url); return GET_JSON(url);

View File

@ -4,9 +4,11 @@ import { loadMnemonic, saveMnemonic } from "./DataManage";
import { NativeSvr } from "../services/NativeSvr"; import { NativeSvr } from "../services/NativeSvr";
import { import {
appleAuth, appleAuth,
facebookAuth,
getWalletInfo, getWalletInfo,
googleAuth, googleAuth,
tikTokAuth, tikTokAuth,
twitterAuth,
uploadWalletInfo, uploadWalletInfo,
} from "../api/WalletApi"; } from "../api/WalletApi";
import { WalletEnv } from "../config/WalletEnv"; import { WalletEnv } from "../config/WalletEnv";
@ -46,6 +48,14 @@ export async function loadInternalWallet(channel: number) {
let res: any = await new NativeSvr().signWithTikTok(); let res: any = await new NativeSvr().signWithTikTok();
console.log("native tiktok res: " + res); console.log("native tiktok res: " + res);
tokenRes = await tikTokAuth(res); tokenRes = await tikTokAuth(res);
} else if (channel == 3) {
let res: any = await new NativeSvr().signWithFacebook();
console.log("native facebook res: " + res);
tokenRes = await facebookAuth(res);
} else if (channel == 4) {
let res: any = await new NativeSvr().signWithTwitter();
console.log("native twitter res: " + res);
tokenRes = await twitterAuth(res);
} else { } else {
let res: any = await new NativeSvr().signWithGoogle(); let res: any = await new NativeSvr().signWithGoogle();
console.log("native google res: " + res); console.log("native google res: " + res);

View File

@ -46,6 +46,18 @@ export class NativeSvr {
return this._subscribeToCallResponse(id); return this._subscribeToCallResponse(id);
} }
public signWithFacebook() {
let id = payloadId();
jsb.callJcVoidMethodJNI(id, "signWithFacebook");
return this._subscribeToCallResponse(id);
}
public signWithTwitter() {
let id = payloadId();
jsb.callJcVoidMethodJNI(id, "signWithTwitter");
return this._subscribeToCallResponse(id);
}
public signOutGoogle() { public signOutGoogle() {
let id = payloadId(); let id = payloadId();
jsb.signOutGoogle(id); jsb.signOutGoogle(id);