Skip to content

Commit

Permalink
Merge pull request #592 from Wizcorp/develop
Browse files Browse the repository at this point in the history
Merging Develop
  • Loading branch information
aogilvie committed Jul 28, 2014
2 parents bd0092a + 574b89f commit 0e61bab
Show file tree
Hide file tree
Showing 174 changed files with 6,529 additions and 1,565 deletions.
188 changes: 87 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,146 +6,106 @@ The Facebook plugin for [Apache Cordova](http://incubator.apache.org/cordova/) a

* Supported on PhoneGap (Cordova) v3.3.0 and above.
* This plugin is built for
* iOS FacebookSDK 3.13.0
* Android FacebookSDK 3.8.0
* iOS FacebookSDK 3.16.1
* Android FacebookSDK 3.16.0

## Facebook Requirements and Set-Up

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.
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).

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).
#### Install Guides

#### iOS
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.
- [iOS Guide](platforms/ios/README.md)

#### Android
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!
- [Android Guide](platforms/android/README.md)

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

## Example Apps
#### Example Apps

`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.

#### Setup Android Example

Configure the project with your FB app id in the `res/values/facebookconnect.xml` file. For example:

```xml
<resources>
<string name="fb_app_id">123456789</string>
<string name="fb_app_name">TEST</string>
</resources>
```

#### Setup iOS Example

- Change **FacebookAppID** in project *-info.plist
- Change URL scheme to `fb<YOUR APPID>` e.g. `fb123456789`

#### Setup Web App Example

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.


## Adobe PhoneGap Build
#### Adobe PhoneGap Build

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

## Manual Installation

- None! CLI automatic install is now the recommended method.
- Why?
- Too much can go wrong with this plugin for manual installs.
- We automate so you have less work to do!
- All Plugins should be CLI compatible since Cordova 3

## Automatic Installation

This plugin is based on [plugman](https://git-wip-us.apache.org/repos/asf?p=cordova-plugman.git;a=summary).

It will:

- add native class files
- setup the whitelist
- setup URL scheme (for deeplink with FB application if installed)
- and add your Facebook application Id automagically to a string resource file that can be read from the plugin.
## API

To install the plugin in your app, execute the following (replace variables where necessary)...

### iOS


cordova create myApp

cd myApp/

cordova platform add ios

cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
### Login

### Android
`facebookConnectPlugin.login(Function success, Function failure)`

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

cd myApp/
Success function returns an Object like;

cordova platform add android
{
id: "634565435",
lastName: "bob"
...
}

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

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

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

![image](./android_setup_1.png) ***Img. 1***
### Get Status

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***).
`facebookConnectPlugin.getLoginStatus(Function success, Function failure)`

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

## JavaScript API
```
{
authResponse: {
userID: "12345678912345",
accessToken: "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn",
session_Key: true,
expiresIn: "5183738",
sig: "..."
},
status: "connected"
}
```
For more information see: [Facebook Documentation](https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus)

###facebookConnectPlugin.login(Function success, Function failure)
### Show a Dialog

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

Success function returns an Object like;
Example options -
Feed Dialog:

{
id: "634565435",
lastName: "bob"
...
method: "feed",
link: "http://example.com",
caption: "Such caption, very feed."
}

Failure function returns an error String.

###facebookConnectPlugin.logout(Function success, Function failure)

###facebookConnectPlugin.getLoginStatus(Function success, Function failure)

Success function returns a status String.

###facebookConnectPlugin.showDialog(Object options, Function success, Function failure)

Example options:
App request:

{
method: "feed" | "apprequests"
method: "apprequests",
message: "Come on man, check out my application."
}

Success function returns an Object with `postId` as String.
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)

Success function returns an Object with `postId` as String or `from` and `to` information when doing `apprequest`.
Failure function returns an error String.

###facebookConnectPlugin.api(String requestPath, Array permissions, Func success, Func failure)
### The Graph API

`facebookConnectPlugin.api(String requestPath, Array permissions, Function success, Function failure)`

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

Example permissions:

["basic_info", "user_birthday"]
["public_info", "user_birthday"]

Success function returns an Object.

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

## Sample JavaScript Code
# 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/)

### Log an Event

`logEvent(String name, Object params, Number valueToSum, Function success, Function failure)`

- **name**, name of the event
- **params**, extra data to log with the event (is optional)
- **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)

### Log a Purchase

`logPurchase(Number value, String currency, Function success, Function failure)`

**NOTE:** Both parameters are required. The currency specification is expected to be an [ISO 4217 currency code](http://en.wikipedia.org/wiki/ISO_4217)

## Sample Code

### Login

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

facebookConnectPlugin.login(["basic_info"],
facebookConnectPlugin.login(["public_info"],
fbLoginSuccess,
function (error) { alert("" + error) }
);

### Get access token
### Get Access Token

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

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

facebookConnectPlugin.login(["basic_info"],
facebookConnectPlugin.login(["public_info"],
fbLoginSuccess,
function (error) { alert("" + error) }
);

### Get Status & Post-to-wall
### Get Status and Post-to-wall

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

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

### Getting A User's Birthday
### Getting a User's Birthday

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

Expand Down
4 changes: 2 additions & 2 deletions platforms/android/FacebookLib/.classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
15 changes: 10 additions & 5 deletions platforms/android/FacebookLib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
apply plugin: 'android-library'

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

android {
compileSdkVersion 19
buildToolsVersion "19"
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion 8
targetSdkVersion 19
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}

lintOptions {
abortOnError false
}

sourceSets {
Expand Down
15 changes: 15 additions & 0 deletions platforms/android/FacebookLib/libs/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
prebuilt_jar(
name = 'android-support-v4',
binary_jar = 'android-support-v4.jar',
visibility = [
'PUBLIC',
],
)

prebuilt_jar(
name = 'bolts',
binary_jar = 'bolts.jar',
visibility = [
'PUBLIC',
],
)
Binary file modified platforms/android/FacebookLib/libs/android-support-v4.jar
Binary file not shown.
Binary file added platforms/android/FacebookLib/libs/bolts.jar
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:singleLine="true"
android:layout_gravity="center"
android:gravity="center_vertical"
android:textSize="16dp"
android:textSize="16sp"
android:textColor="@android:color/black"
android:textColorHint="@color/com_facebook_picker_search_bar_text"
android:background="@color/com_facebook_picker_search_bar_background"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<RelativeLayout
android:id="@+id/com_facebook_body_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/com_facebook_tooltip_bubble_view_top_pointer"
android:layout_centerHorizontal="true"
android:background="@drawable/com_facebook_tooltip_blue_background">
<ImageView
android:id="@+id/com_facebook_button_xout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:padding="10dp"
android:src="@drawable/com_facebook_tooltip_blue_xout"
/>
<TextView
android:id="@+id/com_facebook_tooltip_bubble_view_text_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/com_facebook_button_xout"
android:layout_alignParentLeft="true"
android:padding="10dp"
style="@style/tooltip_bubble_text"
/>
</RelativeLayout>
<ImageView
android:id="@+id/com_facebook_tooltip_bubble_view_top_pointer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-10dp"
android:src="@drawable/com_facebook_tooltip_blue_topnub"
/>
<ImageView
android:id="@+id/com_facebook_tooltip_bubble_view_bottom_pointer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_centerHorizontal="true"
android:layout_below="@id/com_facebook_body_frame"
android:layout_marginTop="-13dp"
android:src="@drawable/com_facebook_tooltip_blue_bottomnub"
/>
</RelativeLayout>
Loading

0 comments on commit 0e61bab

Please sign in to comment.