From 60dce20e910d593a6c8a221bca63b0b98ca69f0b Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Sun, 9 Jul 2017 16:45:37 +0100 Subject: [PATCH] add basic tests for rect-native-fbsdk remove unneeded namespace export fix typo in AppEventsFlushBehavior remove top level namespace Also fix typos. --- types/react-native-fbsdk/index.d.ts | 2077 +++++++++-------- .../react-native-fbsdk-tests.tsx | 127 +- types/react-native-fbsdk/tsconfig.json | 4 +- 3 files changed, 1155 insertions(+), 1053 deletions(-) diff --git a/types/react-native-fbsdk/index.d.ts b/types/react-native-fbsdk/index.d.ts index c27fdb7671..8a07d47e88 100644 --- a/types/react-native-fbsdk/index.d.ts +++ b/types/react-native-fbsdk/index.d.ts @@ -5,1035 +5,1066 @@ // TypeScript Version: 2.3 import { ComponentClass, Component } from 'react'; -import { StyleSheet } from 'react-native'; -import { LoginManager } from 'react-native-fbsdk'; -declare namespace FBSDK { +import { ViewStyle } from 'react-native'; + +/** + * Commonly used Facebook permissions + */ +export type Permissions = 'public_profile' + | 'user_friends' + | 'email' + | 'user_about_me' + | 'user_actions.books' + | 'user_actions.fitness' + | 'user_actions.music' + | 'user_actions.news' + | 'user_actions.video' + | 'user_birthday' + | 'user_education_history' + | 'user_events' + | 'user_games_activity' + | 'user_hometown' + | 'user_likes' + | 'user_location' + | 'user_managed_groups' + | 'user_photos' + | 'user_posts' + | 'user_relationships' + | 'user_relationship_details' + | 'user_religion_politics' + | 'user_tagged_places' + | 'user_videos' + | 'user_website' + | 'user_work_history' + | 'read_custom_friendlists' + | 'read_insights' + | 'read_audience_network_insights' + | 'read_page_mailboxes' + | 'manage_pages' + | 'publish_pages' + | 'publish_actions' + | 'rsvp_event' + | 'pages_show_list' + | 'pages_manage_cta' + | 'pages_manage_instant_articles' + | 'ads_read' + | 'ads_management' + | 'business_management' + | 'pages_messaging' + | 'pages_messaging_subscriptions' + | 'pages_messaging_payments' + | 'pages_messaging_phone_number' + | string; + +/** + * Specifies the privacy of a group. + */ +export type AppGroupPrivacy = + // Anyone can see the group, who's in in and what members post. + 'Open' | + // Anyone can see the group and who's in it, but only members can see posts. + 'Closed'; + +/** + * A model for app groups. + */ +export interface AppGroupCreationContent { /** - * Specifies the privacy of a group. + * The description of the group. */ - type AppGroupPrivacy = - // Anyone can see the group, who's in in and what members post. - 'Open' | - // Anyone can see the group and who's in it, but only members can see posts. - 'Closed'; + description: string; /** - * A model for app invites. + * The name of the group. */ - interface AppGroupCreationContent { - /** - * The description of the group. - */ - description: string; - - /** - * The name of the group. - */ - name: string; - - /** - * The privacy for the group. - */ - privacy: AppGroupPrivacy; - } + name: string; /** - * A model for app invites. + * The privacy for the group. */ - interface AppInviteContent { - /** - * A URL to a preview image that will be displayed with the app invite. - * This is optional. If you don't include it, a fallback image will be used. - */ - previewImageUrl?: string; - - /** - * An app link target that will be used as a target when the user accepts the invite. - */ - applinkUrl: string; - - /** - * Promotional code to be displayed while sending and receiving the invite. - * This is optional. This can be between 0 and 10 characters long and can contain - * alphanumeric characters only. To set a promo code, you need to set promo text. - */ - promotionCode?: string; - - /** - * Promotional text to be displayed while sending and receiving the invite. - * This is optional. This can be between 0 and 80 characters long and can contain - * alphanumeric and spaces only. - */ - promotionText?: string; - } - - type GameRequestActionType = - // The user is sending an object to their friends. - 'send' | - // The user is asking for an object from friends. - 'askfor' | - // It is the turn of the friends to play against the user in a match. - 'turn'; - - type GameRequestFilters = - // Friends using the app can be displayed. - 'app_users' | - // Friends not using the app can be displayed. - 'app_non_users'; - - /** - * A model for a game request. - */ - interface GameRequestContent { - /** - * A plain-text message to be sent as part of the request. Required. - */ - message: string; - - /** - * Used when defining additional context about the nature of the request. - * The parameter 'objectID' is required if the action type is either 'send' or 'ask-for'. - */ - actionType?: GameRequestActionType; - - /** - * Additional freeform data you may pass for tracking. The maximum length is 255 characters. - */ - data?: string; - - /** - * Controls the set of friends someone sees if a multi-friend selector is shown. - */ - filters?: GameRequestFilters; - - /** - * The Open Graph object ID of the object being sent/asked for. This cannot be null for ActionType SEND and - * ASKFOR. - */ - objectId?: string; - - /** - * An array of user IDs, usernames or invite tokens of people to send requests to. - */ - recipients?: string[]; - - /** - * An array of user IDs that will be included in the dialog as the first suggested friends. - * Can't be used together with filters. - */ - suggestions?: string[]; - - /** - * The title for the dialog. - */ - title?: string; - } - - type ObjectIdActionType = 'unknown' | 'open_graph' | 'page'; - - /** - * A base interface for content to be shared. - */ - interface ObjectIdAndType { - /** - * The object ID, this can be a URL or a Facebook ID. - */ - objectId: string; - - /** - * Encapsulates the valid values for the facebook:object_type - * attribute for a LikeView - */ - objectType: ObjectIdActionType; - } - - type ShareContent = ShareLinkContent | SharePhotoContent | ShareVideoContent | ShareOpenGraphContent; - /** - * A base interface for content to be shared. - */ - interface ShareContentCommonParameters { - /** - * List of IDs for taggable people to tag with this content. - */ - peopleIds?: string[]; - - /** - * The ID for a place to tag with this content. - */ - placeId?: string; - - /** - * A value to be added to the referrer URL when a person follows a link from - * this shared content on feed. - */ - ref?: string; - - /** - * A hashtag to be added to the share interface. The hashtag must be 32 characters or less. - */ - hashtag?: string; - } - - /** - * A model for status and link content to be shared. - */ - interface ShareLinkContent { - /** - * The type of content to be shared is link. - */ - contentType: 'link'; - - /** - * Common parameters for share content; - */ - commonParameters?: ShareContentCommonParameters; - - /** - * URL for the content being shared. - */ - contentUrl: string; - - /** - * The Description of the link. - * If not specified, this field is automatically populated by information scraped - * from the contentURL, typically the title of the page. - * @deprecated `contentDescription` is deprecated from Graph API 2.9. - * For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations. - */ - contentDescription?: string; - - /** - * The title to display for this link. - * @deprecated `contentTitle` is deprecated from Graph API 2.9. - * For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations. - */ - contentTitle?: string; - - /** - * The URL of a picture to attach to this comment. - * @deprecated `imageUrl` is deprecated from Graph API 2.9. - * For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations. - */ - imageUrl?: string; - - /** - * The predefined quote to attach to this comment. - * If specified, the quote text will render with custom styling on top of the link. - */ - quote?: string; - } - - interface OpenGraphProperties { - [key: string]: OpenGraphValue; - } - - interface OpenGraphValue { - type: OpenGraphValueType; - - value: any; - } - - type OpenGraphValueType = - 'number' | - 'open-graph-object' | - 'photo' | - 'string'; - - interface ShareOpenGraphValueContainer { - /** - * Sets a number for the specified key. - */ - // tslint:disable-next-line:variable-name - putNumber(key: string, number: number): void; - - /** - * Sets an open graph object for the specified key. - */ - putObject(key: string, object: ShareOpenGraphValueContainer): void; - - /** - * Sets a photo for the specified key. - */ - putPhoto(key: string, photo: SharePhoto): void; - - /** - * Sets a string for the specified key. - */ - // tslint:disable-next-line:variable-name - putString(key: string, string: string): void; - - /** - * Gets an entry for the given key. - */ - getEntry(key: string): OpenGraphValue; - } - - /** - * Represents an interface for adding and retrieving values to open graph objects and actions. - */ - class ShareOpenGraphValueContainer { - private _properties: OpenGraphProperties; - - constructor(properties: OpenGraphProperties); - } - - /** - * Represents an open graph action. - */ - class ShareOpenGraphAction extends ShareOpenGraphValueContainer { - /** - * The action type. - */ - actionType: string; - - constructor(actionType: string); - } - - /** - * Represents a content object containing information about an Open Graph Action. - */ - interface ShareOpenGraphContent { - /** - * The type of content to be shared is open graph content. - */ - contentType: 'open-graph'; - - /** - * Common parameters for share content; - */ - commonParameters?: ShareContentCommonParameters; - - /** - * URL for the content being shared. - */ - contentUrl?: string; - - /** - * Open Graph Action to be shared. - */ - action: ShareOpenGraphAction; - - /** - * Property name that points to the primary Open Graph Object in the action. - */ - previewPropertyName: string; - } - - /** - * Represents an open graph object. - */ - class ShareOpenGraphObject extends ShareOpenGraphValueContainer {} - - /** - * A photo for sharing. - */ - interface SharePhoto { - /** - * The URL to the photo. - * Note that when sharing SharePhotoContent with Share Button, the imageUrl - * of a SharePhoto cannot be the Uri of an image on the web. - */ - imageUrl: string; - - /** - * Specifies whether the photo was generated by the user or the application. - */ - userGenerated?: boolean; - - /** - * The user generated caption for the photo. Note that the 'caption' must - * come from the user, as pre-filled content is forbidden by the platform - * Policies (2.3). - */ - caption?: string; - } - - /** - * A model for photo content to be shared. - */ - interface SharePhotoContent { - /** - * The type of content to be shared is photo. - */ - contentType: 'photo'; - - /** - * Common parameters for share content; - */ - commonParameters?: ShareContentCommonParameters; - - /** - * URL for the content being shared. - */ - contentUrl?: string; - - /** - * Photos to be shared. - */ - photos: SharePhoto[]; - } - - /** - * A video for sharing. - */ - interface ShareVideo { - /** - * The URL to the video. Must point to the location of the video on disk. - */ - localUrl: string; - } - - /** - * A model for video content to be shared. - */ - interface ShareVideoContent { - /** - * The type of content to be shared is photo. - */ - contentType: 'video'; - - /** - * Common parameters for share content; - */ - commonParameters?: ShareContentCommonParameters; - - /** - * URL for the content being shared. - */ - contentUrl?: string; - - /** - * Video to be shared. - */ - video: ShareVideo; - - /** - * Description of the video. - */ - contentDescription?: string; - - /** - * Title of the video. - */ - contentTitle?: string; - - /** - * The photo that represents the video. - */ - previewPhoto?: SharePhoto; - } - - interface AccessTokenMap { - accessToken: string; - applicationID: string; - userID: string; - permissions: string[]; - declinedPermissions: string[]; - accessTokenSource?: string; - expirationTime: number; - lastRefreshTime: number; - } - - /** - * Represents an immutable access token for using Facebook services. - */ - class AccessToken { - /** - * The access token string. - */ - accessToken: string; - - /** - * The app ID. - */ - applicationID: string; - - /** - * The user ID. - */ - userID: string; - - /** - * The known granted permissions. - */ - permissions: string[]; - - /** - * The known declined permissions. - */ - declinedPermissions: string[]; - - /** - * The source of access token. - * @platform android - */ - accessTokenSource?: string; - - /** - * The expiration time of the access token. - * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT. - */ - expirationTime: number; - - /** - * The last refresh time of the access token. - * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT. - */ - lastRefreshTime: number; - /** - * Getter for the access token that is current for the application. - */ - static getCurrentAccessToken(): Promise; - - /** - * Setter for the access token that is current for the application. - */ - static setCurrentAccessToken(accessToken: AccessTokenMap): void; - - /** - * Updates the current access token with up to date permissions, - * and extends the expiration date, if extension is possible. - */ - - static refreshCurrentAccessTokenAsync(): Promise; - - constructor(tokenMap: AccessTokenMap); - - /** - * Gets the date at which the access token expires. The value is the number of - * milliseconds since Jan. 1, 1970, midnight GMT. - */ - getExpires(): number; - - /** - * Get the list of permissions associated with this access token. Note that the most up-to-date - * list of permissions is maintained by Facebook, so this list may be outdated if permissions - * have been added or removed since the time the AccessToken object was created. See - * https://developers.facebook.com/docs/reference/login/#permissions for details. - */ - getPermissions(): string[]; - - /** - * Gets the list of permissions declined by the user with this access token. It represents the - * entire set of permissions that have been requested and declined. Note that the most - * up-to-date list of permissions is maintained by Facebook, so this list may be outdated if - * permissions have been granted or declined since the last time an AccessToken object was - * created. See https://developers.facebook.com/docs/reference/login/#permissions for details. - */ - getDeclinedPermissions(): string[]; - - /** - * Gets the date at which the token was last refreshed. Since tokens expire, the Facebook SDK - * will attempt to renew them periodically. The value is the number of milliseconds since - * Jan. 1, 1970, midnight GMT. - */ - getLastRefresh(): number; - - /** - * Gets the ID of the Facebook Application associated with this access token. - */ - getApplicationId(): string; - - /** - * Gets user ID associated with this access token. - */ - getUserId(): string; - } - - /** - * Controls when an AppEventsLogger sends log events to the server - */ - type AppEventsFlushBehavior = - /** - * Flush automatically: periodically (every 15 seconds or after every 100 events), and - * always at app reactivation. This is the default value. - */ - 'auto' | - /** - * Only flush when AppEventsLogger.flush() is explicitly invoked. - */ - 'explicity-only'; - - interface Params { - [key: string]: string | number; - } - - interface AppEventsLogger { - /** - * Sets the current event flushing behavior specifying when events - * are sent back to Facebook servers. - */ - setFlushBehavior(flushBehavior: AppEventsFlushBehavior): void; - - /** - * Logs an event with eventName and optional arguments. - * This function supports the following usage: - * logEvent(eventName: string); - * logEvent(eventName: string, valueToSum: number); - * logEvent(eventName: string, parameters: {[key:string]:string|number}); - * logEvent(eventName: string, valueToSum: number, parameters: {[key:string]:string|number}); - * See https://developers.facebook.com/docs/app-events/android for detail. - */ - logEvent(eventName: string, ...args: Array): void; - - /** - * Logs a purchase. See http://en.wikipedia.org/wiki/ISO_4217 for currencyCode. - */ - logPurchase(purchaseAmount: number, currencyCode: string, parameters?: object): void; - - /** - * Logs an app event that tracks that the application was open via Push Notification. - */ - logPushNotificationOpen(payload?: object): void; - - /** - * Explicitly kicks off flushing of events to Facebook. - */ - flush(): void; - - /** - * For iOS only, sets and sends device token to register the current application for push notifications. - * @platform ios - */ - setPushNotificationsDeviceToken(deviceToken: string): void; - - /** - * For Android only, sets and sends registration id to register the current app for push notifications. - * @platform Android - */ - setPushNotificationsRegistrationId(registrationId: string): void; - } - - const AppEventsLogger: AppEventsLogger; - - interface AppInviteDialog { - /** - * Check if the dialog can be shown. - */ - canShow(): Promise; - - /** - * Shows the dialog using the specified content. - */ - show(appInviteContent: AppInviteContent): Promise; - } - - const AppInviteDialog: AppInviteDialog; - - interface GameRequestDialog { - /** - * Check if the dialog can be shown. - */ - canShow(): Promise; - - /** - * Shows the dialog using the specified content. - */ - show(gameRequestContent: GameRequestContent): Promise; - } - - const GameRequestDialog: GameRequestDialog; - - type GraphRequestCallback = (error?: object, result?: object) => void; - interface GraphRequestConfig { - /** - * The httpMethod to use for the request, for example "GET" or "POST". - */ - httpMethod?: string; - /** - * The Graph API version to use (e.g., "v2.0") - */ - version?: string; - /** - * The request parameters. - */ - parameters?: GraphRequestParameters; - /** - * The access token used by the request. - */ - accessToken?: string; - } - - interface GraphRequestParameters { - [key: string]: object; - } - - /** - * Represents a Graph API request and provides batch request supports. - */ - class GraphRequest { - /** - * The Graph API endpoint to use for the request, for example "me". - */ - graphPath: string; - - /** - * The optional config for the request. - */ - config?: GraphRequestConfig; - - /** - * Called upon completion or failure of the request. - */ - callback?: GraphRequestCallback; - - /** - * Constructs a new Graph API request. - */ - constructor(graphPath: string, config?: GraphRequestConfig | null, callback?: GraphRequestCallback); - - /** - * Adds a string parameter to the request. - */ - addStringParameter(paramString: string, key: string): void; - } - - class GraphRequestManager { - requestBatch: GraphRequest[]; - requestCallbacks: Array; - batchCallback: GraphRequestCallback; - constructor(); - - /** - * Add a graph request. - */ - addRequest(request: GraphRequest): GraphRequestManager; - - /** - * Add call back to the GraphRequestManager. Only one callback can be added. - * Note that invocation of the batch callback does not indicate success of every - * graph request made, only that the entire batch has finished executing. - */ - addBatchCallback(callback: GraphRequestCallback): GraphRequestManager; - - /** - * Executes requests in a batch. - * Note that when there's an issue with network connection the batch callback - * behavior differs in Android and iOS. - * On iOS, the batch callback returns an error if the batch fails with a network error. - * On Android, the batch callback always returns {"result": "batch finished executing"} - * after the batch time out. This is because detecting network status requires - * extra permission and it's unncessary for the sdk. Instead, you can use the NetInfo module - * in react-native to get the network status. - */ - start(timeout?: number): void; - } - - type AuxiliaryViewPosition = 'top' | 'bottom' | 'inline'; - type HorizontalAlignment = 'center' | 'left' | 'right'; - type LikeViewStyle = 'button'| // Note 'button' is only available on Android. - 'standard' | - 'box_count'; - - interface LikeViewProps { - /** - * The objectId and type for the object to like. - */ - objectIdAndType: ObjectIdAndType; - - /** - * The style to use for the receiver. Distinct from React styling. - */ - likeViewStyle?: LikeViewStyle; - - /** - * The position for the auxiliary view for the receiver. - */ - auxiliaryViewPosition?: AuxiliaryViewPosition; - - /** - * The text alignment of the social sentence. - */ - horizontalAlignment?: HorizontalAlignment; - - /** - * The foreground color to use for the content of the receiver. - */ - foregroundColor?: number; - - /** - * If true, a sound is played when the receiver is toggled. - */ - soundEnabled?: boolean; - - /** - * View style, if any. - */ - style?: StyleSheet.Style; - } - - class LikeView extends Component {} - - type TooltipBehaviorIOS = 'auto' | 'force_display' | 'disable'; - - interface LoginButtonProps { - /** - * Represents the read permissions to request when the login button - * is pressed. - */ - readPermissions?: string[]; - - /** - * Represents the publish permissions to request when the login - * button is pressed. - */ - publishPermissions?: string[]; - - /** - * The callback invoked upon error/completion of a login request. - */ - onLoginFinished?(error: object, result: LoginResult): void; - - /** - * The callback invoked upon completion of a logout request. - */ - onLogoutFinished?(): void; - - /** - * The behavior to use when attempting a login. - * @platform android - */ - loginBehaviorAndroid?: LoginBehaviorAndroid; - - /** - * The behavior to use when attempting a login. - * @platform ios - */ - loginBehaviorIOS?: LoginBehaviorIOS; - - /** - * The default audience to target when attempting a login. - */ - defaultAudience?: DefaultAudience; - - /** - * For iOS only, the desired tooltip behavior. - * @platform ios - */ - tooltipBehaviorIOS?: TooltipBehaviorIOS; - - /** - * View style, if any. - */ - style?: StyleSheet.Style; - } - - class LoginButton extends Component { - private _eventHandler(event: object): void; - } - - /** - * Indicates which default audience to use for sessions that post data to Facebook. - */ - type DefaultAudience = - // Indicates that the user's friends are able to see posts made by the application. - 'friends' | - // Indicates that all Facebook users are able to see posts made by the application. - 'everyone' | - // Indicates that only the user is able to see posts made by the application. - 'only_me'; - - type LoginBehavior = LoginBehaviorIOS | LoginBehaviorAndroid; - - /** - * Indicate how Facebook Login should be attempted on Android. - */ - type LoginBehaviorAndroid = - // Attempt login in using the Facebook App, and if that does not work fall back to web dialog auth. - 'native_with_fallback'| - // Only attempt to login using the Facebook App. - 'native_only'| - // Only the web dialog auth should be used. - 'web_only'; - - /** - * Indicate how Facebook Login should be attempted on iOS. - */ - type LoginBehaviorIOS = - // Attempts log in through the native Facebook app. - // The SDK may still use Safari instead. - // See details in https://developers.facebook.com/blog/post/2015/10/29/Facebook-Login-iOS9/ - 'native' | - // Attempts log in through the Safari browser. - 'browser' | - // Attempts log in through the Facebook account currently signed in through Settings. - 'system_account' | - // Attempts log in through a modal UIWebView pop-up. - 'web'; - - /** - * Shows the results of a login operation. - */ - interface LoginResult { - isCancelled: boolean; - grantedPermissions?: string[]; - declinedPermissions?: string[]; - } - - interface LoginManager { - /** - * Logs the user in with the requested read permissions. - */ - logInWithReadPermissions(permissions: string[]): Promise; - - /** - * Logs the user in with the requested publish permissions. - */ - logInWithPublishPermissions(permissions: string[]): Promise; - - /** - * Getter for the login behavior. - */ - getLoginBehavior(): Promise; - - /** - * Setter for the login behavior. - */ - setLoginBehavior(loginBehavior: LoginBehavior): void; - - /** - * Getter for the default audience. - */ - getDefaultAudience(): Promise; - - /** - * Setter for the default audience. - */ - setDefaultAudience(defaultAudience: DefaultAudience): void; - - /** - * Logs out the user. - */ - logOut(): void; - } - - const LoginManager: LoginManager; - - interface MessageDialog { - /** - * Check if the dialog can be shown. - */ - canShow(shareContent: ShareContent): Promise; - - /** - * Shows the dialog using the specified content. - */ - show(shareContent: ShareContent): Promise; - - /** - * Sets whether or not the native message dialog should fail when it encounters a data error. - */ - setShouldFailOnDataError(shouldFailOnDataError: boolean): void; - } - - const MessageDialog: MessageDialog; - - interface SendButtonProps { - /** - * Content to be shared. - */ - shareContent: ShareContent; - - /** - * View style, if any. - */ - style?: StyleSheet.Style; - } - - class SendButton extends Component {} - - interface ShareApi { - /** - * Check if the content can be shared via share api. - */ - canShare(shareContent: ShareContent): Promise; - - /** - * For iOS only, creates a User Owned Open Graph object without an action. - * NOTE: Only one share action can be performed at a time. - * @platform ios - */ - createOpenGraphObject(openGraphObject: ShareOpenGraphObject): Promise; - - /** - * Shares the specified content with a message. - * NOTE: Only one share action can be performed at a time. - */ - share(shareContent: ShareContent, graphNode: string, message: string): Promise; - } - - const ShareApi: ShareApi; - - interface ShareButtonProps { - /** - * Content to be shared. - */ - shareContent: ShareContent; - - /** - * View style, if any. - */ - style?: StyleSheet.Style; - } - - class ShareButton extends Component {} - - type ShareDialogMode = ShareDialogModeIOS | ShareDialogModeAndroid; - type ShareDialogModeAndroid = - /** - * The mode is determined automatically. - */ - 'automatic'| - /** - * The native dialog is used. - */ - 'native'| - /** - * The web dialog is used. - */ - 'web'| - /** - * The feed dialog is used. - */ - 'feed'; - type ShareDialogModeIOS = - /* - * Acts with the most appropriate mode that is available. - */ - 'automatic'| - /* - * Displays the dialog in Safari. - */ - 'browser'| - /* - * Displays the dialog in a UIWebView within the app. - */ - 'webview'; - - interface ShareDialog { - /** - * Check if the dialog can be shown. - */ - canShow(shareContent: ShareContent): Promise; - - /** - * Shows the dialog using the specified content. - */ - show(shareContent: ShareContent): Promise; - - /** - * Sets the mode for the share dialog. - */ - setMode(mode: ShareDialogMode): void; - - /** - * Sets whether or not the native share dialog should fail when it encounters a data error. - */ - setShouldFailOnDataError(shouldFailOnDataError: boolean): void; - } - - const ShareDialog: ShareDialog; + privacy: AppGroupPrivacy; +} + +/** + * A model for app invites. + */ +export interface AppInviteContent { + /** + * A URL to a preview image that will be displayed with the app invite. + * This is optional. If you don't include it, a fallback image will be used. + */ + previewImageUrl?: string; + + /** + * An app link target that will be used as a target when the user accepts the invite. + */ + applinkUrl: string; + + /** + * Promotional code to be displayed while sending and receiving the invite. + * This is optional. This can be between 0 and 10 characters long and can contain + * alphanumeric characters only. To set a promo code, you need to set promo text. + */ + promotionCode?: string; + + /** + * Promotional text to be displayed while sending and receiving the invite. + * This is optional. This can be between 0 and 80 characters long and can contain + * alphanumeric and spaces only. + */ + promotionText?: string; +} + +export type GameRequestActionType = + // The user is sending an object to their friends. + 'send' | + // The user is asking for an object from friends. + 'askfor' | + // It is the turn of the friends to play against the user in a match. + 'turn'; + +export type GameRequestFilters = + // Friends using the app can be displayed. + 'app_users' | + // Friends not using the app can be displayed. + 'app_non_users'; + +/** + * A model for a game request. + */ +export interface GameRequestContent { + /** + * A plain-text message to be sent as part of the request. Required. + */ + message: string; + + /** + * Used when defining additional context about the nature of the request. + * The parameter 'objectID' is required if the action type is either 'send' or 'ask-for'. + */ + actionType?: GameRequestActionType; + + /** + * Additional freeform data you may pass for tracking. The maximum length is 255 characters. + */ + data?: string; + + /** + * Controls the set of friends someone sees if a multi-friend selector is shown. + */ + filters?: GameRequestFilters; + + /** + * The Open Graph object ID of the object being sent/asked for. This cannot be null for ActionType SEND and + * ASKFOR. + */ + objectId?: string; + + /** + * An array of user IDs, usernames or invite tokens of people to send requests to. + */ + recipients?: string[]; + + /** + * An array of user IDs that will be included in the dialog as the first suggested friends. + * Can't be used together with filters. + */ + suggestions?: string[]; + + /** + * The title for the dialog. + */ + title?: string; +} + +export type ObjectIdActionType = 'unknown' | 'open_graph' | 'page'; + +/** + * A base interface for content to be shared. + */ +export interface ObjectIdAndType { + /** + * The object ID, this can be a URL or a Facebook ID. + */ + objectId: string; + + /** + * Encapsulates the valid values for the facebook:object_type + * attribute for a LikeView + */ + objectType: ObjectIdActionType; +} + +export type ShareContent = ShareLinkContent | SharePhotoContent | ShareVideoContent | ShareOpenGraphContent; +/** + * A base interface for content to be shared. + */ +export interface ShareContentCommonParameters { + /** + * List of IDs for taggable people to tag with this content. + */ + peopleIds?: string[]; + + /** + * The ID for a place to tag with this content. + */ + placeId?: string; + + /** + * A value to be added to the referrer URL when a person follows a link from + * this shared content on feed. + */ + ref?: string; + + /** + * A hashtag to be added to the share interface. The hashtag must be 32 characters or less. + */ + hashtag?: string; +} + +/** + * A model for status and link content to be shared. + */ +export interface ShareLinkContent { + /** + * The type of content to be shared is link. + */ + contentType: 'link'; + + /** + * Common parameters for share content; + */ + commonParameters?: ShareContentCommonParameters; + + /** + * URL for the content being shared. + */ + contentUrl: string; + + /** + * The Description of the link. + * If not specified, this field is automatically populated by information scraped + * from the contentURL, typically the title of the page. + * @deprecated `contentDescription` is deprecated from Graph API 2.9. + * For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations. + */ + contentDescription?: string; + + /** + * The title to display for this link. + * @deprecated `contentTitle` is deprecated from Graph API 2.9. + * For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations. + */ + contentTitle?: string; + + /** + * The URL of a picture to attach to this comment. + * @deprecated `imageUrl` is deprecated from Graph API 2.9. + * For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations. + */ + imageUrl?: string; + + /** + * The predefined quote to attach to this comment. + * If specified, the quote text will render with custom styling on top of the link. + */ + quote?: string; +} + +export interface OpenGraphProperties { + [key: string]: OpenGraphValue; +} + +export interface OpenGraphValue { + type: OpenGraphValueType; + + value: any; +} + +export type OpenGraphValueType = + 'number' | + 'open-graph-object' | + 'photo' | + 'string'; + +export interface ShareOpenGraphValueContainer { + /** + * Sets a number for the specified key. + */ + // tslint:disable-next-line:variable-name + putNumber(key: string, number: number): void; + + /** + * Sets an open graph object for the specified key. + */ + putObject(key: string, object: ShareOpenGraphValueContainer): void; + + /** + * Sets a photo for the specified key. + */ + putPhoto(key: string, photo: SharePhoto): void; + + /** + * Sets a string for the specified key. + */ + // tslint:disable-next-line:variable-name + putString(key: string, string: string): void; + + /** + * Gets an entry for the given key. + */ + getEntry(key: string): OpenGraphValue; +} + +/** + * Represents an interface for adding and retrieving values to open graph objects and actions. + */ +export class ShareOpenGraphValueContainer { + private _properties: OpenGraphProperties; + + constructor(properties: OpenGraphProperties); +} + +/** + * Represents an open graph action. + */ +export class ShareOpenGraphAction extends ShareOpenGraphValueContainer { + /** + * The action type. + */ + actionType: string; + + constructor(actionType: string); +} + +/** + * Represents a content object containing information about an Open Graph Action. + */ +export interface ShareOpenGraphContent { + /** + * The type of content to be shared is open graph content. + */ + contentType: 'open-graph'; + + /** + * Common parameters for share content; + */ + commonParameters?: ShareContentCommonParameters; + + /** + * URL for the content being shared. + */ + contentUrl?: string; + + /** + * Open Graph Action to be shared. + */ + action: ShareOpenGraphAction; + + /** + * Property name that points to the primary Open Graph Object in the action. + */ + previewPropertyName: string; +} + +/** + * Represents an open graph object. + */ +export class ShareOpenGraphObject extends ShareOpenGraphValueContainer {} + +/** + * A photo for sharing. + */ +export interface SharePhoto { + /** + * The URL to the photo. + * Note that when sharing SharePhotoContent with Share Button, the imageUrl + * of a SharePhoto cannot be the Uri of an image on the web. + */ + imageUrl: string; + + /** + * Specifies whether the photo was generated by the user or the application. + */ + userGenerated?: boolean; + + /** + * The user generated caption for the photo. Note that the 'caption' must + * come from the user, as pre-filled content is forbidden by the platform + * Policies (2.3). + */ + caption?: string; +} + +/** + * A model for photo content to be shared. + */ +export interface SharePhotoContent { + /** + * The type of content to be shared is photo. + */ + contentType: 'photo'; + + /** + * Common parameters for share content; + */ + commonParameters?: ShareContentCommonParameters; + + /** + * URL for the content being shared. + */ + contentUrl?: string; + + /** + * Photos to be shared. + */ + photos: SharePhoto[]; +} + +/** + * A video for sharing. + */ +export interface ShareVideo { + /** + * The URL to the video. Must point to the location of the video on disk. + */ + localUrl: string; +} + +/** + * A model for video content to be shared. + */ +export interface ShareVideoContent { + /** + * The type of content to be shared is photo. + */ + contentType: 'video'; + + /** + * Common parameters for share content; + */ + commonParameters?: ShareContentCommonParameters; + + /** + * URL for the content being shared. + */ + contentUrl?: string; + + /** + * Video to be shared. + */ + video: ShareVideo; + + /** + * Description of the video. + */ + contentDescription?: string; + + /** + * Title of the video. + */ + contentTitle?: string; + + /** + * The photo that represents the video. + */ + previewPhoto?: SharePhoto; +} + +export interface AccessTokenMap { + accessToken: string; + applicationID: string; + userID: string; + permissions: Permissions[]; + declinedPermissions: Permissions[]; + accessTokenSource?: string; + expirationTime: number; + lastRefreshTime: number; +} + +/** + * Represents an immutable access token for using Facebook services. + */ +export class AccessToken { + /** + * The access token string. + */ + accessToken: string; + + /** + * The app ID. + */ + applicationID: string; + + /** + * The user ID. + */ + userID: string; + + /** + * The known granted permissions. + */ + permissions: Permissions[]; + + /** + * The known declined permissions. + */ + declinedPermissions: Permissions[]; + + /** + * The source of access token. + * @platform android + */ + accessTokenSource?: string; + + /** + * The expiration time of the access token. + * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT. + */ + expirationTime: number; + + /** + * The last refresh time of the access token. + * The value is the number of milliseconds since Jan. 1, 1970, midnight GMT. + */ + lastRefreshTime: number; + /** + * Getter for the access token that is current for the application. + */ + static getCurrentAccessToken(): Promise; + + /** + * Setter for the access token that is current for the application. + */ + static setCurrentAccessToken(accessToken: AccessTokenMap): void; + + /** + * Updates the current access token with up to date permissions, + * and extends the expiration date, if extension is possible. + */ + + static refreshCurrentAccessTokenAsync(): Promise; + + constructor(tokenMap: AccessTokenMap); + + /** + * Gets the date at which the access token expires. The value is the number of + * milliseconds since Jan. 1, 1970, midnight GMT. + */ + getExpires(): number; + + /** + * Get the list of permissions associated with this access token. Note that the most up-to-date + * list of permissions is maintained by Facebook, so this list may be outdated if permissions + * have been added or removed since the time the AccessToken object was created. See + * https://developers.facebook.com/docs/reference/login/#permissions for details. + */ + getPermissions(): Permissions[]; + + /** + * Gets the list of permissions declined by the user with this access token. It represents the + * entire set of permissions that have been requested and declined. Note that the most + * up-to-date list of permissions is maintained by Facebook, so this list may be outdated if + * permissions have been granted or declined since the last time an AccessToken object was + * created. See https://developers.facebook.com/docs/reference/login/#permissions for details. + */ + getDeclinedPermissions(): Permissions[]; + + /** + * Gets the date at which the token was last refreshed. Since tokens expire, the Facebook SDK + * will attempt to renew them periodically. The value is the number of milliseconds since + * Jan. 1, 1970, midnight GMT. + */ + getLastRefresh(): number; + + /** + * Gets the ID of the Facebook Application associated with this access token. + */ + getApplicationId(): string; + + /** + * Gets user ID associated with this access token. + */ + getUserId(): string; +} + +/** + * Controls when an AppEventsLogger sends log events to the server + */ +export type AppEventsFlushBehavior = + /** + * Flush automatically: periodically (every 15 seconds or after every 100 events), and + * always at app reactivation. This is the default value. + */ + 'auto' | + /** + * Only flush when AppEventsLogger.flush() is explicitly invoked. + */ + 'explicitly-only'; + +export interface Params { + [key: string]: string | number; +} + +export namespace AppEventsLogger { + /** + * Sets the current event flushing behavior specifying when events + * are sent back to Facebook servers. + */ + function setFlushBehavior(flushBehavior: AppEventsFlushBehavior): void; + + /** + * Logs an event with eventName and optional arguments. + * This function supports the following usage: + * logEvent(eventName: string); + * logEvent(eventName: string, valueToSum: number); + * logEvent(eventName: string, parameters: {[key:string]:string|number}); + * logEvent(eventName: string, valueToSum: number, parameters: {[key:string]:string|number}); + * See https://developers.facebook.com/docs/app-events/android for detail. + */ + function logEvent(eventName: string, ...args: Array): void; + + /** + * Logs a purchase. See http://en.wikipedia.org/wiki/ISO_4217 for currencyCode. + */ + function logPurchase(purchaseAmount: number, currencyCode: string, parameters?: object): void; + + /** + * Logs an app event that tracks that the application was open via Push Notification. + */ + function logPushNotificationOpen(payload?: object): void; + + /** + * Explicitly kicks off flushing of events to Facebook. + */ + function flush(): void; + + /** + * For iOS only, sets and sends device token to register the current application for push notifications. + * @platform ios + */ + function setPushNotificationsDeviceToken(deviceToken: string): void; + + /** + * For Android only, sets and sends registration id to register the current app for push notifications. + * @platform Android + */ + function setPushNotificationsRegistrationId(registrationId: string): void; +} + +export namespace AppInviteDialog { + /** + * Check if the dialog can be shown. + */ + function canShow(): Promise; + + /** + * Shows the dialog using the specified content. + */ + function show(appInviteContent: AppInviteContent): Promise; +} + +export namespace GameRequestDialog { + /** + * Check if the dialog can be shown. + */ + function canShow(): Promise; + + /** + * Shows the dialog using the specified content. + */ + function show(gameRequestContent: GameRequestContent): Promise; +} + +export type GraphRequestCallback = (error?: object, result?: object) => void; +export interface GraphRequestConfig { + /** + * The httpMethod to use for the request, for example "GET" or "POST". + */ + httpMethod?: string; + /** + * The Graph API version to use (e.g., "v2.0") + */ + version?: string; + /** + * The request parameters. + */ + parameters?: GraphRequestParameters; + /** + * The access token used by the request. + */ + accessToken?: string; +} + +export interface GraphRequestParameters { + [key: string]: object; +} + +/** + * Represents a Graph API request and provides batch request supports. + */ +export class GraphRequest { + /** + * The Graph API endpoint to use for the request, for example "me". + */ + graphPath: string; + + /** + * The optional config for the request. + */ + config?: GraphRequestConfig; + + /** + * Called upon completion or failure of the request. + */ + callback?: GraphRequestCallback; + + /** + * Constructs a new Graph API request. + */ + constructor(graphPath: string, config?: GraphRequestConfig | null, callback?: GraphRequestCallback); + + /** + * Adds a string parameter to the request. + */ + addStringParameter(paramString: string, key: string): void; +} + +export class GraphRequestManager { + requestBatch: GraphRequest[]; + requestCallbacks: Array; + batchCallback: GraphRequestCallback; + constructor(); + + /** + * Add a graph request. + */ + addRequest(request: GraphRequest): GraphRequestManager; + + /** + * Add call back to the GraphRequestManager. Only one callback can be added. + * Note that invocation of the batch callback does not indicate success of every + * graph request made, only that the entire batch has finished executing. + */ + addBatchCallback(callback: GraphRequestCallback): GraphRequestManager; + + /** + * Executes requests in a batch. + * Note that when there's an issue with network connection the batch callback + * behavior differs in Android and iOS. + * On iOS, the batch callback returns an error if the batch fails with a network error. + * On Android, the batch callback always returns {"result": "batch finished executing"} + * after the batch time out. This is because detecting network status requires + * extra permission and it's unncessary for the sdk. Instead, you can use the NetInfo module + * in react-native to get the network status. + */ + start(timeout?: number): void; +} + +export type AuxiliaryViewPosition = 'top' | 'bottom' | 'inline'; +export type HorizontalAlignment = 'center' | 'left' | 'right'; +export type LikeViewStyle = 'button'| // Note 'button' is only available on Android. + 'standard' | + 'box_count'; + +export interface LikeViewProps { + /** + * The objectId and type for the object to like. + */ + objectIdAndType: ObjectIdAndType; + + /** + * The style to use for the receiver. Distinct from React styling. + */ + likeViewStyle?: LikeViewStyle; + + /** + * The position for the auxiliary view for the receiver. + */ + auxiliaryViewPosition?: AuxiliaryViewPosition; + + /** + * The text alignment of the social sentence. + */ + horizontalAlignment?: HorizontalAlignment; + + /** + * The foreground color to use for the content of the receiver. + */ + foregroundColor?: number; + + /** + * If true, a sound is played when the receiver is toggled. + */ + soundEnabled?: boolean; + + /** + * View style, if any. + */ + style?: ViewStyle; +} + +export class LikeView extends Component {} + +export type TooltipBehaviorIOS = 'auto' | 'force_display' | 'disable'; + +export interface LoginButtonProps { + /** + * Represents the read permissions to request when the login button + * is pressed. + */ + readPermissions?: Permissions[]; + + /** + * Represents the publish permissions to request when the login + * button is pressed. + */ + publishPermissions?: Permissions[]; + + /** + * The callback invoked upon error/completion of a login request. + */ + onLoginFinished?(error: object, result: LoginResult): void; + + /** + * The callback invoked upon completion of a logout request. + */ + onLogoutFinished?(): void; + + /** + * The behavior to use when attempting a login. + * @platform android + */ + loginBehaviorAndroid?: LoginBehaviorAndroid; + + /** + * The behavior to use when attempting a login. + * @platform ios + */ + loginBehaviorIOS?: LoginBehaviorIOS; + + /** + * The default audience to target when attempting a login. + */ + defaultAudience?: DefaultAudience; + + /** + * For iOS only, the desired tooltip behavior. + * @platform ios + */ + tooltipBehaviorIOS?: TooltipBehaviorIOS; + + /** + * View style, if any. + */ + style?: ViewStyle; +} + +export class LoginButton extends Component { + private _eventHandler(event: object): void; +} + +/** + * Indicates which default audience to use for sessions that post data to Facebook. + */ +export type DefaultAudience = + // Indicates that the user's friends are able to see posts made by the application. + 'friends' | + // Indicates that all Facebook users are able to see posts made by the application. + 'everyone' | + // Indicates that only the user is able to see posts made by the application. + 'only_me'; + +export type LoginBehavior = LoginBehaviorIOS | LoginBehaviorAndroid; + +/** + * Indicate how Facebook Login should be attempted on Android. + */ +export type LoginBehaviorAndroid = + // Attempt login in using the Facebook App, and if that does not work fall back to web dialog auth. + 'native_with_fallback'| + // Only attempt to login using the Facebook App. + 'native_only'| + // Only the web dialog auth should be used. + 'web_only'; + +/** + * Indicate how Facebook Login should be attempted on iOS. + */ +export type LoginBehaviorIOS = + // Attempts log in through the native Facebook app. + // The SDK may still use Safari instead. + // See details in https://developers.facebook.com/blog/post/2015/10/29/Facebook-Login-iOS9/ + 'native' | + // Attempts log in through the Safari browser. + 'browser' | + // Attempts log in through the Facebook account currently signed in through Settings. + 'system_account' | + // Attempts log in through a modal UIWebView pop-up. + 'web'; + +/** + * Shows the results of a login operation. + */ +export interface LoginResult { + error: any; + isCancelled: boolean; + grantedPermissions?: Permissions[]; + declinedPermissions?: Permissions[]; +} + +export namespace LoginManager { + /** + * Logs the user in with the requested read permissions. + */ + function logInWithReadPermissions(permissions: Permissions[]): Promise; + + /** + * Logs the user in with the requested publish permissions. + */ + function logInWithPublishPermissions(permissions: Permissions[]): Promise; + + /** + * Getter for the login behavior. + */ + function getLoginBehavior(): Promise; + + /** + * Setter for the login behavior. + */ + function setLoginBehavior(loginBehavior: LoginBehavior): void; + + /** + * Getter for the default audience. + */ + function getDefaultAudience(): Promise; + + /** + * Setter for the default audience. + */ + function setDefaultAudience(defaultAudience: DefaultAudience): void; + + /** + * Logs out the user. + */ + function logOut(): void; +} + +export namespace MessageDialog { + /** + * Check if the dialog can be shown. + */ + function canShow(shareContent: ShareContent): Promise; + + /** + * Shows the dialog using the specified content. + */ + function show(shareContent: ShareContent): Promise; + + /** + * Sets whether or not the native message dialog should fail when it encounters a data error. + */ + function setShouldFailOnDataError(shouldFailOnDataError: boolean): void; +} + +export interface SendButtonProps { + /** + * Content to be shared. + */ + shareContent: ShareContent; + + /** + * View style, if any. + */ + style?: ViewStyle; +} + +export class SendButton extends Component {} + +export namespace ShareApi { + /** + * Check if the content can be shared via share api. + */ + function canShare(shareContent: ShareContent): Promise; + + /** + * For iOS only, creates a User Owned Open Graph object without an action. + * NOTE: Only one share action can be performed at a time. + * @platform ios + */ + function createOpenGraphObject(openGraphObject: ShareOpenGraphObject): Promise; + + /** + * Shares the specified content with a message. + * NOTE: Only one share action can be performed at a time. + */ + function share(shareContent: ShareContent, graphNode: string, message: string): Promise; +} + +export interface ShareButtonProps { + /** + * Content to be shared. + */ + shareContent: ShareContent; + + /** + * View style, if any. + */ + style?: ViewStyle; +} + +export class ShareButton extends Component {} + +export type ShareDialogMode = ShareDialogModeIOS | ShareDialogModeAndroid; +export type ShareDialogModeAndroid = + /** + * The mode is determined automatically. + */ + 'automatic'| + /** + * The native dialog is used. + */ + 'native'| + /** + * The web dialog is used. + */ + 'web'| + /** + * The feed dialog is used. + */ + 'feed'; +export type ShareDialogModeIOS = + /* + * Acts with the most appropriate mode that is available. + */ + 'automatic'| + /* + * Displays the dialog in Safari. + */ + 'browser'| + /* + * Displays the dialog in a UIWebView within the app. + */ + 'webview'; + +export namespace ShareDialog { + /** + * Check if the dialog can be shown. + */ + function canShow(shareContent: ShareContent): Promise; + + /** + * Shows the dialog using the specified content. + */ + function show(shareContent: ShareContent): Promise; + + /** + * Sets the mode for the share dialog. + */ + function setMode(mode: ShareDialogMode): void; + + /** + * Sets whether or not the native share dialog should fail when it encounters a data error. + */ + function setShouldFailOnDataError(shouldFailOnDataError: boolean): void; } -export as namespace FBSDK; -// tslint:disable-next-line:export-just-namespace -export = FBSDK; diff --git a/types/react-native-fbsdk/react-native-fbsdk-tests.tsx b/types/react-native-fbsdk/react-native-fbsdk-tests.tsx index a6334f2cfc..7d1210f06a 100644 --- a/types/react-native-fbsdk/react-native-fbsdk-tests.tsx +++ b/types/react-native-fbsdk/react-native-fbsdk-tests.tsx @@ -1,36 +1,107 @@ import * as React from 'react'; import * as FBSDK from 'react-native-fbsdk'; import { View } from 'react-native'; -import render from '../react-dom/index'; const { - LoginButton, - AccessToken + LoginButton, + AccessToken, + LoginManager, + ShareDialog, + AppEventsLogger, + GraphRequest, + GraphRequestManager, } = FBSDK; -class Login extends React.Component { - render() { - return ( - - { - if (error) { - alert("login has error: " + result.error); - } else if (result.isCancelled) { - alert("login is cancelled."); - } else { - AccessToken.getCurrentAccessToken().then( - (data) => { - alert(data.accessToken.toString()) - } - ); - } - } - } - onLogoutFinished={() => alert("logout.")}/> - - ); - } +export class Login extends React.Component { + render() { + return ( + + { + if (error) { + alert("login has error: " + result.error); + } else if (result.isCancelled) { + alert("login is cancelled."); + } else { + AccessToken.getCurrentAccessToken().then( + (data) => { + if (data) { + alert(data.accessToken.toString()); + } + } + ); + } + } + } + onLogoutFinished={() => alert("logout.")} + /> + + ); + } } + +// Attempt a login using the Facebook login dialog asking for default permissions. +LoginManager.logInWithReadPermissions(['public_profile']).then( + (result) => { + if (result.isCancelled) { + alert('Login cancelled'); + } else { + alert(`Login success with permissions: ${result.grantedPermissions}`); + } + }, + (error) => { + alert(`Login fail with error: ${error}`); + } +); + +// Build up a shareable link. +const shareLinkContent: FBSDK.ShareLinkContent = { + contentType: 'link', + contentUrl: "https://facebook.com", + contentDescription: 'Wow, check out this great site!', +}; + +// Share the link using the share dialog. +export const shareLinkWithShareDialog = (): void => { + ShareDialog.canShow(shareLinkContent).then( + (canShow) => { + if (canShow) { + return ShareDialog.show(shareLinkContent); + } + } + ).then( + (result) => { + if (result.isCancelled) { + alert('Share cancelled'); + } else { + alert(`Share success with postId: ${result.postId}`); + } + }, + (error: Error) => { + alert(`Share fail with error: ${error}`); + } + ); +}; + +const obj = { param: 'value' }; +AppEventsLogger.logPurchase(15, 'USD', obj); + +const responseInfoCallback: FBSDK.GraphRequestCallback = (error, result) => { + if (error) { + alert(`Error fetching data: ${error}`); + } else { + alert(`Success fetching data: ${result}`); + } +}; + +// Create a graph request asking for user information with a callback to handle the response. +const infoRequest = new GraphRequest( + '/me', + null, + responseInfoCallback, +); + +// Start the graph request. +new GraphRequestManager().addRequest(infoRequest).start(); diff --git a/types/react-native-fbsdk/tsconfig.json b/types/react-native-fbsdk/tsconfig.json index 52ea75b5cb..d6dccb2d02 100644 --- a/types/react-native-fbsdk/tsconfig.json +++ b/types/react-native-fbsdk/tsconfig.json @@ -15,10 +15,10 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "jsx": "react" + "jsx": "react-native" }, "files": [ "index.d.ts", - "react-native-elements-tests.tsx" + "react-native-fbsdk-tests.tsx" ] }