Skip to content

Commit

Permalink
update for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
aogilvie committed Jan 30, 2014
1 parent b85a188 commit 67e81e1
Show file tree
Hide file tree
Showing 122 changed files with 9,762 additions and 1,312 deletions.
82 changes: 24 additions & 58 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.phonegap.plugins.facebookconnect"
version="0.4.0">
version="0.5.0">

<name>Facebook Connect</name>

Expand All @@ -22,20 +22,28 @@
<asset src="www/facebook-js-sdk.js" target="facebook-js-sdk.js" />

<config-file target="config.xml" parent="/*">
<access origin="https://m.facebook.com" />
<access origin="https://graph.facebook.com" />
<access origin="https://api.facebook.com" />
<access origin="https://*.fbcdn.net" />
<access origin="https://*.akamaihd.net" />
<access origin="https://m.facebook.com" />
<access origin="https://graph.facebook.com" />
<access origin="https://api.facebook.com" />
<access origin="https://*.fbcdn.net" />
<access origin="https://*.akamaihd.net" />
</config-file>

<preference name="APP_ID" />
<preference name="APP_NAME" />

<engines>
<engine name="cordova" version=">=3.0.0" />
<!-- Requires > 3.3.* because of the custom Framework tag for iOS [CB-5238] -->
<engine name="cordova" version=">=3.3.0" />
</engines>

<!-- JavaScript interface -->
<js-module src="www/phonegap/plugin/facebookConnectPlugin/facebookConnectPlugin.js"
name="FacebookConnectPlugin"
target="phonegap/plugin/facebookConnectPlugin/facebookConnectPlugin.js">
<clobbers target="window.facebookConnectPlugin" />
</js-module>

<!-- android -->
<platform name="android">

Expand Down Expand Up @@ -71,9 +79,11 @@
<platform name="ios">

<config-file target="config.xml" parent="/*">
<feature name="org.apache.cordova.facebook.Connect">
<param name="ios-package" value="FacebookConnectPlugin" />
</feature>
<feature name="FacebookConnectPlugin">
<param name="ios-package" value="FacebookConnectPlugin"/>
<param name="onload" value="true" />
</feature>
<plugin name="FacebookConnectPlugin" value="FacebookConnectPlugin"/>
</config-file>

<header-file src="src/ios/FacebookConnectPlugin.h" />
Expand All @@ -98,54 +108,10 @@
</array>
</config-file>

<!-- release facebook 3.5.2 framework -->
<source-file src="src/ios/frameworks/FacebookSDK-3.5.2-Release.a" framework="true" />

<!-- debug facebook 3.5.2 framework -->
<!-- <source-file src="src/ios/frameworks/FacebookSDK-3.5.2-Debug.a" framework="true" /> -->

<!-- facebook header files -->
<header-file src="src/ios/headers/FBAccessTokenData.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBAppCall.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBAppLinkData.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBCacheDescriptor.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBDialogs.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBDialogsData.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBDialogsParams.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBError.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBErrorUtility.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBFrictionlessRecipientCache.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBFriendPickerViewController.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBGraphLocation.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBGraphObject.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBGraphPlace.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBGraphUser.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBInsights.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBLoginView.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBNativeDialogs.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBOpenGraphAction.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBOpenGraphActionShareDialogParams.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBOpenGraphObject.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBPlacePickerViewController.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBProfilePictureView.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBRequest.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBRequestConnection.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBSession.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBSessionTokenCachingStrategy.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBSettings.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBShareDialogParams.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBTestSession.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBUserSettingsViewController.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBViewController.h" target-dir="facebook" />
<header-file src="src/ios/headers/FBWebDialogs.h" target-dir="facebook" />
<header-file src="src/ios/headers/FacebookSDK.h" target-dir="facebook" />
<header-file src="src/ios/headers/NSError+FBError.h" target-dir="facebook" />

<!-- facebook resource bundles -->
<resource-file src="src/ios/resources/FacebookSDKResources.bundle" />
<resource-file src="src/ios/resources/FBUserSettingsViewResources.bundle" />

