Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ParseUI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ Pod::Spec.new do |s|
'CoreGraphics',
'QuartzCore'

s.dependency 'Parse', '~> 1.6'
s.dependency 'ParseFacebookUtils', '~> 1.6'
s.dependency 'Parse', '~> 1.7'
end
6 changes: 3 additions & 3 deletions ParseUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = PF;
LastUpgradeCheck = 0610;
LastUpgradeCheck = 0620;
ORGANIZATIONNAME = "Parse Inc.";
TargetAttributes = {
81472F661A1AB33800FD6EED = {
Expand Down Expand Up @@ -1219,7 +1219,7 @@
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = ParseUIDemo/Other/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1251,7 +1251,7 @@
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = ParseUIDemo/Other/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
2 changes: 1 addition & 1 deletion ParseUI.xcodeproj/xcshareddata/xcschemes/ParseUI.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,7 +48,8 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8129E5DE1A9CB067006752BC"
Expand All @@ -66,7 +67,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8129E5DE1A9CB067006752BC"
Expand Down
8 changes: 5 additions & 3 deletions ParseUI.xcodeproj/xcshareddata/xcschemes/ParseUIDemo.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,7 +48,8 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "81472F661A1AB33800FD6EED"
Expand All @@ -66,7 +67,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "81472F661A1AB33800FD6EED"
Expand Down
58 changes: 49 additions & 9 deletions ParseUI/Classes/LogInViewController/PFLogInViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
This protocol exists so that we can weakly refer to messages to pass to PFFacebookUtils without
actually taking a dependency on the symbols.
*/
@protocol WeaklyReferencedFBUtils
@protocol WeaklyReferencedFBUtils <NSObject>

+ (void)logInWithPermissions:(NSArray *)permissions block:(void(^)(PFUser *user, NSError *error))block;
// FBSDKv3
+ (void)logInWithPermissions:(NSArray *)permissions block:(PFUserResultBlock)block;
// FBSDKv4
+ (void)logInInBackgroundWithReadPermissions:(NSArray *)permissions block:(PFUserResultBlock)block;
+ (void)logInInBackgroundWithPublishPermissions:(NSArray *)permissions block:(PFUserResultBlock)block;

@end

Expand Down Expand Up @@ -279,6 +283,8 @@ - (void)_requestPasswordResetWithEmail:(NSString *)email {
}];
}

#pragma mark Log In With Facebook

