This repository was archived by the owner on Jan 16, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 89
Add support for tvOS platform. #23
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e66cec3
Add Parse/Bolts frameworks for tvOS.
nlutsenko 83bc5fa
Add ParseFacebookUtils for tvOS target.
nlutsenko 8b5f8f2
Update target framework dependencies.
nlutsenko 6bfa512
Update fetch dependencies script for tvOS target.
nlutsenko d6fd99e
Refactor FacebookAuthenticationProvider into Mobile/Device to support…
nlutsenko 83a13ab
Update podspec to support tvOS.
nlutsenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Copyright (c) 2015-present, Parse, LLC. | ||
// All rights reserved. | ||
// | ||
// This source code is licensed under the BSD-style license found in the | ||
// LICENSE file in the root directory of this source tree. An additional grant | ||
// of patent rights can be found in the PATENTS file in the same directory. | ||
// | ||
|
||
#include "Shared/Platform/tvOS.xcconfig" | ||
#include "Shared/Product/Framework.xcconfig" | ||
|
||
PRODUCT_NAME = ParseFacebookUtilsV4 | ||
|
||
MACH_O_TYPE = staticlib | ||
DEFINES_MODULE = YES | ||
CLANG_ENABLE_MODULES = YES | ||
|
||
INFOPLIST_FILE = $(SRCROOT)/Resources/Info-tvOS.plist | ||
|
||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(SRCROOT)/Vendor/tvOS |
Large diffs are not rendered by default.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
ParseFacebookUtils.xcodeproj/xcshareddata/xcschemes/ParseFacebookUtilsV4-tvOS.xcscheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "0720" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "81FE7F731C17790400E6BD34" | ||
BuildableName = "ParseFacebookUtilsV4.framework" | ||
BlueprintName = "ParseFacebookUtilsV4-tvOS" | ||
ReferencedContainer = "container:ParseFacebookUtils.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "81FE7F731C17790400E6BD34" | ||
BuildableName = "ParseFacebookUtilsV4.framework" | ||
BlueprintName = "ParseFacebookUtilsV4-tvOS" | ||
ReferencedContainer = "container:ParseFacebookUtils.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
<AdditionalOptions> | ||
</AdditionalOptions> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "81FE7F731C17790400E6BD34" | ||
BuildableName = "ParseFacebookUtilsV4.framework" | ||
BlueprintName = "ParseFacebookUtilsV4-tvOS" | ||
ReferencedContainer = "container:ParseFacebookUtils.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
ParseFacebookUtils/Internal/AuthenticationProvider/PFFacebookAuthenticationProvider.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright (c) 2015-present, Parse, LLC. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "PFFacebookAuthenticationProvider.h" | ||
|
||
#import <FBSDKCoreKit/FBSDKAccessToken.h> | ||
#import <FBSDKCoreKit/FBSDKApplicationDelegate.h> | ||
|
||
#import "PFFacebookPrivateUtilities.h" | ||
|
||
NSString *const PFFacebookUserAuthenticationType = @"facebook"; | ||
|
||
@implementation PFFacebookAuthenticationProvider | ||
|
||
///-------------------------------------- | ||
#pragma mark - Init | ||
///-------------------------------------- | ||
|
||
- (instancetype)initWithApplication:(UIApplication *)application | ||
launchOptions:(nullable NSDictionary *)launchOptions { | ||
self = [super init]; | ||
if (!self) return nil; | ||
|
||
[[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication] | ||
didFinishLaunchingWithOptions:launchOptions]; | ||
|
||
return self; | ||
} | ||
|
||
+ (instancetype)providerWithApplication:(UIApplication *)application | ||
launchOptions:(nullable NSDictionary *)launchOptions { | ||
return [[self alloc] initWithApplication:application launchOptions:launchOptions]; | ||
} | ||
|
||
///-------------------------------------- | ||
#pragma mark - Authenticate | ||
///-------------------------------------- | ||
|
||
- (BFTask PF_GENERIC(NSDictionary<NSString *, NSString *>*)*)authenticateAsyncWithReadPermissions:(nullable NSArray PF_GENERIC(NSString *)*)readPermissions | ||
publishPermissions:(nullable NSArray PF_GENERIC(NSString *)*)publishPermissions { | ||
return [self authenticateAsyncWithReadPermissions:readPermissions | ||
publishPermissions:publishPermissions | ||
fromViewComtroller:[PFFacebookPrivateUtilities applicationTopViewController]]; | ||
} | ||
|
||
- (BFTask PF_GENERIC(NSDictionary<NSString *, NSString *>*)*)authenticateAsyncWithReadPermissions:(nullable NSArray PF_GENERIC(NSString *)*)readPermissions | ||
publishPermissions:(nullable NSArray PF_GENERIC(NSString *)*)publishPermissions | ||
fromViewComtroller:(UIViewController *)viewController { | ||
return [BFTask taskWithError:[NSError pffb_invalidFacebookSessionError]]; | ||
} | ||
|
||
///-------------------------------------- | ||
#pragma mark - PFUserAuthenticationDelegate | ||
///-------------------------------------- | ||
|
||
- (BOOL)restoreAuthenticationWithAuthData:(nullable NSDictionary PF_GENERIC(NSString *, NSString *)*)authData { | ||
FBSDKAccessToken *token = [PFFacebookPrivateUtilities facebookAccessTokenFromUserAuthenticationData:authData]; | ||
if (!token) { | ||
return !authData; // Only deauthenticate if authData was nil, otherwise - return failure (`NO`). | ||
} | ||
|
||
FBSDKAccessToken *currentToken = [FBSDKAccessToken currentAccessToken]; | ||
// Do not reset the current token if we have the same token already set. | ||
if (![currentToken.userID isEqualToString:token.userID] || | ||
![currentToken.tokenString isEqualToString:token.tokenString]) { | ||
[FBSDKAccessToken setCurrentAccessToken:token]; | ||
} | ||
|
||
return YES; | ||
} | ||
|
||
@end |
29 changes: 29 additions & 0 deletions
29
...acebookUtils/Internal/AuthenticationProvider/iOS/PFFacebookMobileAuthenticationProvider.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) 2015-present, Parse, LLC. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import <FBSDKLoginKit/FBSDKLoginManager.h> | ||
|
||
#import <Parse/PFConstants.h> | ||
#import <Parse/PFUser.h> | ||
|
||
#import "PFFacebookAuthenticationProvider.h" | ||
|
||
@class BFTask PF_GENERIC(__covariant BFGenericType); | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface PFFacebookMobileAuthenticationProvider : PFFacebookAuthenticationProvider | ||
|
||
@property (nonatomic, strong, readonly) FBSDKLoginManager *loginManager; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
88 changes: 88 additions & 0 deletions
88
...acebookUtils/Internal/AuthenticationProvider/iOS/PFFacebookMobileAuthenticationProvider.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright (c) 2015-present, Parse, LLC. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "PFFacebookMobileAuthenticationProvider.h" | ||
#import "PFFacebookMobileAuthenticationProvider_Private.h" | ||
|
||
#import <Bolts/BFTask.h> | ||
#import <Bolts/BFTaskCompletionSource.h> | ||
|
||
#import <FBSDKCoreKit/FBSDKAccessToken.h> | ||
#import <FBSDKCoreKit/FBSDKSettings.h> | ||
|
||
#import <FBSDKLoginKit/FBSDKLoginManagerLoginResult.h> | ||
|
||
#import <Parse/PFConstants.h> | ||
|
||
#import "PFFacebookPrivateUtilities.h" | ||
|
||
@implementation PFFacebookMobileAuthenticationProvider | ||
|
||
///-------------------------------------- | ||
#pragma mark - Init | ||
///-------------------------------------- | ||
|
||
- (instancetype)initWithApplication:(UIApplication *)application | ||
launchOptions:(nullable NSDictionary *)launchOptions { | ||
self = [super initWithApplication:application launchOptions:launchOptions]; | ||
if (!self) return nil; | ||
|
||
_loginManager = [[FBSDKLoginManager alloc] init]; | ||
|
||
return self; | ||
} | ||
|
||
///-------------------------------------- | ||
#pragma mark - Authenticate | ||
///-------------------------------------- | ||
|
||
- (BFTask PF_GENERIC(NSDictionary<NSString *, NSString *>*)*)authenticateAsyncWithReadPermissions:(nullable NSArray PF_GENERIC(NSString *) *)readPermissions | ||
publishPermissions:(nullable NSArray PF_GENERIC(NSString *) *)publishPermissions | ||
fromViewComtroller:(UIViewController *)viewController { | ||
if (readPermissions && publishPermissions) { | ||
NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException | ||
reason:@"Read permissions are not permitted to be requested with publish permissions." | ||
userInfo:nil]; | ||
return [BFTask taskWithException:exception]; | ||
} | ||
|
||
BFTaskCompletionSource *taskCompletionSource = [BFTaskCompletionSource taskCompletionSource]; | ||
FBSDKLoginManagerRequestTokenHandler resultHandler = ^(FBSDKLoginManagerLoginResult *result, NSError *error) { | ||
if (result.isCancelled) { | ||
[taskCompletionSource cancel]; | ||
} else if (error) { | ||
taskCompletionSource.error = error; | ||
} else { | ||
taskCompletionSource.result = [PFFacebookPrivateUtilities userAuthenticationDataFromAccessToken:result.token]; | ||
} | ||
}; | ||
if (publishPermissions) { | ||
[self.loginManager logInWithPublishPermissions:publishPermissions | ||
fromViewController:viewController | ||
handler:resultHandler]; | ||
} else { | ||
[self.loginManager logInWithReadPermissions:readPermissions | ||
fromViewController:viewController | ||
handler:resultHandler]; | ||
} | ||
return taskCompletionSource.task; | ||
} | ||
|
||
///-------------------------------------- | ||
#pragma mark - PFUserAuthenticationDelegate | ||
///-------------------------------------- | ||
|
||
- (BOOL)restoreAuthenticationWithAuthData:(nullable NSDictionary PF_GENERIC(NSString *, NSString *) *)authData { | ||
if (!authData) { | ||
[self.loginManager logOut]; | ||
} | ||
return [super restoreAuthenticationWithAuthData:authData]; | ||
} | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...cebookUtils/Internal/AuthenticationProvider/tvOS/PFFacebookDeviceAuthenticationProvider.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright (c) 2015-present, Parse, LLC. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "PFFacebookAuthenticationProvider.h" | ||
|
||
@interface PFFacebookDeviceAuthenticationProvider : PFFacebookAuthenticationProvider | ||
|
||
@end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I hate the name 'device' to refer to tvOS, but seeing as its FBSDKs decision, we really should keep it that way I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Naming here is totally influenced by FBSDK.