<!-- system frameworks -->
<!-- Facebook framework -->
<framework src="src/ios/frameworks/FacebookSDK.framework" custom="true" />

<!-- System frameworks -->
<framework src="libsqlite3.dylib" />
<framework src="Social.framework" weak="true" />
<framework src="Accounts.framework" weak="true" />
Expand Down
8 changes: 3 additions & 5 deletions src/ios/FacebookConnectPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// GapFacebookConnect
//
// Created by Jesse MacFadyen on 11-04-22.
// Updated by Ally Ogilvie on 29/Jan/2014.
// Copyright 2011 Nitobi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FacebookSDK.h"

#import <FacebookSDK/FacebookSDK.h>
#import <Cordova/CDV.h>

@interface FacebookConnectPlugin : CDVPlugin {
}

@interface FacebookConnectPlugin : CDVPlugin
@end
70 changes: 39 additions & 31 deletions src/ios/FacebookConnectPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,35 @@ @interface FacebookConnectPlugin ()

@implementation FacebookConnectPlugin


-(CDVPlugin *)initWithWebView:(UIWebView *)theWebView {
NSLog(@"Init FacebookConnect Session");
self = (FacebookConnectPlugin *)[super initWithWebView:theWebView];
self.userid = @"";

[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:NO
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
return self;
}

/* 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];
NSLog(@"handle url: %@", [notification object]);
NSURL* url = [notification object];

if (![url isKindOfClass:[NSURL class]]) {
if (![url isKindOfClass:[NSURL class]]) {
return;
}
[FBSession.activeSession handleOpenURL:url];
}

[FBSession.activeSession handleOpenURL:url];
}

/*
Expand Down Expand Up @@ -138,39 +157,28 @@ - (BOOL)areAllPermissionsReadPermissions:(NSArray*)permissions {
return YES;
}

- (void) init:(CDVInvokedUrlCommand*)command
{
self.userid = @"";

[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:NO
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];

CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void) getLoginStatus:(CDVInvokedUrlCommand*)command
{
{
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:[self responseObject]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void) login:(CDVInvokedUrlCommand*)command
{
- (void)login:(CDVInvokedUrlCommand *)command {
BOOL permissionsAllowed = YES;
NSString *permissionsErrorMessage = @"";
NSArray *permissions = nil;
if ([command.arguments count] > 0) {
permissions = command.arguments;
}
if (permissions == nil) {
// We need permissions
permissionsErrorMessage = @"No permissions specified at login";
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsString:permissionsErrorMessage];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
return;
}

// save the callbackId for the login callback
self.loginCallbackId = command.callbackId;
Expand All @@ -183,6 +191,7 @@ - (void) login:(CDVInvokedUrlCommand*)command
// To mix both, we'll use deprecated methods
BOOL publishPermissionFound = NO;
BOOL readPermissionFound = NO;

for (NSString *p in permissions) {
if ([self isPublishPermission:p]) {
publishPermissionFound = YES;
Expand All @@ -195,6 +204,7 @@ - (void) login:(CDVInvokedUrlCommand*)command
break;
}
}

if (publishPermissionFound && readPermissionFound) {
// Mix of permissions, not allowed
permissionsAllowed = NO;
Expand Down Expand Up @@ -237,9 +247,6 @@ - (void) login:(CDVInvokedUrlCommand*)command
permissionsAllowed = NO;
permissionsErrorMessage = @"You can only ask for read permissions initially";
}



}

if (!permissionsAllowed) {
Expand Down Expand Up @@ -314,10 +321,11 @@ - (void) showDialog:(CDVInvokedUrlCommand*)command
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon to Cancel
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsString:@"User cancelled."];
} else {
// Send the URL parameters back, for a requests dialog, the "request" parameter
// will include the resutling request id. For a feed dialog, the "post_id"
// will include the resluting request id. For a feed dialog, the "post_id"
// parameter will include the resulting post id.
NSDictionary *params = [self parseURLParams:[resultURL query]];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:params];
Expand Down
Binary file removed src/ios/frameworks/FacebookSDK-3.5.2-Debug.a
Binary file not shown.
Binary file removed src/ios/frameworks/FacebookSDK-3.5.2-Release.a
Binary file not shown.
1 change: 1 addition & 0 deletions src/ios/frameworks/FacebookSDK.framework/FacebookSDK
1 change: 1 addition & 0 deletions src/ios/frameworks/FacebookSDK.framework/Headers
1 change: 1 addition & 0 deletions src/ios/frameworks/FacebookSDK.framework/Resources
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,48 @@
*/

#import <Foundation/Foundation.h>

#import "FBSession.h"

/*!
@class FBAccessTokenData
@abstract Represents an access token used for the Facebook login flow
and includes associated metadata such as expiration date and permissions.
You should use factory methods (createToken...) to construct instances
and should be treated as immutable.
@discussion For more information, see
@discussion For more information, see
https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/.
*/
@interface FBAccessTokenData : NSObject <NSCopying>

/*!
@method
@abstract Creates an FBAccessTokenData from an App Link provided by the Facebook application
or nil if the url is not valid.
@param url The url provided.
@param appID needed in order to verify URL format.
@param urlSchemeSuffix needed in order to verify URL format.
*/
+ (FBAccessTokenData *) createTokenFromFacebookURL:(NSURL *)url appID:(NSString *)appID urlSchemeSuffix:(NSString *)urlSchemeSuffix;

/*!
@method
@abstract Creates an FBAccessTokenData from a dictionary or returns nil if required data is missing.
@param dictionary the dictionary with FBSessionTokenCachingStrategy keys.
*/
+ (FBAccessTokenData *) createTokenFromDictionary:(NSDictionary *)dictionary;

/*!
@method
@abstract Creates an FBAccessTokenData from existing information or returns nil if required data is missing.
@param accessToken The token string. If nil or empty, this method will return nil.
@param permissions The permissions set. A value of nil indicates basic permissions.
@param expirationDate The expiration date. A value of nil defaults to `[NSDate distantFuture]`.
Expand All @@ -70,19 +71,38 @@

/*!
@method
@abstract Creates an FBAccessTokenData from existing information or returns nil if required data is missing.
@param accessToken The token string. If nil or empty, this method will return nil.
@param permissions The permissions set. A value of nil indicates basic permissions.
@param expirationDate The expiration date. A value of nil defaults to `[NSDate distantFuture]`.
@param loginType The login source of the token.
@param refreshDate The date that token was last refreshed. A value of nil defaults to `[NSDate date]`.
@param permissionsRefreshDate The date the permissions were last refreshed. A value of nil defaults to `[NSDate distantPast]`.
*/
+ (FBAccessTokenData *) createTokenFromString:(NSString *)accessToken
permissions:(NSArray *)permissions
expirationDate:(NSDate *)expirationDate
loginType:(FBSessionLoginType)loginType
refreshDate:(NSDate *)refreshDate
permissionsRefreshDate:(NSDate *)permissionsRefreshDate;

/*!
@method
@abstract Returns a dictionary representation of this instance.
@discussion This is provided for backwards compatibility with previous
access token related APIs that used a NSDictionary (see `FBSessionTokenCachingStrategy`).
*/
- (NSMutableDictionary *) dictionary;

/*!
@method
@abstract Returns a Boolean value that indicates whether a given object is an FBAccessTokenData object and exactly equal the receiver.
@param accessTokenData the data to compare to the receiver.
*/
- (BOOL) isEqualToAccessTokenData:(FBAccessTokenData *)accessTokenData;
Expand Down Expand Up @@ -112,4 +132,9 @@
*/
@property (readonly, nonatomic, copy) NSDate *refreshDate;

/*!
@abstract returns the date the permissions were last refreshed.
*/
@property (readonly, nonatomic, copy) NSDate *permissionsRefreshDate;

@end
Loading

0 comments on commit 67e81e1

Please sign in to comment.