Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook SDK 4.1 #1051

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
03faa59
Upgrade to Facebook iOS SDK 4.1.0
mereformalities May 14, 2015
62022a0
Upgrade to Facebook Android SDK 4.1.2
mereformalities May 14, 2015
dce0081
Update docs
mereformalities May 14, 2015
941553a
iOS platform rewrite for FB SDK 4.1
mereformalities May 15, 2015
5fa55be
Add getProfile for browser platform
mereformalities May 15, 2015
ffd04dc
Remove whitespace
mereformalities May 15, 2015
44e80cc
Update HelloCordova tests
mereformalities May 15, 2015
84fcb3f
Bump plugin version
mereformalities May 15, 2015
532b2a6
Add Bolts framework
mereformalities May 18, 2015
c997e1b
Add Bolts framework
mereformalities May 18, 2015
2976dfb
Use Facebook method name appinvites
mereformalities May 18, 2015
b5ff5cc
Rename dialog method keys
mereformalities May 26, 2015
939c27e
Note deprecation of handleOpenURL
mereformalities May 26, 2015
5ef98a1
Android platform rewrite for FB SDK 4.1
mereformalities May 26, 2015
cd6fc5e
Fix compile errors
mereformalities May 26, 2015
fb302ee
SDK AndroidManifest setup changes
mereformalities May 26, 2015
f1fac7d
Add Java 7 dependency
mereformalities May 26, 2015
0939183
Move java target, source
mereformalities May 26, 2015
837ed2e
Near-complete Android rewrite
mereformalities May 27, 2015
21fe00d
Finish share dialog
mereformalities May 27, 2015
78b96f8
Fix wrong Sharer.Result method call
mereformalities May 27, 2015
b3cf16e
Add Java 7 dependency to Android docs
mereformalities Jun 24, 2015
41508fc
Comprehensive gitignore for ios project
mereformalities Jun 24, 2015
d69516c
Fix minor typos
mereformalities Jun 24, 2015
653e145
Fix whitespace
mereformalities Jun 24, 2015
db1d8fb
Handle application:openURL on iOS
mereformalities Jun 24, 2015
a94e10e
Add FB setup call to Android docs
mereformalities Jun 24, 2015
e912339
Fix whitespace
mereformalities Jun 24, 2015
956176f
Add missing dialogs
mereformalities Jun 24, 2015
628eab4
Pass through FBSDKGameRequestContent
mereformalities Jun 24, 2015
3d48ffa
Rename dialog ivars
mereformalities Jul 10, 2015
089668d
Factor out bundleFromJSONObject helper
mereformalities Jul 10, 2015
2b0268e
Factor out listFromJSONArray helper
mereformalities Jul 10, 2015
d07d996
Accept parameters, http method for graph api calls
mereformalities Jul 10, 2015
69504a6
Check for user object
mereformalities Sep 16, 2015
5bd3dd3
Merge with Wizcorp/develop
mereformalities Sep 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Before creating a Github issue make sure you...

When submitting an issue please add as much of the following information:

- Tell us what you expected to happen and what actually happened. ("It doesn't work" is **not** a solveable problem)
- Tell us what you expected to happen and what actually happened. ("It doesn't work" is **not** a solvable problem)
- Provide sample code so people can test and debug the problem.
- Provide `adb logcat` or Xcode console output.

Expand All @@ -27,6 +27,6 @@ Can you solve the problem yourself? If so see the next section on Pull Requests
## Pull Requests

