Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export interface ITextShareData {
type: "text";
text: string;
}

export interface IImageShareData {
type: "image";
imageUrl: string;
title: string;
description: string;
}

export interface IWebShareData {
type: "news";
imageUrl: string;
webpageUrl: string;
title: string;
description: string;
}

export interface IPayReq {
partnerId: string;
prepayId: string;
nonceStr: string;
timeStamp: string;
package: string;
sign: string;
}

export interface IPayResp {
errCode: number;
errMsg: string;
appid: string;
returnKey: string;
}

export interface ILoginResp {
code: string;
appid: string;
lang: string;
country: string;
errCode?: number;
errMsg?: string;
}

export function isWXAppInstalled(): Promise<boolean>;

export function isWXAppSupportApi(): Promise<boolean>;

export function login(data: { scope: string }): Promise<ILoginResp>;

export function shareToTimeline(
data: ITextShareData | IImageShareData | IWebShareData
): Promise<void>;

export function shareToSession(
data: ITextShareData | IImageShareData | IWebShareData
): Promise<void>;

export function pay(data: IPayReq): Promise<IPayResp>;
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NativeAppEventEmitter, NativeModules } from 'react-native';
import promisify from 'es6-promisify';
import Promise from 'bluebird';

const WeChatAPI = NativeModules.WeChatAPI;

Expand Down Expand Up @@ -57,7 +57,7 @@ function wrapCheckApi(nativeFunc) {
return undefined;
}

const promisified = promisify(nativeFunc, translateError);
const promisified = Promise.promisify(nativeFunc, translateError);
return (...args) => {
return promisified(...args);
};
Expand All @@ -71,7 +71,7 @@ function wrapApi(nativeFunc) {
return undefined;
}

const promisified = promisify(nativeFunc, translateError);
const promisified = Promise.promisify(nativeFunc, translateError);
return async function (...args) {
if (!WeChatAPI.isAppRegistered) {
throw new Error('注册应用失败');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"homepage": "https://github.com/reactnativecn/react-native-wx#readme",
"dependencies": {
"es6-promisify": "^3.0.0"
"bluebird": "^3.5.1"
},
"peerDependencies": {
"react-native": "^0.33.0"
Expand Down