UNPKG

915 BPlain TextView Raw
1import { UnavailabilityError } from '@unimodules/core';
2
3import ExponentFacebook from './ExponentFacebook';
4
5type FacebookLoginResult = {
6 type: string;
7 token?: string;
8 expires?: number;
9};
10
11type FacebookOptions = {
12 permissions?: string[];
13 behavior?: 'web' | 'native' | 'browser' | 'system';
14};
15
16export async function logInWithReadPermissionsAsync(
17 appId: string,
18 options?: FacebookOptions
19): Promise<FacebookLoginResult> {
20 if (!ExponentFacebook.logInWithReadPermissionsAsync) {
21 throw new UnavailabilityError('Facebook', 'logInWithReadPermissionsAsync');
22 }
23 if (typeof appId !== 'string') {
24 console.warn(
25 `logInWithReadPermissionsAsync: parameter 'appId' must be a string, was '${typeof appId}''.`
26 );
27 appId = String(appId);
28 }
29
30 if (!options || typeof options !== 'object') {
31 options = {};
32 }
33 return ExponentFacebook.logInWithReadPermissionsAsync(appId, options);
34}