- (void)_loginWithFacebook {
if (self.loading) {
return;
Expand All @@ -289,23 +295,55 @@ - (void)_loginWithFacebook {
[(PFActionButton *)_logInView.facebookButton setLoading:YES];
}

Class fbUtils = NSClassFromString(@"PFFacebookUtils");
[fbUtils logInWithPermissions:_facebookPermissions block:^(PFUser *user, NSError *error) {
self.loading = NO;
__weak typeof(self) wself = self;
PFUserResultBlock resultBlock = ^(PFUser *user, NSError *error) {
__strong typeof(wself) sself = wself;
sself.loading = NO;
if ([_logInView.facebookButton isKindOfClass:[PFActionButton class]]) {
[(PFActionButton *)_logInView.facebookButton setLoading:NO];
}

if (user) {
[self _loginDidSuceedWithUser:user];
[sself _loginDidSuceedWithUser:user];
} else if (error) {
[self _loginDidFailWithError:error];
[sself _loginDidFailWithError:error];
} else {
// User cancelled login.
}
}];
};

Class fbUtils = NSClassFromString(@"PFFacebookUtils");
if ([fbUtils respondsToSelector:@selector(logInWithPermissions:block:)]) {
// Facebook SDK v3 Login
[fbUtils logInWithPermissions:_facebookPermissions block:resultBlock];
} else if ([fbUtils respondsToSelector:@selector(logInInBackgroundWithReadPermissions:block:)]) {
// Facebook SDK v4 Login
if ([self _permissionsContainsFacebookPublishPermission:_facebookPermissions]) {
[fbUtils logInInBackgroundWithPublishPermissions:_facebookPermissions block:resultBlock];
} else {
[fbUtils logInInBackgroundWithReadPermissions:_facebookPermissions block:resultBlock];
}
} else {
[NSException raise:NSInternalInconsistencyException
format:@"Can't find PFFacebookUtils. Please link with ParseFacebookUtils or ParseFacebookUtilsV4 to enable login with Facebook."];
}
}

- (BOOL)_permissionsContainsFacebookPublishPermission:(NSArray *)permissions {
for (NSString *permission in permissions) {
if ([permission hasPrefix:@"publish"] ||
[permission hasPrefix:@"manage"] ||
[permission isEqualToString:@"ads_management"] ||
[permission isEqualToString:@"create_event"] ||
[permission isEqualToString:@"rsvp_event"]) {
return YES;
}
}
return NO;
}

#pragma mark Log In With Twitter

- (void)_loginWithTwitter {
if (self.loading) {
return;
Expand All @@ -332,6 +370,8 @@ - (void)_loginWithTwitter {
}];
}

#pragma mark Log In

- (void)_loginAction {
if (self.loading) {
return;
Expand Down Expand Up @@ -522,7 +562,7 @@ - (void)_updateViewContentOffsetAnimated:(BOOL)animated {
contentOffset = CGPointMake(0.0f, MIN(offsetForScrollingTextFieldToTop,
offsetForScrollingLowestViewToBottom));
}

[_logInView setContentOffset:contentOffset animated:animated];
}

Expand Down
17 changes: 7 additions & 10 deletions ParseUIDemo/Classes/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#import "AppDelegate.h"

#import <Parse/Parse.h>

#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <FBSDKCoreKit/FBSDKApplicationDelegate.h>

#import "PFUIDemoViewController.h"

Expand All @@ -35,7 +35,7 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Parse setApplicationId:@"UdNpOP2XFoEiXLZEBDl6xONmCMH8VjETmnEsl0xJ"
clientKey:@"wNJFho0fQaQFQ2Fe1x9b67lVBakJiAtFj1Uz30A9"];
[PFFacebookUtils initializeFacebook];
[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];
[PFTwitterUtils initializeWithConsumerKey:@"3Q9hMEKqqSg4ie2pibZ2sVJuv"
consumerSecret:@"IEZ9wv2d1EpXNGFKGp7sAGdxRtyqtPwygyciFZwTHTGhPp4FMj"];

Expand All @@ -54,13 +54,10 @@ - (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
withSession:[PFFacebookUtils session]];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}

#pragma mark -
Expand Down
8 changes: 2 additions & 6 deletions ParseUIDemo/Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
Parse.setApplicationId("UdNpOP2XFoEiXLZEBDl6xONmCMH8VjETmnEsl0xJ", clientKey: "wNJFho0fQaQFQ2Fe1x9b67lVBakJiAtFj1Uz30A9")
PFFacebookUtils.initializeFacebook()
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions);
PFTwitterUtils.initializeWithConsumerKey("3Q9hMEKqqSg4ie2pibZ2sVJuv", consumerSecret: "IEZ9wv2d1EpXNGFKGp7sAGdxRtyqtPwygyciFZwTHTGhPp4FMj")

window = UIWindow(frame: UIScreen.mainScreen().bounds)
Expand All @@ -46,11 +46,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
return FBAppCall.handleOpenURL(url, sourceApplication: sourceApplication, withSession: PFFacebookUtils.session())
}

func applicationDidBecomeActive(application: UIApplication) {
FBAppCall.handleDidBecomeActiveWithSession(PFFacebookUtils.session())
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

// MARK: Test Data
Expand Down
3 changes: 2 additions & 1 deletion ParseUIDemo/Swift/ParseUIDemo-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define ParseStarterProject_Bridging_Header_h

#import <Bolts/Bolts.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

#endif
5 changes: 3 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source 'https://github.com/CocoaPods/Specs.git'
workspace 'ParseUI'
xcodeproj 'ParseUI.xcodeproj'
link_with 'ParseUIDemo'
platform :ios, "7.0"

pod 'Parse', '~> 1.6'
pod 'ParseFacebookUtils', '~> 1.6'
pod 'Parse', '~> 1.7'
pod 'ParseFacebookUtilsV4', '~> 1.7'