export interface FacebookLoginResponse { status: string; authResponse: { session_key: boolean; accessToken: string; expiresIn: number; sig: string; secret: string; userID: string; }; } /** * @name Facebook * @description * Use the Facebook Connect plugin to obtain access to the native FB application on iOS and Android. * * Requires Cordova plugin: `cordova-plugin-facebook4`. For more info, please see the [Facebook Connect](https://github.com/jeduan/cordova-plugin-facebook4). * * #### Installation * * To use the FB plugin, you first have to create a new Facebook App inside of the Facebook developer portal at [https://developers.facebook.com/apps](https://developers.facebook.com/apps). * * [![fb-getstarted-1](/img/docs/native/Facebook/1.png)](https://developers.facebook.com/apps/) * * Retrieve the `App ID` and `App Name`. * * [![fb-getstarted-2](/img/docs/native/Facebook/2.png)](https://developers.facebook.com/apps/) * * Then type in the following command in your Terminal, where APP_ID and APP_NAME are the values from the Facebook Developer portal. * * ```bash * ionic plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" * ``` * * After, you'll need to add the native platforms you'll be using to your app in the Facebook Developer portal under your app's Settings: * * [![fb-getstarted-3](/img/docs/native/Facebook/3.png)](https://developers.facebook.com/apps/) * * Click `'Add Platform'`. * * [![fb-getstarted-4](/img/docs/native/Facebook/4.png)](https://developers.facebook.com/apps/) * * At this point you'll need to open your project's [`config.xml`](https://cordova.apache.org/docs/en/latest/config_ref/index.html) file, found in the root directory of your project. * * Take note of the `id` for the next step: * ``` * * ``` * * You can also edit the `id` to whatever you'd like it to be. * * #### iOS Install * Under 'Bundle ID', add the `id` from your `config.xml` file: * * [![fb-getstarted-5](/img/docs/native/Facebook/5.png)](https://developers.facebook.com/apps/) * * * #### Android Install * Under 'Google Play Package Name', add the `id` from your `config.xml` file: * * [![fb-getstarted-6](/img/docs/native/Facebook/6.png)](https://developers.facebook.com/apps/) * * * And that's it! You can now make calls to Facebook using the plugin. * * ## Events * * App events allow you to understand the makeup of users engaging with your app, measure the performance of your Facebook mobile app ads, and reach specific sets of your users with Facebook mobile app ads. * * - [iOS] [https://developers.facebook.com/docs/ios/app-events](https://developers.facebook.com/docs/ios/app-events) * - [Android] [https://developers.facebook.com/docs/android/app-events](https://developers.facebook.com/docs/android/app-events) * - [JS] Does not have an Events API, so the plugin functions are empty and will return an automatic success * * Activation events are automatically tracked for you in the plugin. * * Events are listed on the [insights page](https://www.facebook.com/insights/). * * For tracking events, see `logEvent` and `logPurchase`. * * @usage * ```typescript * import { Facebook } from 'ionic-native'; * * * * ``` * */ export declare class Facebook { /** * Browser wrapper * @param {number} appId Your Facebook AppID from their dashboard * @param {string} version The version of API you may want to use. Optional * @returns {Promise} */ static browserInit(appId: number, version?: string): Promise; /** * Login to Facebook to authenticate this app. * * ```typescript * { * status: "connected", * authResponse: { * session_key: true, * accessToken: "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn", * expiresIn: 5183979, * sig: "...", * secret: "...", * userID: "634565435" * } * } * ``` * * @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) this app has upon logging in. * @returns {Promise} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails. */ static login(permissions: string[]): Promise; /** * Logout of Facebook. * * For more info see the [Facebook docs](https://developers.facebook.com/docs/reference/javascript/FB.logout) * @returns {Promise} Returns a Promise that resolves on a successful logout, and rejects if logout fails. */ static logout(): Promise; /** * Determine if a user is logged in to Facebook and has authenticated your app. There are three possible states for a user: * * 1) the user is logged into Facebook and has authenticated your application (connected) * 2) the user is logged into Facebook but has not authenticated your application (not_authorized) * 3) the user is either not logged into Facebook or explicitly logged out of your application so it doesn't attempt to connect to Facebook and thus, we don't know if they've authenticated your application or not (unknown) * * Resolves with a response like: * * ``` * { * authResponse: { * userID: "12345678912345", * accessToken: "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn", * session_Key: true, * expiresIn: "5183738", * sig: "..." * }, * status: "connected" * } * ``` * * For more information see the [Facebook docs](https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus) * * @returns {Promise} Returns a Promise that resolves with a status, or rejects with an error */ static getLoginStatus(): Promise; /** * Get a Facebook access token for using Facebook services. * * @returns {Promise} Returns a Promise that resolves with an access token, or rejects with an error */ static getAccessToken(): Promise; /** * Show one of various Facebook dialogs. Example of options for a Share dialog: * * ``` * { * method: "share", * href: "http://example.com", * caption: "Such caption, very feed.", * description: "Much description", * picture: 'http://example.com/image.png' * } * ``` * * For more options see the [Cordova plugin docs](https://github.com/jeduan/cordova-plugin-facebook4#show-a-dialog) and the [Facebook docs](https://developers.facebook.com/docs/javascript/reference/FB.ui) * @param {Object} options The dialog options * @returns {Promise} Returns a Promise that resolves with success data, or rejects with an error */ static showDialog(options: any): Promise; /** * Make a call to Facebook Graph API. Can take additional permissions beyond those granted on login. * * For more information see: * * Calling the Graph API - https://developers.facebook.com/docs/javascript/reference/FB.api * Graph Explorer - https://developers.facebook.com/tools/explorer * Graph API - https://developers.facebook.com/docs/graph-api * * @param {string} requestPath Graph API endpoint you want to call * @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) for this request. * @returns {Promise} Returns a Promise that resolves with the result of the request, or rejects with an error */ static api(requestPath: string, permissions: string[]): Promise; /** * Log an event. For more information see the Events section above. * * @param {string} name Name of the event * @param {Object} [params] An object containing extra data to log with the event * @param {number} [valueToSum] any value to be added to added to a sum on each event * @returns {Promise} */ static logEvent(name: string, params?: Object, valueToSum?: number): Promise; /** * Log a purchase. For more information see the Events section above. * * @param {number} value Value of the purchase. * @param {string} currency The currency, as an [ISO 4217 currency code](http://en.wikipedia.org/wiki/ISO_4217) * @returns {Promise} */ static logPurchase(value: number, currency: string): Promise; /** * Open App Invite dialog. Does not require login. * * For more information see: * * the App Invites Overview - https://developers.facebook.com/docs/app-invites/overview * the App Links docs - https://developers.facebook.com/docs/applinks * * * @param {Object} options An object containing an [App Link](https://developers.facebook.com/docs/applinks) URL to your app and an optional image URL. * url: [App Link](https://developers.facebook.com/docs/applinks) to your app * picture: image to be displayed in the App Invite dialog * * @returns {Promise} Returns a Promise that resolves with the result data, or rejects with an error */ static appInvite(options: { url: string; picture: string; }): Promise; }