- Include screenshots and animated GIFs in your pull request whenever possible.
- Try to follow the [JavaScript](https://github.com/Wizcorp/javascript-styleguide/blob/master/README.md), [Objective-C](http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml) or [Java](https://google-styleguide.googlecode.com/svn/trunk/javaguide.html) style guides. Although these are just guides, please at least support continuety (that means **using 4 spaces please**).
- Try to follow the [JavaScript](https://github.com/Wizcorp/javascript-styleguide/blob/master/README.md), [Objective-C](http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml) or [Java](https://google-styleguide.googlecode.com/svn/trunk/javaguide.html) style guides. Although these are just guides, please at least support continuity (that means **using 4 spaces please**).
- **Send your pull request to the develop branch.**
- If you can, provide sample testing code.
- If you can, provide sample testing code.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ This is the official plugin for Facebook in Apache Cordova/PhoneGap!
The Facebook plugin for [Apache Cordova](http://incubator.apache.org/cordova/) allows you to use the same JavaScript code in your Cordova application as you use in your web application. However, unlike in the browser, the Cordova application will use the native Facebook app to perform Single Sign On for the user. If this is not possible then the sign on will degrade gracefully using the standard dialog based authentication.

* Supported on PhoneGap (Cordova) v3.5.0 and above.
* JDK version 1.7 or above is required
* This plugin is built for
* iOS FacebookSDK 3.21.1
* Android FacebookSDK 3.21.1
* iOS Facebook SDK 4.1.0
* Android Facebook SDK 4.1.2
* GitHub URL : [https://github.com/Wizcorp/phonegap-facebook-plugin/](https://github.com/Wizcorp/phonegap-facebook-plugin/)

## << --- Cordova Registry Warning [iOS]

****Installing this plugin directly from Cordova Registry results in Xcode using a broken `FacebookSDK.framework`, this is because the current publish procedure to NPM breaks symlinks [CB-6092](https://issues.apache.org/jira/browse/CB-6092). Please install the plugin through a locally cloned copy or re-add the `FacebookSDK.framework` to Xcode after installation.****
****Installing this plugin directly from Cordova Registry results in Xcode using a broken `FBSDKCoreKit.framework`, etc. This is because the current publish procedure to NPM breaks symlinks [CB-6092](https://issues.apache.org/jira/browse/CB-6092). Please install the plugin through a locally cloned copy or re-add `FBSDKCoreKit.framework`, etc to Xcode after installation.****

## ------------------------------------------ >>

Expand Down Expand Up @@ -237,15 +238,15 @@ Using the graph api this is a very simple task:
Send a photo to a user's feed

```
facebookConnectPlugin.showDialog(
facebookConnectPlugin.showDialog(
{
method: "feed",
picture:'https://www.google.co.jp/logos/doodles/2014/doodle-4-google-2014-japan-winner-5109465267306496.2-hp.png',
name:'Test Post',
message:'First photo post',
message:'First photo post',
caption: 'Testing using phonegap plugin',
description: 'Posting photo using phonegap facebook plugin'
},
},
function (response) { alert(JSON.stringify(response)) },
function (response) { alert(JSON.stringify(response)) });
```
24 changes: 13 additions & 11 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Troubleshooting

Can't solve your issue here? Check the [existing issues](https://github.com/Wizcorp/phonegap-facebook-plugin/issues) on Github. If you still cannot find a solution please [create and issue after reading the contributing guide](CONTRIBUTING.md).
Can't solve your issue here? Check the [existing issues](https://github.com/Wizcorp/phonegap-facebook-plugin/issues) on Github. If you still cannot find a solution please [create and issue after reading the contributing guide](CONTRIBUTING.md).

When creating a Github issue **remember to**:

Expand All @@ -9,8 +9,8 @@ When creating a Github issue **remember to**:
- Provide a log (Xcode console or adb logcat)

### Troubleshooting contents
- [**General**](#general)
- [How do I Build without Eclipse?](#how-do-i-build-without-eclipse)
- [**General**](#general)
- [How do I Build without Eclipse?](#how-do-i-build-without-eclipse)
- [How do I Add a Like Button?](#how-do-i-add-a-like-button)
- [Where is the init API?](#where-is-the-init-api)
- [How to install with NPM PhoneGap?](#how-to-install-with-npm-phonegap)
Expand Down Expand Up @@ -38,7 +38,7 @@ When creating a Github issue **remember to**:
- Problem
- I am trying to implement like button functionality in my app. Whenever user likes my facebook page, user will get rewards. So i have tried to implement this like button functionality as described here:
[https://developers.facebook.com/docs/plugins/like-button](https://developers.facebook.com/docs/plugins/like-button)

- Solution
- It won't work for native apps because: [https://developers.facebook.com/docs/ios/like-button/](https://developers.facebook.com/docs/ios/like-button/) is not supported yet. **HOWEVER**; it can be done with the graph API [http://stackoverflow.com/questions/11915269/built-in-like-button-facebook-sdk-3-0](http://stackoverflow.com/questions/11915269/built-in-like-button-facebook-sdk-3-0)
Things you have to take care of are :
Expand All @@ -65,7 +65,7 @@ The better way to understand this little "workflow" is to manipulate the Graph A

- Problem
- I'm trying to install via https the Facebook plugin in iOS, but when I try the following line:

`sudo phonegap local plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="12345678910" --variable APP_NAME="MyAPP"`

Im getting the message "[error] Variable(s) missing: APP_ID, APP_NAME"
Expand Down Expand Up @@ -114,7 +114,7 @@ Add this line to `initWithWebView` before `[FBSession openActiveSessionWithReadP

## Android
### No Reply From Login?

- Problem
- **facebookConnectPlugin.login doesn't call neither success nor faillure methods.** - When I'm disconnected from Facebook and don't have the native app, the iframe fallback is blank. Checking on chrome inspector, the elements are set to display: none.

Expand All @@ -123,9 +123,9 @@ Add this line to `initWithWebView` before `[FBSession openActiveSessionWithReadP

```
try {
PackageInfo info =
PackageInfo info =
cordova.getActivity().getPackageManager().getPackageInfo("com.goapes.golearn", PackageManager.GET_SIGNATURES);

for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Expand Down Expand Up @@ -225,8 +225,10 @@ requestsDialog.build().show();
2. Go to "Build Phases"
3. Ensure that the following file is added under "Compile Sources":
- `FacebookConnectPlugin.m`
4. Ensure that the following is added under "Link Binary With Libraris":
- `FacebookSDK.framework`
4. Ensure that the following are added under "Link Binary With Libraries":
- `FBSDKCoreKit.framework`
- `FBSDKLoginKit.framework`
- `FBSDKShareKit.framework`
- `libsqlite3.dylib`
- `Social.framework`
- `Accounts.framework`
Expand All @@ -239,4 +241,4 @@ Cordova and plugman seems to have some problems adding frameworks etc. when re-i
- Problem:
- Calling the login function always opens the web dialog even though the native app is installed on the device.
- Solution:
- Switch "deep linking" to ON in the Facebook developer website settings for your application
- Switch "deep linking" to ON in the Facebook developer website settings for your application.
33 changes: 26 additions & 7 deletions facebookConnectPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ if (cordova.platformId == "browser") {
}
},

getProfile: function (s, f) {
// Try will catch errors when SDK has not been init
try {
FB.api('/me', function (response) {
s(response);
});
} catch (error) {
if (!f) {
console.error(error.message);
} else {
f(error.message);
}
}
},

showDialog: function (options, s, f) {

if (!options.name) {
Expand All @@ -42,16 +57,16 @@ if (cordova.platformId == "browser") {
if (!options.description) {
options.description = "";
}
if (!options.href) {
options.href = "";
}
if (!options.picture) {
options.picture = "";
}
if (options.link && !options.href) {
options.href = options.link;
}

if (!options.href) {
options.href = "";
}

// Try will catch errors when SDK has not been init
try {
FB.ui(options,
Expand Down Expand Up @@ -82,7 +97,7 @@ if (cordova.platformId == "browser") {
}
options.scope = permissions.toString();
}

FB.login(function (response) {
if (response.authResponse) {
s(response);
Expand Down Expand Up @@ -132,7 +147,7 @@ if (cordova.platformId == "browser") {

api: function (graphPath, permissions, s, f) {
// JS API does not take additional permissions

// Try will catch errors when SDK has not been init
try {
FB.api(graphPath, function (response) {
Expand Down Expand Up @@ -164,7 +179,7 @@ if (cordova.platformId == "browser") {
});
}
};

// Bake in the JS SDK
(function () {
// Retrieve the root element to append the script tags to
Expand Down Expand Up @@ -200,6 +215,10 @@ if (cordova.platformId == "browser") {
exec(s, f, "FacebookConnectPlugin", "getLoginStatus", []);
},

getProfile: function (s, f) {
exec(s, f, "FacebookConnectPlugin", "getProfile", []);
},

showDialog: function (options, s, f) {
if (!options.link && options.href) {
options.link = options.href;
Expand Down
32 changes: 18 additions & 14 deletions platforms/android/FacebookLib/AndroidManifest.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright 2010-present Facebook.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.

As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.android">
package="com.facebook">
<application/>
<uses-sdk android:minSdkVersion="9" />
</manifest>
26 changes: 26 additions & 0 deletions platforms/android/FacebookLib/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
build_config(
name = 'config-debug',
package = 'com.facebook',
debug = True,
)

android_resource(
name = 'res',
res = 'res',
package = 'com.facebook',
deps = [
],
)

android_library(
name = 'android-sdk',
srcs = glob(['src/**/*.java']) + [':config-debug'],
deps = [
':res',
'//libs:android-support-v4',
'//libs:bolts',
],
visibility = [
'PUBLIC',
],
)
6 changes: 3 additions & 3 deletions platforms/android/FacebookLib/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ repositories {
project.group = 'com.facebook.android'

dependencies {
compile 'com.android.support:support-v4:[20,21)'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile 'com.android.support:support-v4:[21,22)'
compile 'com.parse.bolts:bolts-android:1.2.0'
}

android {
Expand Down Expand Up @@ -83,7 +83,7 @@ uploadArchives {

licenses {
license {
name 'The Apache Software License, Version 2.0'
name 'Facebook Platform License'
url 'https://github.com/facebook/facebook-android-sdk/blob/master/LICENSE.txt'
distribution 'repo'
}
Expand Down
Empty file modified platforms/android/FacebookLib/libs/BUCK
100644 → 100755
Empty file.
Empty file modified platforms/android/FacebookLib/libs/android-support-v4.jar
100644 → 100755
Empty file.
Empty file modified platforms/android/FacebookLib/libs/bolts-android-1.1.2.jar
100644 → 100755
Empty file.
25 changes: 25 additions & 0 deletions platforms/android/FacebookLib/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.

As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<lint>
<!-- Disable the given check in this project -->
<issue id="MissingTranslation" severity="ignore" />
</lint>
20 changes: 20 additions & 0 deletions platforms/android/FacebookLib/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes
Binary file not shown.
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.
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.
Binary file not shown.
Binary file not shown.
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.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
File renamed without changes
File renamed without changes
Diff not rendered.
Diff not rendered.
File renamed without changes
File renamed without changes
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
File renamed without changes
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
File renamed without changes
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.

As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/com_facebook_button_background_color_disabled" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/com_facebook_button_background_color_pressed" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/com_facebook_button_background_color" />
</shape>
</item>
</selector>
Loading