Skip to content

Commit 88fdab7

Browse files
author
aogilvie
committed
Merge branch 'master' of github.com:wizcorp/phonegap-facebook-plugin
2 parents 8bc9c07 + 0e61bab commit 88fdab7

File tree

174 files changed

+6529
-1565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+6529
-1565
lines changed

README.md

+87-101
Original file line numberDiff line numberDiff line change
@@ -6,146 +6,106 @@ The Facebook plugin for [Apache Cordova](http://incubator.apache.org/cordova/) a
66

77
* Supported on PhoneGap (Cordova) v3.3.0 and above.
88
* This plugin is built for
9-
* iOS FacebookSDK 3.13.0
10-
* Android FacebookSDK 3.8.0
9+
* iOS FacebookSDK 3.16.1
10+
* Android FacebookSDK 3.16.0
1111

1212
## Facebook Requirements and Set-Up
1313

14-
The Facebook SDK (both native and JavaScript) is changing independent of this plugin. The manual install instructions include how to get the latest SDK for use in your project.
14+
To use this plugin you will need to make sure you've registered your Facebook app with Facebook and have an `APP_ID` [https://developers.facebook.com/apps](https://developers.facebook.com/apps).
1515

16-
To use this plugin you will need to make sure you've registered your Facebook app with Facebook and have an APP_ID (https://developers.facebook.com/apps).
16+
#### Install Guides
1717

18-
#### iOS
19-
If you plan on rolling this out on iOS, please note that you will need to ensure that you have properly set up your Native iOS App settings on the [Facebook App Dashboard](http://developers.facebook.com/apps). Please see the [Getting Started with the Facebook SDK](https://developers.facebook.com/docs/ios/getting-started/): Create a Facebook App section, for more details on this.
18+
- [iOS Guide](platforms/ios/README.md)
2019

21-
#### Android
22-
If you plan on rolling this out on Android, please note that you will need to [generate a hash of your Android key(s) and submit those to the Developers page on Facebook](https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/) to get it working. Furthermore, if you are generating this hash on Windows (specifically 64 bit versions), please use version 0.9.8e or 0.9.8d of [OpenSSL for Windows](http://code.google.com/p/openssl-for-windows/downloads/list) and *not* 0.9.8k. Big ups to [fernandomatos](http://github.com/fernandomatos) for pointing this out!
20+
- [Android Guide](platforms/android/README.md)
2321

24-
#### Web App
25-
`www/js/facebookConnectPlugin.js` contains the JavaScript SDK and API file. The API matches as close as possible to the native APIs.
22+
- [Web App Guide](platforms/web/README.md)
2623

27-
## Example Apps
24+
#### Example Apps
2825

2926
`platforms/android` and `platforms/ios` contain example projects and all the native code for the plugin for both Android and iOS platforms. They also include versions of the Android and iOS Facebook SDKs. These are used during automatic installation.
3027

31-
#### Setup Android Example
32-
33-
Configure the project with your FB app id in the `res/values/facebookconnect.xml` file. For example:
34-
35-
```xml
36-
<resources>
37-
<string name="fb_app_id">123456789</string>
38-
<string name="fb_app_name">TEST</string>
39-
</resources>
40-
```
41-
42-
#### Setup iOS Example
43-
44-
- Change **FacebookAppID** in project *-info.plist
45-
- Change URL scheme to `fb<YOUR APPID>` e.g. `fb123456789`
46-
47-
#### Setup Web App Example
48-
49-
Host the `www` folder on a server and configure your Facebook dashboard correctly to test the Web APIs. Most people use [Parse](https://parse.com/) for easy testing.
50-
51-
52-
## Adobe PhoneGap Build
28+
#### Adobe PhoneGap Build
5329

5430
If using this plugin on Adobe PhoneGap Build you can ignore the instructions below and go straight to the
5531
PhoneGap Build documentation available [here] (https://build.phonegap.com/plugins/257).
5632

57-
## Manual Installation
58-
59-
- None! CLI automatic install is now the recommended method.
60-
- Why?
61-
- Too much can go wrong with this plugin for manual installs.
62-
- We automate so you have less work to do!
63-
- All Plugins should be CLI compatible since Cordova 3
64-
65-
## Automatic Installation
66-
67-
This plugin is based on [plugman](https://git-wip-us.apache.org/repos/asf?p=cordova-plugman.git;a=summary).
68-
69-
It will:
70-
71-
- add native class files
72-
- setup the whitelist
73-
- setup URL scheme (for deeplink with FB application if installed)
74-
- and add your Facebook application Id automagically to a string resource file that can be read from the plugin.
33+
## API
7534

76-
To install the plugin in your app, execute the following (replace variables where necessary)...
77-
78-
### iOS
79-
80-
81-
cordova create myApp
82-
83-
cd myApp/
84-
85-
cordova platform add ios
86-
87-
cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
35+
### Login
8836

89-
### Android
37+
`facebookConnectPlugin.login(Function success, Function failure)`
9038

91-
cordova create myApp
39+
**NOTE** : Developers should call `facebookConnectPlugin.browserInit(<appId>)` before login - **Web App ONLY** (see [Web App Guide](platforms/web/README.md))
9240

93-
cd myApp/
41+
Success function returns an Object like;
9442

95-
cordova platform add android
43+
{
44+
id: "634565435",
45+
lastName: "bob"
46+
...
47+
}
9648

97-
cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
49+
Failure function returns an error String.
9850

99-
**Android requires an additional step which is to reference the FacebookSDK project as a library to your project.**
51+
### Logout
10052

101-
Open your project in Eclipse (New > Project... Existing Android project from source), import everything (***see Img. 1***).
53+
`facebookConnectPlugin.logout(Function success, Function failure)`
10254

103-
![image](./android_setup_1.png) ***Img. 1***
55+
### Get Status
10456

105-
In Eclipse, right click your project folder in the left-had column. Select "Properties", select Android in the left column and in the right side of the window add FacebookSDK as a library (***see Img. 2***).
57+
`facebookConnectPlugin.getLoginStatus(Function success, Function failure)`
10658

107-
![image](./android_setup_2.png) ***Img. 2***
59+
Success function returns a status Object. Example:
10860

109-
## JavaScript API
61+
```
62+
{
63+
authResponse: {
64+
userID: "12345678912345",
65+
accessToken: "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn",
66+
session_Key: true,
67+
expiresIn: "5183738",
68+
sig: "..."
69+
},
70+
status: "connected"
71+
}
72+
```
73+
For more information see: [Facebook Documentation](https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus)
11074

111-
###facebookConnectPlugin.login(Function success, Function failure)
75+
### Show a Dialog
11276

113-
**NOTE** : Developers should call `facebookConnectPlugin.browserInit(<appId>)` before login - **Web App ONLY**
77+
`facebookConnectPlugin.showDialog(Object options, Function success, Function failure)`
11478

115-
Success function returns an Object like;
79+
Example options -
80+
Feed Dialog:
11681

11782
{
118-
id: "634565435",
119-
lastName: "bob"
120-
...
83+
method: "feed",
84+
link: "http://example.com",
85+
caption: "Such caption, very feed."
12186
}
12287

123-
Failure function returns an error String.
124-
125-
###facebookConnectPlugin.logout(Function success, Function failure)
126-
127-
###facebookConnectPlugin.getLoginStatus(Function success, Function failure)
128-
129-
Success function returns a status String.
130-
131-
###facebookConnectPlugin.showDialog(Object options, Function success, Function failure)
132-
133-
Example options:
88+
App request:
13489

13590
{
136-
method: "feed" | "apprequests"
91+
method: "apprequests",
92+
message: "Come on man, check out my application."
13793
}
13894

139-
Success function returns an Object with `postId` as String.
95+
For options information see: [Facebook feed dialog documentation](https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.0), [Facebook share dialog documentation](https://developers.facebook.com/docs/sharing/reference/share-dialog)
96+
97+
Success function returns an Object with `postId` as String or `from` and `to` information when doing `apprequest`.
14098
Failure function returns an error String.
14199

142-
###facebookConnectPlugin.api(String requestPath, Array permissions, Func success, Func failure)
100+
### The Graph API
101+
102+
`facebookConnectPlugin.api(String requestPath, Array permissions, Function success, Function failure)`
143103

144104
Allows access to the Facebook Graph API. This API allows for additional permission because, unlike login, the Graph API can accept multiple permissions.
145105

146106
Example permissions:
147107

148-
["basic_info", "user_birthday"]
108+
["public_info", "user_birthday"]
149109

150110
Success function returns an Object.
151111

@@ -159,7 +119,33 @@ For more information see:
159119
- Graph Explorer - [https://developers.facebook.com/tools/explorer](https://developers.facebook.com/tools/explorer)
160120
- Graph API - [https://developers.facebook.com/docs/graph-api/](https://developers.facebook.com/docs/graph-api/)
161121

162-
## Sample JavaScript Code
122+
# Events
123+
124+
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.
125+
126+
- [iOS] [https://developers.facebook.com/docs/ios/app-events](https://developers.facebook.com/docs/ios/app-events)
127+
- [Android] [https://developers.facebook.com/docs/android/app-events](https://developers.facebook.com/docs/android/app-events)
128+
- [JS] Does not have an Events API, so the plugin functions are empty and will return an automatic success
129+
130+
Activation events are automatically tracked for you in the plugin.
131+
132+
Events are listed on the [insights page](https://www.facebook.com/insights/)
133+
134+
### Log an Event
135+
136+
`logEvent(String name, Object params, Number valueToSum, Function success, Function failure)`
137+
138+
- **name**, name of the event
139+
- **params**, extra data to log with the event (is optional)
140+
- **valueToSum**, a property which is an arbitrary number that can represent any value (e.g., a price or a quantity). When reported, all of the valueToSum properties will be summed together. For example, if 10 people each purchased one item that cost $10 (and passed in valueToSum) then they would be summed to report a number of $100. (is optional)
141+
142+
### Log a Purchase
143+
144+
`logPurchase(Number value, String currency, Function success, Function failure)`
145+
146+
**NOTE:** Both parameters are required. The currency specification is expected to be an [ISO 4217 currency code](http://en.wikipedia.org/wiki/ISO_4217)
147+
148+
## Sample Code
163149

164150
### Login
165151

@@ -169,12 +155,12 @@ In your `onDeviceReady` event add the following
169155
alert("UserInfo: " + JSON.stringify(userData));
170156
}
171157

172-
facebookConnectPlugin.login(["basic_info"],
158+
facebookConnectPlugin.login(["public_info"],
173159
fbLoginSuccess,
174160
function (error) { alert("" + error) }
175161
);
176162

177-
### Get access token
163+
### Get Access Token
178164

179165
If you need the Facebook access token (for example, for validating the login on server side), do:
180166

@@ -187,12 +173,12 @@ If you need the Facebook access token (for example, for validating the login on
187173
});
188174
}
189175

190-
facebookConnectPlugin.login(["basic_info"],
176+
facebookConnectPlugin.login(["public_info"],
191177
fbLoginSuccess,
192178
function (error) { alert("" + error) }
193179
);
194180

195-
### Get Status & Post-to-wall
181+
### Get Status and Post-to-wall
196182

197183
For a more instructive example change the above `fbLoginSuccess` to;
198184

@@ -213,7 +199,7 @@ For a more instructive example change the above `fbLoginSuccess` to;
213199
);
214200
};
215201

216-
### Getting A User's Birthday
202+
### Getting a User's Birthday
217203

218204
Using the graph api this is a very simple task: [currently iOS only!]
219205

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
35
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
46
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
57
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
6-
<classpathentry kind="src" path="src"/>
7-
<classpathentry kind="src" path="gen"/>
88
<classpathentry kind="output" path="bin/classes"/>
99
</classpath>

platforms/android/FacebookLib/build.gradle

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
apply plugin: 'android-library'
22

33
dependencies {
4-
compile 'com.android.support:support-v4:13.0.+'
4+
compile 'com.android.support:support-v4:19.1.+'
5+
compile files('../libs/bolts.jar')
56
}
67

78
android {
8-
compileSdkVersion 19
9-
buildToolsVersion "19"
9+
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
10+
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
1011

1112
defaultConfig {
12-
minSdkVersion 8
13-
targetSdkVersion 19
13+
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
14+
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
15+
}
16+
17+
lintOptions {
18+
abortOnError false
1419
}
1520

1621
sourceSets {
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
prebuilt_jar(
2+
name = 'android-support-v4',
3+
binary_jar = 'android-support-v4.jar',
4+
visibility = [
5+
'PUBLIC',
6+
],
7+
)
8+
9+
prebuilt_jar(
10+
name = 'bolts',
11+
binary_jar = 'bolts.jar',
12+
visibility = [
13+
'PUBLIC',
14+
],
15+
)
Binary file not shown.
39.8 KB
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

platforms/android/FacebookLib/res/layout/com_facebook_search_bar_layout.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
android:singleLine="true"
2121
android:layout_gravity="center"
2222
android:gravity="center_vertical"
23-
android:textSize="16dp"
23+
android:textSize="16sp"
2424
android:textColor="@android:color/black"
2525
android:textColorHint="@color/com_facebook_picker_search_bar_text"
2626
android:background="@color/com_facebook_picker_search_bar_background"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:paddingLeft="20dp"
7+
android:paddingRight="20dp">
8+
<RelativeLayout
9+
android:id="@+id/com_facebook_body_frame"
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:layout_below="@+id/com_facebook_tooltip_bubble_view_top_pointer"
13+
android:layout_centerHorizontal="true"
14+
android:background="@drawable/com_facebook_tooltip_blue_background">
15+
<ImageView
16+
android:id="@+id/com_facebook_button_xout"
17+
android:layout_width="wrap_content"
18+
android:layout_height="wrap_content"
19+
android:layout_alignParentTop="true"
20+
android:layout_alignParentRight="true"
21+
android:padding="10dp"
22+
android:src="@drawable/com_facebook_tooltip_blue_xout"
23+
/>
24+
<TextView
25+
android:id="@+id/com_facebook_tooltip_bubble_view_text_body"
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:layout_alignParentTop="true"
29+
android:layout_toLeftOf="@id/com_facebook_button_xout"
30+
android:layout_alignParentLeft="true"
31+
android:padding="10dp"
32+
style="@style/tooltip_bubble_text"
33+
/>
34+
</RelativeLayout>
35+
<ImageView
36+
android:id="@+id/com_facebook_tooltip_bubble_view_top_pointer"
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:layout_alignParentTop="true"
40+
android:layout_centerHorizontal="true"
41+
android:layout_marginBottom="-10dp"
42+
android:src="@drawable/com_facebook_tooltip_blue_topnub"
43+
/>
44+
<ImageView
45+
android:id="@+id/com_facebook_tooltip_bubble_view_bottom_pointer"
46+
android:layout_width="wrap_content"
47+
android:layout_height="wrap_content"
48+
android:layout_gravity="center_horizontal|bottom"
49+
android:layout_centerHorizontal="true"
50+
android:layout_below="@id/com_facebook_body_frame"
51+
android:layout_marginTop="-13dp"
52+
android:src="@drawable/com_facebook_tooltip_blue_bottomnub"
53+
/>
54+
</RelativeLayout>

0 commit comments

Comments
 (0)