From a89ce0e0d7c05dd95d2ee02a667bf160d8fd500b Mon Sep 17 00:00:00 2001 From: Jake Craige Date: Mon, 9 Jun 2014 09:15:46 -0500 Subject: [PATCH 1/4] check loginCallbackId exists before pluginResult call We make sure that loginCallbackId exists before calling it. When it's not set, it triggers the exception referenced in issue #507 --- .../FacebookConnectPlugin.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m b/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m index 2cc271af0..ca53c4682 100644 --- a/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m +++ b/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m @@ -71,21 +71,25 @@ - (void)sessionStateChanged:(FBSession *)session ^(FBRequestConnection *connection, id user, NSError *error) { if (!error) { self.userid = user.id; + // Send the plugin result. Wait for a successful fetch of user info. - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + if(self.loginCallbackId) { + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self responseObject]]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; + } } else { self.userid = @""; - } }]; }else { // Don't get user's info but trigger success callback // Send the plugin result. Wait for a successful fetch of user info. - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + if(self.loginCallbackId) { + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self responseObject]]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; + } } } break; @@ -127,7 +131,7 @@ - (void)sessionStateChanged:(FBSession *)session alertMessage = @"Error. Please try again later."; } - if (alertMessage) { + if (alertMessage && self.loginCallbackId) { CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:alertMessage]; [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; From 77e3c7fb03bff3b90dca6e9c0ff8f252b2d877fe Mon Sep 17 00:00:00 2001 From: Ally Date: Mon, 16 Jun 2014 17:58:26 +0900 Subject: [PATCH 2/4] Update FacebookConnectPlugin.m Tweaked the PRed code to be more inline with Google Objective-C style guide. --- .../FacebookConnectPlugin.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m b/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m index ca53c4682..2323985d6 100644 --- a/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m +++ b/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m @@ -73,8 +73,8 @@ - (void)sessionStateChanged:(FBSession *)session self.userid = user.id; // Send the plugin result. Wait for a successful fetch of user info. - if(self.loginCallbackId) { - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + if (self.loginCallbackId) { + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self responseObject]]; [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; } @@ -82,11 +82,11 @@ - (void)sessionStateChanged:(FBSession *)session self.userid = @""; } }]; - }else { + } else { // Don't get user's info but trigger success callback // Send the plugin result. Wait for a successful fetch of user info. - if(self.loginCallbackId) { - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + if (self.loginCallbackId) { + CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self responseObject]]; [self.commandDelegate sendPluginResult:pluginResult callbackId:self.loginCallbackId]; } From a39a38f69e54336a45cd3ac14dfeccb3e40191d9 Mon Sep 17 00:00:00 2001 From: Tracktl Date: Wed, 2 Jul 2014 11:24:28 +0200 Subject: [PATCH 3/4] fix user.id to pass app validation - http://stackoverflow.com/a/14448057/3130279 --- .../FacebookConnectPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m b/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m index a28c76a58..2b8667c3e 100644 --- a/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m +++ b/platforms/ios/HelloCordova/Plugins/com.phonegap.plugins.facebookconnect/FacebookConnectPlugin.m @@ -70,7 +70,7 @@ - (void)sessionStateChanged:(FBSession *)session [FBRequestConnection startForMeWithCompletionHandler: ^(FBRequestConnection *connection, id user, NSError *error) { if (!error) { - self.userid = user.id; + self.userid = [user objectForKey:@"id"]; // Send the plugin result. Wait for a successful fetch of user info. if (self.loginCallbackId) { From 97de8a64c4238cc854e9d730889b7cc7a275f50e Mon Sep 17 00:00:00 2001 From: aogilvie Date: Tue, 8 Jul 2014 12:51:16 +0900 Subject: [PATCH 4/4] version bump and spelling fix --- README.md | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a24528209..aa501d61f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ 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.3.0 and above. -* This plugin is build for +* This plugin is built for * iOS FacebookSDK 3.13.0 * Android FacebookSDK 3.8.0 diff --git a/plugin.xml b/plugin.xml index 83dc3268e..69fdf1aab 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="0.6.0"> Facebook Connect