Skip to content

Commit

Permalink
fixed issue with merge
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengill committed Mar 29, 2012
1 parent 17e68fe commit 1c8f97f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -11,7 +11,7 @@ This is all licensed under MIT except for `app/www/facebook_js_sdk.js` which is

# Requirements

* PhoneGap (Cordova) v1.5
* PhoneGap (Cordova) v1.5 (For compatibility with older versions of PhoneGap, please download the tag [1.4.1support](https://github.com/davejohnson/phonegap-plugin-facebook-connect/zipball/1.4.1support))

The Facebook SDK (both native and JavaScript) is changing independent of this plugin. The working versions of the Facebook Android and iOS SDKs are bundled in this project via git submodules.

Expand Down
33 changes: 16 additions & 17 deletions native/ios/FacebookConnectPlugin.m
Expand Up @@ -10,13 +10,13 @@
#import "FacebookConnectPlugin.h"
#import "JSON.h"

#define APP_SECRET @"IgnoreMe"
#define APP_SECRET @"IGNORE"

@implementation FacebookConnectPlugin

@synthesize facebook, loginCallbackId;

/* This overrides PGPlugin's method, which receives a notification when handleOpenURL is called on the main app delegate */
/* This overrides CDVPlugin's method, which receives a notification when handleOpenURL is called on the main app delegate */
- (void) handleOpenURL:(NSNotification*)notification
{
NSURL* url = [notification object];
Expand All @@ -37,24 +37,24 @@ - (void) init:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
NSString* callbackId = [arguments objectAtIndex:0];
NSString* appId = [arguments objectAtIndex:1];
self.facebook = [[Facebook alloc] initWithAppId:appId andDelegate: self];

// Check for any stored session update Facebook session information
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
self.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
self.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}

PluginResult* result = [PluginResult resultWithStatus:PGCommandStatus_OK];
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[super writeJavascript:[result toSuccessCallbackString:callbackId]];
}

- (void) getLoginStatus:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
NSString* callbackId = [arguments objectAtIndex:0]; // first item is the callbackId

PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_OK messageAsDictionary:[self responseObject]];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self responseObject]];
NSString* callback = [pluginResult toSuccessCallbackString:callbackId];
// we need to wrap the callback in a setTimeout(func, 0) so it doesn't block the UI (handleOpenURL limitation)
[super writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", callback]];
Expand Down Expand Up @@ -89,7 +89,7 @@ - (void) logout:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)option

[facebook logout];

PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_OK];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[super writeJavascript:[pluginResult toSuccessCallbackString:callbackId]];
}

Expand All @@ -99,7 +99,7 @@ - (void) showFeedPublishDialog:(NSMutableArray*)arguments withDict:(NSMutableDic

[facebook dialog:@"feed" andDelegate:self];

PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_NO_RESULT];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
NSString* callback = [pluginResult toSuccessCallbackString:callbackId];
[super writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", callback]];
}
Expand All @@ -125,7 +125,7 @@ - (void) showDialog:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)op
[method release];
[params release];

PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_NO_RESULT];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
NSString* callback = [pluginResult toSuccessCallbackString:callbackId];
[super writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", callback]];
}
Expand Down Expand Up @@ -154,7 +154,6 @@ - (NSDictionary*) responseObject
self.facebook.accessToken,
expiresIn,
APP_SECRET,

[NSNumber numberWithBool:YES],
@"...",
@"...",
Expand Down Expand Up @@ -193,10 +192,10 @@ - (void) fbDidLogin
[defaults setObject:[self.facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[self.facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];

[facebook requestWithGraphPath:@"me" andDelegate:self];

PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_OK messageAsDictionary:
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:
[self responseObject]];
NSString* callback = [pluginResult toSuccessCallbackString:self.loginCallbackId];

Expand All @@ -206,7 +205,7 @@ - (void) fbDidLogin
}

- (void)fbDidLogout {
// Cleared stored session information
// Cleared stored session information
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:@"FBAccessTokenKey"];
[defaults removeObjectForKey:@"FBExpirationDateKey"];
Expand Down Expand Up @@ -252,7 +251,7 @@ - (void)fbSessionInvalidated {
*/
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error
{

}

/**
Expand All @@ -264,7 +263,7 @@ - (void)request:(FBRequest *)request didFailWithError:(NSError *)error
*/
- (void) request:(FBRequest *)request didLoad:(id)result
{
PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_OK messageAsDictionary:
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:
[self responseObject]];
NSString* callback = [pluginResult toSuccessCallbackString:self.loginCallbackId];
// we need to wrap the callback in a setTimeout(func, 0) so it doesn't block the UI (handleOpenURL limitation)
Expand Down Expand Up @@ -323,7 +322,7 @@ - (void)dialogDidNotComplete:(FBDialog *)dialog
*/
- (void)dialog:(FBDialog*)dialog didFailWithError:(NSError *)error
{

}

/**
Expand Down

0 comments on commit 1c8f97f

Please sign in to comment.