-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (78 loc) · 2.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import PropTypes from "prop-types";
import React from "react";
import {
NativeModules,
NativeEventEmitter,
requireNativeComponent,
} from "react-native";
const { LoginKit, CreativeKit } = NativeModules;
class BitmojiStickerPicker extends React.Component {
render() {
return <BitmojiStickerPickerNative {...this.props} />;
}
}
BitmojiStickerPicker.propTypes = {
/**
* A Boolean value that determines whether the user may use pinch
* gestures to zoom in and out of the map.
*/
zoomEnabled: PropTypes.bool,
};
const BitmojiStickerPickerNative = requireNativeComponent(
"BitmojiStickerPicker"
);
// export const NativeLoginKit = NativeModules.SnapchatLogin;
// export const LoginKitEmitter = new NativeEventEmitter(NativeLoginKit);
class RNLoginKit {
static async login() {
try {
console.log("Attempting to login");
let result = await LoginKit.login();
if (result.error) {
console.log(result.error, "error");
throw new Error(result.error);
}
return await this.getUserInfo();
} catch (error) {
throw error;
}
}
static async isLoggedIn() {
const { result } = await LoginKit.isUserLoggedIn();
return result;
}
static async logout() {
const { result } = await LoginKit.logout();
return result;
}
static async refreshAccessToken() {
const { result } = await LoginKit.getAccessToken();
return result;
}
static async getUserInfo() {
try {
let tmp = await LoginKit.fetchUserData();
const data = tmp;
if (data === null) {
throw new Error("No User Info");
}
const res = await LoginKit.getAccessToken();
data.accessToken = res.accessToken;
return data;
} catch (error) {
throw error;
}
}
}
class RNCreativeKit {
static async shareSticker(options) {
// options: stickerUrl, swipeUpUrl, caption
const { result } = await CreativeKit.shareSticker(options);
return result;
}
}
class RNBitmojiKit {}
exports.LoginKit = RNLoginKit;
exports.CreativeKit = RNCreativeKit;
exports.BitmojiKit = RNBitmojiKit;
exports.BitmojiStickerPicker = BitmojiStickerPicker;