UNPKG

3.65 kBMarkdownView Raw
1<a style="float:right;font-size:12px;" href="http://github.com/ionic-team/ionic-native/edit/master/src/@ionic-native/plugins/facebook/index.ts#L15">
2 Improve this doc
3</a>
4
5# Facebook
6
7```
8$ ionic cordova plugin add cordova-plugin-facebook-connect --variable APP_ID="123456789" --variable APP_NAME="myApplication"
9$ npm install @ionic-native/facebook
10```
11
12## [Usage Documentation](https://ionicframework.com/docs/native/facebook/)
13
14Plugin Repo: [https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect](https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect)
15
16Use the Facebook Connect plugin to obtain access to the native FB application on iOS and Android.
17
18Requires Cordova plugin: `cordova-plugin-facebook-connect`. For more info, please see the [Facebook Connect](https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect).
19
20#### Installation
21
22 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).
23
24[![fb-getstarted-1](/img/docs/native/Facebook/1.png)](https://developers.facebook.com/apps/)
25
26Retrieve the `App ID` and `App Name`.
27
28[![fb-getstarted-2](/img/docs/native/Facebook/2.png)](https://developers.facebook.com/apps/)
29
30Then type in the following command in your Terminal, where APP_ID and APP_NAME are the values from the Facebook Developer portal.
31
32```bash
33 ionic cordova plugin add cordova-plugin-facebook-connect --variable APP_ID="123456789" --variable APP_NAME="myApplication"
34```
35
36After, 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:
37
38[![fb-getstarted-3](/img/docs/native/Facebook/3.png)](https://developers.facebook.com/apps/)
39
40Click `'Add Platform'`.
41
42[![fb-getstarted-4](/img/docs/native/Facebook/4.png)](https://developers.facebook.com/apps/)
43
44At 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.
45
46Take note of the `id` for the next step:
47```
48<widget id="com.mycompany.testapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
49```
50
51You can also edit the `id` to whatever you'd like it to be.
52
53#### iOS Install
54Under 'Bundle ID', add the `id` from your `config.xml` file:
55
56[![fb-getstarted-5](/img/docs/native/Facebook/5.png)](https://developers.facebook.com/apps/)
57
58
59#### Android Install
60Under 'Google Play Package Name', add the `id` from your `config.xml` file:
61
62[![fb-getstarted-6](/img/docs/native/Facebook/6.png)](https://developers.facebook.com/apps/)
63
64
65And that's it! You can now make calls to Facebook using the plugin.
66
67## Events
68
69App 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.
70
71- [iOS] [https://developers.facebook.com/docs/ios/app-events](https://developers.facebook.com/docs/ios/app-events)
72- [Android] [https://developers.facebook.com/docs/android/app-events](https://developers.facebook.com/docs/android/app-events)
73- [JS] Does not have an Events API, so the plugin functions are empty and will return an automatic success
74
75Activation events are automatically tracked for you in the plugin.
76
77Events are listed on the [insights page](https://www.facebook.com/insights/).
78
79For tracking events, see `logEvent` and `logPurchase`.
80
81## Supported platforms
82
83- Android
84 - iOS
85 - Browser
86
87
88