- Upgrade Libraries
This commit is contained in:
parent
1629110349
commit
a03a974df9
@ -35,7 +35,7 @@
|
|||||||
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @{BaseUrl:@"http://pnobject.local/",EndpointPath:@"api/v1/"},
|
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @{BaseUrl:@"http://pnobject.local/",EndpointPath:@"api/v1/"},
|
||||||
EnvironmentStage : @{BaseUrl:@"https://pnobject.stage.it/",EndpointPath:@"api/v1/"},
|
EnvironmentStage : @{BaseUrl:@"https://pnobject.stage.it/",EndpointPath:@"api/v1/"},
|
||||||
EnvironmentProduction : @{BaseUrl:@"http://pnobject.prod.it/",EndpointPath:@"api/v1/"},
|
EnvironmentProduction : @{BaseUrl:@"http://pnobject.prod.it/",EndpointPath:@"api/v1/"},
|
||||||
} andUserSubclass:[PNUser class]];
|
} userSubclass:[PNUser class] andStoreClientIdentifier:@"ftiuyvkbyfi789ptf78"];
|
||||||
|
|
||||||
/** Can user special char %@ to autoset EndpointPath to Oauth endpointPath */
|
/** Can user special char %@ to autoset EndpointPath to Oauth endpointPath */
|
||||||
[[PNObjectConfig sharedInstance] setClientID:@"******" clientSecret:@"******" oAuthEndpointAction:@"%@oauth-token" oauthMode:OAuthModeClientCredential refreshTokenEnabled:NO forEnv:EnvironmentStage];
|
[[PNObjectConfig sharedInstance] setClientID:@"******" clientSecret:@"******" oAuthEndpointAction:@"%@oauth-token" oauthMode:OAuthModeClientCredential refreshTokenEnabled:NO forEnv:EnvironmentStage];
|
||||||
|
|||||||
@ -26,33 +26,39 @@ PODS:
|
|||||||
- DJLocalization/Core (= 1.2.2)
|
- DJLocalization/Core (= 1.2.2)
|
||||||
- DJLocalization/Core (1.2.2)
|
- DJLocalization/Core (1.2.2)
|
||||||
- Expecta (1.0.6)
|
- Expecta (1.0.6)
|
||||||
- Facebook-iOS-SDK (4.38.0):
|
- FacebookSDK (4.38.0):
|
||||||
- Bolts (~> 1.9)
|
- Bolts (~> 1.9)
|
||||||
- Facebook-iOS-SDK/CoreKit (= 4.38.0)
|
- FacebookSDK/CoreKit (= 4.38.0)
|
||||||
- Facebook-iOS-SDK/MarketingKit (= 4.38.0)
|
- FacebookSDK/MarketingKit (= 4.38.0)
|
||||||
- Facebook-iOS-SDK/CoreKit (4.38.0):
|
- FacebookSDK/CoreKit (4.38.0):
|
||||||
- Bolts (~> 1.9)
|
- Bolts (~> 1.9)
|
||||||
- FBSDKCoreKit
|
- FBSDKCoreKit
|
||||||
- Facebook-iOS-SDK/MarketingKit (4.38.0):
|
- FacebookSDK/MarketingKit (4.38.0):
|
||||||
- Bolts (~> 1.9)
|
- Bolts (~> 1.9)
|
||||||
- Facebook-iOS-SDK/CoreKit
|
- FacebookSDK/CoreKit
|
||||||
- FBSDKMarketingKit
|
- FBSDKMarketingKit
|
||||||
- FBSDKCoreKit (4.39.0):
|
- FBSDKCoreKit (4.39.0):
|
||||||
- Bolts (~> 1.9)
|
- Bolts (~> 1.9)
|
||||||
|
- FBSDKLoginKit (4.39.0):
|
||||||
|
- FBSDKCoreKit
|
||||||
- FBSDKMarketingKit (4.38.0):
|
- FBSDKMarketingKit (4.38.0):
|
||||||
- FBSDKCoreKit
|
- FBSDKCoreKit
|
||||||
|
- FBSDKShareKit (4.39.0):
|
||||||
|
- FBSDKCoreKit
|
||||||
- NSDataAES (0.2.2)
|
- NSDataAES (0.2.2)
|
||||||
- NSDate_Utils (1.1.0):
|
- NSDate_Utils (1.1.0):
|
||||||
- DJLocalization
|
- DJLocalization
|
||||||
- NSString-Helper (1.2.0)
|
- NSString-Helper (1.2.0)
|
||||||
- nv-ios-http-status (0.0.1)
|
- nv-ios-http-status (0.0.1)
|
||||||
- PEAR-FileManager-iOS (1.3.1)
|
- PEAR-FileManager-iOS (1.3.1)
|
||||||
- PNObject (2.6.0):
|
- PNObject (2.6.1):
|
||||||
- AFNetworking
|
- AFNetworking
|
||||||
- CodFis-Helper
|
- CodFis-Helper
|
||||||
- DDDKeychainWrapper
|
- DDDKeychainWrapper
|
||||||
- DJLocalization
|
- DJLocalization
|
||||||
- Facebook-iOS-SDK
|
- FacebookSDK
|
||||||
|
- FBSDKLoginKit
|
||||||
|
- FBSDKShareKit
|
||||||
- NSDataAES
|
- NSDataAES
|
||||||
- NSDate_Utils
|
- NSDate_Utils
|
||||||
- NSString-Helper
|
- NSString-Helper
|
||||||
@ -81,9 +87,11 @@ SPEC REPOS:
|
|||||||
- DDDKeychainWrapper
|
- DDDKeychainWrapper
|
||||||
- DJLocalization
|
- DJLocalization
|
||||||
- Expecta
|
- Expecta
|
||||||
- Facebook-iOS-SDK
|
- FacebookSDK
|
||||||
- FBSDKCoreKit
|
- FBSDKCoreKit
|
||||||
|
- FBSDKLoginKit
|
||||||
- FBSDKMarketingKit
|
- FBSDKMarketingKit
|
||||||
|
- FBSDKShareKit
|
||||||
- NSDataAES
|
- NSDataAES
|
||||||
- NSDate_Utils
|
- NSDate_Utils
|
||||||
- NSString-Helper
|
- NSString-Helper
|
||||||
@ -106,15 +114,17 @@ SPEC CHECKSUMS:
|
|||||||
DDDKeychainWrapper: e681a4daba6448786fa83b4941f58102a33b1897
|
DDDKeychainWrapper: e681a4daba6448786fa83b4941f58102a33b1897
|
||||||
DJLocalization: 0c84029af375647d4104a42ae36be87194c46c47
|
DJLocalization: 0c84029af375647d4104a42ae36be87194c46c47
|
||||||
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
|
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
|
||||||
Facebook-iOS-SDK: 9077b67c4178ea46c62997bcf2b6314ca6555440
|
FacebookSDK: 73f54b8b94e09b05647cdef0af147f470cd3edc6
|
||||||
FBSDKCoreKit: 1e3981faefab8c88edfaa9eecd94aab02d99a9bc
|
FBSDKCoreKit: 1e3981faefab8c88edfaa9eecd94aab02d99a9bc
|
||||||
|
FBSDKLoginKit: 30ba5039a2c53d65a75103889bc2deebdacd5a1f
|
||||||
FBSDKMarketingKit: e609f39d74ab273cf52e2f8b7e8829ed412b2827
|
FBSDKMarketingKit: e609f39d74ab273cf52e2f8b7e8829ed412b2827
|
||||||
|
FBSDKShareKit: 5a0021c30abb64df9eeba87351dd8a627874543b
|
||||||
NSDataAES: 967ea3337476a80e9838a533c25d570a06855ed0
|
NSDataAES: 967ea3337476a80e9838a533c25d570a06855ed0
|
||||||
NSDate_Utils: c858a89da6e204ecf53aca48dbccb4da4d25bc9e
|
NSDate_Utils: c858a89da6e204ecf53aca48dbccb4da4d25bc9e
|
||||||
NSString-Helper: 1c259caa6c845e79e0bb45ee25e34f95d86d2317
|
NSString-Helper: 1c259caa6c845e79e0bb45ee25e34f95d86d2317
|
||||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||||
PNObject: 11e8fe8e955d327a9832ed63f6720f60b877d66a
|
PNObject: 4dd707682a5933f247091a23e39bf9688ea7e367
|
||||||
PureLayout: f08c01b8dec00bb14a1fefa3de4c7d9c265df85e
|
PureLayout: f08c01b8dec00bb14a1fefa3de4c7d9c265df85e
|
||||||
RZDataBinding: 289e2fbdce8b9585afef69def83425c5d380ffbd
|
RZDataBinding: 289e2fbdce8b9585afef69def83425c5d380ffbd
|
||||||
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
|
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
|
||||||
|
|||||||
62
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.h
generated
Normal file
62
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.h
generated
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Describes the initial response when starting the device login flow.
|
||||||
|
@discussion This is used by `FBSDKDeviceLoginManager`.
|
||||||
|
*/
|
||||||
|
@interface FBSDKDeviceLoginCodeInfo : NSObject
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract There is no public initializer.
|
||||||
|
*/
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the unique id for this login flow.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, readonly) NSString *identifier;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the short "user_code" that should be presented to the user.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, readonly) NSString *loginCode;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the verification URL.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, readonly) NSURL *verificationURL;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the expiration date.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, readonly) NSDate *expirationDate;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the polling interval
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign, readonly) NSUInteger pollingInterval;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
38
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.m
generated
Normal file
38
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.m
generated
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKDeviceLoginCodeInfo+Internal.h"
|
||||||
|
|
||||||
|
@implementation FBSDKDeviceLoginCodeInfo
|
||||||
|
|
||||||
|
- (instancetype) initWithIdentifier:(NSString *)identifier
|
||||||
|
loginCode:(NSString *)loginCode
|
||||||
|
verificationURL:(NSURL *)verificationURL
|
||||||
|
expirationDate:(NSDate *)expirationDate
|
||||||
|
pollingInterval:(NSUInteger)pollingInterval
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_identifier = [identifier copy];
|
||||||
|
_loginCode = [loginCode copy];
|
||||||
|
_verificationURL = [verificationURL copy];
|
||||||
|
_expirationDate = [expirationDate copy];
|
||||||
|
_pollingInterval = pollingInterval;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
@end
|
||||||
105
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManager.h
generated
Normal file
105
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManager.h
generated
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKDeviceLoginManagerResult.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class FBSDKDeviceLoginManager;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract A delegate for `FBSDKDeviceLoginManager`.
|
||||||
|
*/
|
||||||
|
@protocol FBSDKDeviceLoginManagerDelegate <NSObject>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Indicates the device login flow has started. You should parse `codeInfo` to
|
||||||
|
present the code to the user to enter.
|
||||||
|
@param loginManager the login manager instance.
|
||||||
|
@param codeInfo the code info data.
|
||||||
|
*/
|
||||||
|
- (void)deviceLoginManager:(FBSDKDeviceLoginManager *)loginManager startedWithCodeInfo:(FBSDKDeviceLoginCodeInfo *)codeInfo;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Indicates the device login flow has finished.
|
||||||
|
@param loginManager the login manager instance.
|
||||||
|
@param result the results of the login flow.
|
||||||
|
@param error the error, if available.
|
||||||
|
@discussion The flow can be finished if the user completed the flow, cancelled, or if the code has expired.
|
||||||
|
*/
|
||||||
|
- (void)deviceLoginManager:(FBSDKDeviceLoginManager *)loginManager
|
||||||
|
completedWithResult:(nullable FBSDKDeviceLoginManagerResult *)result
|
||||||
|
error:(nullable NSError *)error;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Use this class to perform a device login flow.
|
||||||
|
@discussion The device login flow starts by requesting a code from the device login API.
|
||||||
|
This class informs the delegate when this code is received. You should then present the
|
||||||
|
code to the user to enter. In the meantime, this class polls the device login API
|
||||||
|
periodically and informs the delegate of the results.
|
||||||
|
|
||||||
|
See [Facebook Device Login](https://developers.facebook.com/docs/facebook-login/for-devices).
|
||||||
|
*/
|
||||||
|
@interface FBSDKDeviceLoginManager : NSObject <NSNetServiceDelegate>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Initializes a new instance.
|
||||||
|
@param permissions permissions to request.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithPermissions:(nullable NSArray<NSString *> *)permissions
|
||||||
|
enableSmartLogin:(BOOL)enableSmartLogin
|
||||||
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the delegate.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) id<FBSDKDeviceLoginManagerDelegate> delegate;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the requested permissions.
|
||||||
|
*/
|
||||||
|
@property (nullable, nonatomic, copy, readonly) NSArray<NSString *> *permissions;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract the optional URL to redirect the user to after they complete the login.
|
||||||
|
@discussion the URL must be configured in your App Settings -> Advanced -> OAuth Redirect URIs
|
||||||
|
*/
|
||||||
|
@property (nullable, nonatomic, copy) NSURL *redirectURL;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Starts the device login flow
|
||||||
|
@discussion This instance will retain self until the flow is finished or cancelled.
|
||||||
|
*/
|
||||||
|
- (void)start;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Attempts to cancel the device login flow.
|
||||||
|
*/
|
||||||
|
- (void)cancel;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
235
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManager.m
generated
Normal file
235
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManager.m
generated
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKDeviceLoginManager.h"
|
||||||
|
#import "FBSDKDeviceLoginManagerResult+Internal.h"
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKConstants.h>
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKDeviceLoginCodeInfo+Internal.h"
|
||||||
|
#import "FBSDKLoginConstants.h"
|
||||||
|
|
||||||
|
static NSMutableArray<FBSDKDeviceLoginManager *> *g_loginManagerInstances;
|
||||||
|
|
||||||
|
@implementation FBSDKDeviceLoginManager {
|
||||||
|
FBSDKDeviceLoginCodeInfo *_codeInfo;
|
||||||
|
BOOL _isCancelled;
|
||||||
|
NSNetService * _loginAdvertisementService;
|
||||||
|
BOOL _isSmartLoginEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if (self == [FBSDKDeviceLoginManager class]) {
|
||||||
|
g_loginManagerInstances = [NSMutableArray array];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithPermissions:(NSArray<NSString *> *)permissions enableSmartLogin:(BOOL)enableSmartLogin
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_permissions = [permissions copy];
|
||||||
|
_isSmartLoginEnabled = enableSmartLogin;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)start
|
||||||
|
{
|
||||||
|
[FBSDKInternalUtility validateAppID];
|
||||||
|
[g_loginManagerInstances addObject:self];
|
||||||
|
|
||||||
|
NSDictionary *parameters = @{
|
||||||
|
@"scope": [self.permissions componentsJoinedByString:@","] ?: @"",
|
||||||
|
@"redirect_uri": self.redirectURL.absoluteString ?: @"",
|
||||||
|
FBSDK_DEVICE_INFO_PARAM: [FBSDKDeviceRequestsHelper getDeviceInfo],
|
||||||
|
};
|
||||||
|
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"device/login"
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:[FBSDKInternalUtility validateRequiredClientAccessToken]
|
||||||
|
HTTPMethod:@"POST"
|
||||||
|
flags:FBSDKGraphRequestFlagNone];
|
||||||
|
[request setGraphErrorRecoveryDisabled:YES];
|
||||||
|
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
if (error) {
|
||||||
|
[self _processError:error];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->_codeInfo = [[FBSDKDeviceLoginCodeInfo alloc]
|
||||||
|
initWithIdentifier:result[@"code"]
|
||||||
|
loginCode:result[@"user_code"]
|
||||||
|
verificationURL:[NSURL URLWithString:result[@"verification_uri"]]
|
||||||
|
expirationDate:[[NSDate date] dateByAddingTimeInterval:[result[@"expires_in"] doubleValue]]
|
||||||
|
pollingInterval:[result[@"interval"] integerValue]];
|
||||||
|
|
||||||
|
if (self->_isSmartLoginEnabled) {
|
||||||
|
[FBSDKDeviceRequestsHelper startAdvertisementService:self->_codeInfo.loginCode
|
||||||
|
withDelegate:self
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.delegate deviceLoginManager:self startedWithCodeInfo:self->_codeInfo];
|
||||||
|
[self _schedulePoll:self->_codeInfo.pollingInterval];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cancel
|
||||||
|
{
|
||||||
|
[FBSDKDeviceRequestsHelper cleanUpAdvertisementService:self];
|
||||||
|
_isCancelled = YES;
|
||||||
|
[g_loginManagerInstances removeObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private impl
|
||||||
|
|
||||||
|
- (void)_notifyError:(NSError *)error
|
||||||
|
{
|
||||||
|
[FBSDKDeviceRequestsHelper cleanUpAdvertisementService:self];
|
||||||
|
[self.delegate deviceLoginManager:self
|
||||||
|
completedWithResult:nil
|
||||||
|
error:error];
|
||||||
|
[g_loginManagerInstances removeObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_notifyToken:(NSString *)tokenString
|
||||||
|
{
|
||||||
|
[FBSDKDeviceRequestsHelper cleanUpAdvertisementService:self];
|
||||||
|
void(^completeWithResult)(FBSDKDeviceLoginManagerResult *) = ^(FBSDKDeviceLoginManagerResult *result) {
|
||||||
|
[self.delegate deviceLoginManager:self completedWithResult:result error:nil];
|
||||||
|
[g_loginManagerInstances removeObject:self];
|
||||||
|
};
|
||||||
|
|
||||||
|
if (tokenString) {
|
||||||
|
FBSDKGraphRequest *permissionsRequest =
|
||||||
|
[[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
|
||||||
|
parameters:@{@"fields": @"id,permissions"}
|
||||||
|
tokenString:tokenString
|
||||||
|
HTTPMethod:@"GET"
|
||||||
|
flags:FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||||
|
[permissionsRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id permissionRawResult, NSError *error) {
|
||||||
|
NSString *userID = permissionRawResult[@"id"];
|
||||||
|
NSDictionary *permissionResult = permissionRawResult[@"permissions"];
|
||||||
|
if (error ||
|
||||||
|
!userID ||
|
||||||
|
!permissionResult) {
|
||||||
|
#if TARGET_TV_OS
|
||||||
|
NSError *wrappedError = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKErrorTVOSUnknown
|
||||||
|
message:@"Unable to fetch permissions for token"
|
||||||
|
underlyingError:error];
|
||||||
|
#else
|
||||||
|
NSError *wrappedError = [NSError fbErrorWithDomain:FBSDKLoginErrorDomain
|
||||||
|
code:FBSDKErrorUnknown
|
||||||
|
message:@"Unable to fetch permissions for token"
|
||||||
|
underlyingError:error];
|
||||||
|
#endif
|
||||||
|
[self _notifyError:wrappedError];
|
||||||
|
} else {
|
||||||
|
NSMutableSet<NSString *> *permissions = [NSMutableSet set];
|
||||||
|
NSMutableSet<NSString *> *declinedPermissions = [NSMutableSet set];
|
||||||
|
|
||||||
|
[FBSDKInternalUtility extractPermissionsFromResponse:permissionResult
|
||||||
|
grantedPermissions:permissions
|
||||||
|
declinedPermissions:declinedPermissions];
|
||||||
|
FBSDKAccessToken *accessToken = [[FBSDKAccessToken alloc] initWithTokenString:tokenString
|
||||||
|
permissions:permissions.allObjects
|
||||||
|
declinedPermissions:declinedPermissions.allObjects
|
||||||
|
appID:[FBSDKSettings appID]
|
||||||
|
userID:userID
|
||||||
|
expirationDate:nil
|
||||||
|
refreshDate:nil
|
||||||
|
dataAccessExpirationDate:nil];
|
||||||
|
FBSDKDeviceLoginManagerResult *result = [[FBSDKDeviceLoginManagerResult alloc] initWithToken:accessToken
|
||||||
|
isCancelled:NO];
|
||||||
|
completeWithResult(result);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
_isCancelled = YES;
|
||||||
|
FBSDKDeviceLoginManagerResult *result = [[FBSDKDeviceLoginManagerResult alloc] initWithToken:nil isCancelled:YES];
|
||||||
|
completeWithResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_processError:(NSError *)error
|
||||||
|
{
|
||||||
|
FBSDKDeviceLoginError code = [error.userInfo[FBSDKGraphRequestErrorGraphErrorSubcodeKey] unsignedIntegerValue];
|
||||||
|
switch (code) {
|
||||||
|
case FBSDKDeviceLoginErrorAuthorizationPending:
|
||||||
|
[self _schedulePoll:_codeInfo.pollingInterval];
|
||||||
|
break;
|
||||||
|
case FBSDKDeviceLoginErrorCodeExpired:
|
||||||
|
case FBSDKDeviceLoginErrorAuthorizationDeclined:
|
||||||
|
[self _notifyToken:nil];
|
||||||
|
break;
|
||||||
|
case FBSDKDeviceLoginErrorExcessivePolling:
|
||||||
|
[self _schedulePoll:_codeInfo.pollingInterval * 2];
|
||||||
|
default:
|
||||||
|
[self _notifyError:error];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_schedulePoll:(NSUInteger)interval
|
||||||
|
{
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(interval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
if (self->_isCancelled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *parameters = @{ @"code": self->_codeInfo.identifier };
|
||||||
|
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"device/login_status"
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:[FBSDKInternalUtility validateRequiredClientAccessToken]
|
||||||
|
HTTPMethod:@"POST"
|
||||||
|
flags:FBSDKGraphRequestFlagNone];
|
||||||
|
[request setGraphErrorRecoveryDisabled:YES];
|
||||||
|
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
if (self->_isCancelled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
[self _processError:error];
|
||||||
|
} else {
|
||||||
|
NSString *tokenString = result[@"access_token"];
|
||||||
|
if (tokenString) {
|
||||||
|
[self _notifyToken:tokenString];
|
||||||
|
} else {
|
||||||
|
NSError *unknownError = [NSError fbErrorWithDomain:FBSDKLoginErrorDomain
|
||||||
|
code:FBSDKErrorUnknown
|
||||||
|
message:@"Device Login poll failed. No token nor error was found."];
|
||||||
|
[self _notifyError:unknownError];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)netService:(NSNetService *)sender
|
||||||
|
didNotPublish:(NSDictionary<NSString *, NSNumber *> *)errorDict
|
||||||
|
{
|
||||||
|
// Only cleanup if the publish error is from our advertising service
|
||||||
|
if ([FBSDKDeviceRequestsHelper isDelegate:self forAdvertisementService:sender])
|
||||||
|
{
|
||||||
|
[FBSDKDeviceRequestsHelper cleanUpAdvertisementService:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
50
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManagerResult.h
generated
Normal file
50
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManagerResult.h
generated
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKAccessToken.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Represents the results of the a device login flow.
|
||||||
|
@discussion This is used by `FBSDKDeviceLoginManager`.
|
||||||
|
*/
|
||||||
|
@interface FBSDKDeviceLoginManagerResult : NSObject
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract There is no public initializer.
|
||||||
|
*/
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract The token.
|
||||||
|
*/
|
||||||
|
@property (nullable, nonatomic, strong, readonly) FBSDKAccessToken *accessToken;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Indicates if the login was cancelled by the user, or if the device
|
||||||
|
login code has expired.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign, readonly, getter=isCancelled) BOOL cancelled;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
33
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManagerResult.m
generated
Normal file
33
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKDeviceLoginManagerResult.m
generated
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKDeviceLoginManagerResult+Internal.h"
|
||||||
|
|
||||||
|
@implementation FBSDKDeviceLoginManagerResult
|
||||||
|
|
||||||
|
- (instancetype)initWithToken:(FBSDKAccessToken *)token
|
||||||
|
isCancelled:(BOOL)cancelled
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_accessToken = token;
|
||||||
|
_cancelled = cancelled;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
131
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginButton.h
generated
Normal file
131
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginButton.h
generated
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKButton.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginManager.h>
|
||||||
|
|
||||||
|
#import "FBSDKTooltipView.h"
|
||||||
|
|
||||||
|
@protocol FBSDKLoginButtonDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKLoginButtonTooltipBehavior)
|
||||||
|
Indicates the desired login tooltip behavior.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKLoginButtonTooltipBehavior)
|
||||||
|
{
|
||||||
|
/** The default behavior. The tooltip will only be displayed if
|
||||||
|
the app is eligible (determined by possible server round trip) */
|
||||||
|
FBSDKLoginButtonTooltipBehaviorAutomatic = 0,
|
||||||
|
/** Force display of the tooltip (typically for UI testing) */
|
||||||
|
FBSDKLoginButtonTooltipBehaviorForceDisplay = 1,
|
||||||
|
/** Force disable. In this case you can still exert more refined
|
||||||
|
control by manually constructing a `FBSDKLoginTooltipView` instance. */
|
||||||
|
FBSDKLoginButtonTooltipBehaviorDisable = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A button that initiates a log in or log out flow upon tapping.
|
||||||
|
|
||||||
|
`FBSDKLoginButton` works with `[FBSDKAccessToken currentAccessToken]` to
|
||||||
|
determine what to display, and automatically starts authentication when tapped (i.e.,
|
||||||
|
you do not need to manually subscribe action targets).
|
||||||
|
|
||||||
|
Like `FBSDKLoginManager`, you should make sure your app delegate is connected to
|
||||||
|
`FBSDKApplicationDelegate` in order for the button's delegate to receive messages.
|
||||||
|
|
||||||
|
`FBSDKLoginButton` has a fixed height of @c 30 pixels, but you may change the width. `initWithFrame:CGRectZero`
|
||||||
|
will size the button to its minimum frame.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginButton : FBSDKButton
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default audience to use, if publish permissions are requested at login time.
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) FBSDKDefaultAudience defaultAudience;
|
||||||
|
/**
|
||||||
|
Gets or sets the delegate.
|
||||||
|
*/
|
||||||
|
@property (weak, nonatomic) IBOutlet id<FBSDKLoginButtonDelegate> delegate;
|
||||||
|
/**
|
||||||
|
Gets or sets the login behavior to use
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior;
|
||||||
|
/**
|
||||||
|
The publish permissions to request.
|
||||||
|
|
||||||
|
|
||||||
|
Use `defaultAudience` to specify the default audience to publish to.
|
||||||
|
Note this is converted to NSSet and is only
|
||||||
|
an NSArray for the convenience of literal syntax.
|
||||||
|
*/
|
||||||
|
@property (copy, nonatomic) NSArray *publishPermissions;
|
||||||
|
/**
|
||||||
|
The read permissions to request.
|
||||||
|
|
||||||
|
|
||||||
|
Note, that if read permissions are specified, then publish permissions should not be specified. This is converted to NSSet and is only
|
||||||
|
an NSArray for the convenience of literal syntax.
|
||||||
|
*/
|
||||||
|
@property (copy, nonatomic) NSArray *readPermissions;
|
||||||
|
/**
|
||||||
|
Gets or sets the desired tooltip behavior.
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) FBSDKLoginButtonTooltipBehavior tooltipBehavior;
|
||||||
|
/**
|
||||||
|
Gets or sets the desired tooltip color style.
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) FBSDKTooltipColorStyle tooltipColorStyle;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
@protocol
|
||||||
|
A delegate for `FBSDKLoginButton`
|
||||||
|
*/
|
||||||
|
@protocol FBSDKLoginButtonDelegate <NSObject>
|
||||||
|
|
||||||
|
@required
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the button was used to login.
|
||||||
|
@param loginButton the sender
|
||||||
|
@param result The results of the login
|
||||||
|
@param error The error (if any) from the login
|
||||||
|
*/
|
||||||
|
- (void)loginButton:(FBSDKLoginButton *)loginButton
|
||||||
|
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
|
||||||
|
error:(NSError *)error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the button was used to logout.
|
||||||
|
@param loginButton The button that was clicked.
|
||||||
|
*/
|
||||||
|
- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton;
|
||||||
|
|
||||||
|
@optional
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the button is about to login.
|
||||||
|
@param loginButton the sender
|
||||||
|
@return YES if the login should be allowed to proceed, NO otherwise
|
||||||
|
*/
|
||||||
|
- (BOOL) loginButtonWillLogin:(FBSDKLoginButton *)loginButton;
|
||||||
|
|
||||||
|
@end
|
||||||
333
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginButton.m
generated
Normal file
333
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginButton.m
generated
Normal file
@ -0,0 +1,333 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginButton.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLoginTooltipView.h"
|
||||||
|
|
||||||
|
static const CGFloat kFBLogoSize = 16.0;
|
||||||
|
static const CGFloat kFBLogoLeftMargin = 6.0;
|
||||||
|
static const CGFloat kButtonHeight = 28.0;
|
||||||
|
static const CGFloat kRightMargin = 8.0;
|
||||||
|
static const CGFloat kPaddingBetweenLogoTitle = 8.0;
|
||||||
|
|
||||||
|
@interface FBSDKLoginButton() <FBSDKButtonImpressionTracking>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginButton
|
||||||
|
{
|
||||||
|
BOOL _hasShownTooltipBubble;
|
||||||
|
FBSDKLoginManager *_loginManager;
|
||||||
|
NSString *_userID;
|
||||||
|
NSString *_userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
- (FBSDKDefaultAudience)defaultAudience
|
||||||
|
{
|
||||||
|
return _loginManager.defaultAudience;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setDefaultAudience:(FBSDKDefaultAudience)defaultAudience
|
||||||
|
{
|
||||||
|
_loginManager.defaultAudience = defaultAudience;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (FBSDKLoginBehavior)loginBehavior
|
||||||
|
{
|
||||||
|
return _loginManager.loginBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setLoginBehavior:(FBSDKLoginBehavior)loginBehavior
|
||||||
|
{
|
||||||
|
_loginManager.loginBehavior = loginBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIFont *)defaultFont
|
||||||
|
{
|
||||||
|
return [UIFont systemFontOfSize:13];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIColor *)backgroundColor
|
||||||
|
{
|
||||||
|
return [UIColor colorWithRed:66.0/255.0 green:103.0/255.0 blue:178.0/255.0 alpha:1.0];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - UIView
|
||||||
|
|
||||||
|
- (void)didMoveToWindow
|
||||||
|
{
|
||||||
|
[super didMoveToWindow];
|
||||||
|
|
||||||
|
if (self.window &&
|
||||||
|
((self.tooltipBehavior == FBSDKLoginButtonTooltipBehaviorForceDisplay) || !_hasShownTooltipBubble)) {
|
||||||
|
[self performSelector:@selector(_showTooltipIfNeeded) withObject:nil afterDelay:0];
|
||||||
|
_hasShownTooltipBubble = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Layout
|
||||||
|
|
||||||
|
- (CGRect)imageRectForContentRect:(CGRect)contentRect
|
||||||
|
{
|
||||||
|
CGFloat centerY = CGRectGetMidY(contentRect);
|
||||||
|
CGFloat y = centerY - (kFBLogoSize / 2.0);
|
||||||
|
return CGRectMake(kFBLogoLeftMargin, y, kFBLogoSize, kFBLogoSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGRect)titleRectForContentRect:(CGRect)contentRect
|
||||||
|
{
|
||||||
|
if (self.hidden || CGRectIsEmpty(self.bounds)) {
|
||||||
|
return CGRectZero;
|
||||||
|
}
|
||||||
|
CGRect imageRect = [self imageRectForContentRect:contentRect];
|
||||||
|
CGFloat titleX = CGRectGetMaxX(imageRect) + kPaddingBetweenLogoTitle;
|
||||||
|
CGRect titleRect = CGRectMake(titleX, 0, CGRectGetWidth(contentRect) - titleX - kRightMargin, CGRectGetHeight(contentRect));
|
||||||
|
|
||||||
|
return titleRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)layoutSubviews
|
||||||
|
{
|
||||||
|
CGSize size = self.bounds.size;
|
||||||
|
CGSize longTitleSize = [self sizeThatFits:size title:[self _longLogInTitle]];
|
||||||
|
NSString *title = (longTitleSize.width <= size.width ?
|
||||||
|
[self _longLogInTitle] :
|
||||||
|
[self _shortLogInTitle]);
|
||||||
|
if (![title isEqualToString:[self titleForState:UIControlStateNormal]]) {
|
||||||
|
[self setTitle:title forState:UIControlStateNormal];
|
||||||
|
}
|
||||||
|
|
||||||
|
[super layoutSubviews];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)sizeThatFits:(CGSize)size
|
||||||
|
{
|
||||||
|
if (self.hidden) {
|
||||||
|
return CGSizeZero;
|
||||||
|
}
|
||||||
|
UIFont *font = self.titleLabel.font;
|
||||||
|
|
||||||
|
CGSize selectedSize = FBSDKTextSize([self _logOutTitle], font, size, self.titleLabel.lineBreakMode);
|
||||||
|
CGSize normalSize = FBSDKTextSize([self _longLogInTitle], font, size, self.titleLabel.lineBreakMode);
|
||||||
|
if (normalSize.width > size.width) {
|
||||||
|
normalSize = FBSDKTextSize([self _shortLogInTitle], font, size, self.titleLabel.lineBreakMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGFloat titleWidth = MAX(normalSize.width, selectedSize.width);
|
||||||
|
CGFloat buttonWidth = kFBLogoLeftMargin + kFBLogoSize + kPaddingBetweenLogoTitle + titleWidth + kRightMargin;
|
||||||
|
return CGSizeMake(buttonWidth, kButtonHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButtonImpressionTracking
|
||||||
|
|
||||||
|
- (NSDictionary *)analyticsParameters
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingEventName
|
||||||
|
{
|
||||||
|
return FBSDKAppEventNameFBSDKLoginButtonImpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingIdentifier
|
||||||
|
{
|
||||||
|
return @"login";
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButton
|
||||||
|
|
||||||
|
- (void)configureButton
|
||||||
|
{
|
||||||
|
_loginManager = [[FBSDKLoginManager alloc] init];
|
||||||
|
|
||||||
|
NSString *logInTitle = [self _shortLogInTitle];
|
||||||
|
NSString *logOutTitle = [self _logOutTitle];
|
||||||
|
|
||||||
|
[self configureWithIcon:nil
|
||||||
|
title:logInTitle
|
||||||
|
backgroundColor:self.backgroundColor
|
||||||
|
highlightedColor:nil
|
||||||
|
selectedTitle:logOutTitle
|
||||||
|
selectedIcon:nil
|
||||||
|
selectedColor:self.backgroundColor
|
||||||
|
selectedHighlightedColor:nil];
|
||||||
|
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
|
[self addConstraint:[NSLayoutConstraint constraintWithItem:self
|
||||||
|
attribute:NSLayoutAttributeHeight
|
||||||
|
relatedBy:NSLayoutRelationEqual
|
||||||
|
toItem:nil
|
||||||
|
attribute:NSLayoutAttributeNotAnAttribute
|
||||||
|
multiplier:1
|
||||||
|
constant:28]];
|
||||||
|
[self _updateContent];
|
||||||
|
|
||||||
|
[self addTarget:self action:@selector(_buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(_accessTokenDidChangeNotification:)
|
||||||
|
name:FBSDKAccessTokenDidChangeNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_accessTokenDidChangeNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
if (notification.userInfo[FBSDKAccessTokenDidChangeUserIDKey] || notification.userInfo[FBSDKAccessTokenDidExpireKey]) {
|
||||||
|
[self _updateContent];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_buttonPressed:(id)sender
|
||||||
|
{
|
||||||
|
[self logTapEventWithEventName:FBSDKAppEventNameFBSDKLoginButtonDidTap parameters:self.analyticsParameters];
|
||||||
|
if ([FBSDKAccessToken currentAccessTokenIsActive]) {
|
||||||
|
NSString *title = nil;
|
||||||
|
|
||||||
|
if (_userName) {
|
||||||
|
NSString *localizedFormatString =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginButton.LoggedInAs", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Logged in as %@",
|
||||||
|
@"The format string for the FBSDKLoginButton label when the user is logged in");
|
||||||
|
title = [NSString localizedStringWithFormat:localizedFormatString, _userName];
|
||||||
|
} else {
|
||||||
|
NSString *localizedLoggedIn =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginButton.LoggedIn", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Logged in using Facebook",
|
||||||
|
@"The fallback string for the FBSDKLoginButton label when the user name is not available yet");
|
||||||
|
title = localizedLoggedIn;
|
||||||
|
}
|
||||||
|
NSString *cancelTitle =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginButton.CancelLogout", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Cancel",
|
||||||
|
@"The label for the FBSDKLoginButton action sheet to cancel logging out");
|
||||||
|
NSString *logOutTitle =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginButton.ConfirmLogOut", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Log Out",
|
||||||
|
@"The label for the FBSDKLoginButton action sheet to confirm logging out");
|
||||||
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
|
||||||
|
message:nil
|
||||||
|
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||||
|
alertController.popoverPresentationController.sourceView = self;
|
||||||
|
alertController.popoverPresentationController.sourceRect = self.bounds;
|
||||||
|
UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelTitle
|
||||||
|
style:UIAlertActionStyleCancel
|
||||||
|
handler:nil];
|
||||||
|
UIAlertAction *logout = [UIAlertAction actionWithTitle:logOutTitle
|
||||||
|
style:UIAlertActionStyleDestructive
|
||||||
|
handler:^(UIAlertAction * _Nonnull action) {
|
||||||
|
[self->_loginManager logOut];
|
||||||
|
[self.delegate loginButtonDidLogOut:self];
|
||||||
|
}];
|
||||||
|
[alertController addAction:cancel];
|
||||||
|
[alertController addAction:logout];
|
||||||
|
UIViewController *topMostViewController = [FBSDKInternalUtility topMostViewController];
|
||||||
|
[topMostViewController presentViewController:alertController
|
||||||
|
animated:YES
|
||||||
|
completion:nil];
|
||||||
|
} else {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(loginButtonWillLogin:)]) {
|
||||||
|
if (![self.delegate loginButtonWillLogin:self]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FBSDKLoginManagerRequestTokenHandler handler = ^(FBSDKLoginManagerLoginResult *result, NSError *error) {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(loginButton:didCompleteWithResult:error:)]) {
|
||||||
|
[self.delegate loginButton:self didCompleteWithResult:result error:error];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (self.publishPermissions.count > 0) {
|
||||||
|
[_loginManager logInWithPublishPermissions:self.publishPermissions
|
||||||
|
fromViewController:[FBSDKInternalUtility viewControllerForView:self]
|
||||||
|
handler:handler];
|
||||||
|
} else {
|
||||||
|
[_loginManager logInWithReadPermissions:self.readPermissions
|
||||||
|
fromViewController:[FBSDKInternalUtility viewControllerForView:self]
|
||||||
|
handler:handler];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_logOutTitle
|
||||||
|
{
|
||||||
|
return NSLocalizedStringWithDefaultValue(@"LoginButton.LogOut", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Log out",
|
||||||
|
@"The label for the FBSDKLoginButton when the user is currently logged in");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_longLogInTitle
|
||||||
|
{
|
||||||
|
return NSLocalizedStringWithDefaultValue(@"LoginButton.LogInContinue", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Continue with Facebook",
|
||||||
|
@"The long label for the FBSDKLoginButton when the user is currently logged out");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_shortLogInTitle
|
||||||
|
{
|
||||||
|
return NSLocalizedStringWithDefaultValue(@"LoginButton.LogIn", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Log in",
|
||||||
|
@"The short label for the FBSDKLoginButton when the user is currently logged out");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_showTooltipIfNeeded
|
||||||
|
{
|
||||||
|
if ([FBSDKAccessToken currentAccessToken] || self.tooltipBehavior == FBSDKLoginButtonTooltipBehaviorDisable) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
FBSDKLoginTooltipView *tooltipView = [[FBSDKLoginTooltipView alloc] init];
|
||||||
|
tooltipView.colorStyle = self.tooltipColorStyle;
|
||||||
|
if (self.tooltipBehavior == FBSDKLoginButtonTooltipBehaviorForceDisplay) {
|
||||||
|
tooltipView.forceDisplay = YES;
|
||||||
|
}
|
||||||
|
[tooltipView presentFromView:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_updateContent
|
||||||
|
{
|
||||||
|
BOOL accessTokenIsValid = [FBSDKAccessToken currentAccessTokenIsActive];
|
||||||
|
self.selected = accessTokenIsValid;
|
||||||
|
if (accessTokenIsValid) {
|
||||||
|
if (![[FBSDKAccessToken currentAccessToken].userID isEqualToString:_userID]) {
|
||||||
|
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=id,name"
|
||||||
|
parameters:nil
|
||||||
|
flags:FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||||
|
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
NSString *userID = [FBSDKTypeUtility stringValue:result[@"id"]];
|
||||||
|
if (!error && [[FBSDKAccessToken currentAccessToken].userID isEqualToString:userID]) {
|
||||||
|
self->_userName = [FBSDKTypeUtility stringValue:result[@"name"]];
|
||||||
|
self->_userID = userID;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
142
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginConstants.h
generated
Normal file
142
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginConstants.h
generated
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error domain for all errors from FBSDKLoginKit
|
||||||
|
|
||||||
|
Error codes from the SDK in the range 300-399 are reserved for this domain.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSErrorDomain const FBSDKLoginErrorDomain;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error domain for all errors from FBSDKLoginKit
|
||||||
|
|
||||||
|
Error codes from the SDK in the range 300-399 are reserved for this domain.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKLoginErrorDomain;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NS_ERROR_ENUM
|
||||||
|
#define NS_ERROR_ENUM(_domain, _name) \
|
||||||
|
enum _name: NSInteger _name; \
|
||||||
|
enum __attribute__((ns_error_domain(_domain))) _name: NSInteger
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKLoginError
|
||||||
|
Error codes for FBSDKLoginErrorDomain.
|
||||||
|
*/
|
||||||
|
typedef NS_ERROR_ENUM(FBSDKLoginErrorDomain, FBSDKLoginError)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
Reserved.
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorReserved = 300,
|
||||||
|
/**
|
||||||
|
The error code for unknown errors.
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorUnknown,
|
||||||
|
|
||||||
|
/**
|
||||||
|
The user's password has changed and must log in again
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorPasswordChanged,
|
||||||
|
/**
|
||||||
|
The user must log in to their account on www.facebook.com to restore access
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorUserCheckpointed,
|
||||||
|
/**
|
||||||
|
Indicates a failure to request new permissions because the user has changed.
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorUserMismatch,
|
||||||
|
/**
|
||||||
|
The user must confirm their account with Facebook before logging in
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorUnconfirmedUser,
|
||||||
|
|
||||||
|
/**
|
||||||
|
The Accounts framework failed without returning an error, indicating the
|
||||||
|
app's slider in the iOS Facebook Settings (device Settings -> Facebook -> App Name) has
|
||||||
|
been disabled.
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorSystemAccountAppDisabled,
|
||||||
|
/**
|
||||||
|
An error occurred related to Facebook system Account store
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorSystemAccountUnavailable,
|
||||||
|
/**
|
||||||
|
The login response was missing a valid challenge string.
|
||||||
|
*/
|
||||||
|
FBSDKLoginErrorBadChallengeString,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKDeviceLoginError
|
||||||
|
Error codes for FBSDKDeviceLoginErrorDomain.
|
||||||
|
*/
|
||||||
|
typedef NS_ERROR_ENUM(FBSDKLoginErrorDomain, FBSDKDeviceLoginError) {
|
||||||
|
/**
|
||||||
|
Your device is polling too frequently.
|
||||||
|
*/
|
||||||
|
FBSDKDeviceLoginErrorExcessivePolling = 1349172,
|
||||||
|
/**
|
||||||
|
User has declined to authorize your application.
|
||||||
|
*/
|
||||||
|
FBSDKDeviceLoginErrorAuthorizationDeclined = 1349173,
|
||||||
|
/**
|
||||||
|
User has not yet authorized your application. Continue polling.
|
||||||
|
*/
|
||||||
|
FBSDKDeviceLoginErrorAuthorizationPending = 1349174,
|
||||||
|
/**
|
||||||
|
The code you entered has expired.
|
||||||
|
*/
|
||||||
|
FBSDKDeviceLoginErrorCodeExpired = 1349152
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deprecated
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSInteger, FBSDKLoginErrorCode)
|
||||||
|
{
|
||||||
|
FBSDKLoginReservedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorReserved instead") = FBSDKLoginErrorReserved,
|
||||||
|
FBSDKLoginUnknownErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorUnknown instead"),
|
||||||
|
FBSDKLoginPasswordChangedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorPasswordChanged instead"),
|
||||||
|
FBSDKLoginUserCheckpointedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorUserCheckpointed instead"),
|
||||||
|
FBSDKLoginUserMismatchErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorUserMismatch instead"),
|
||||||
|
FBSDKLoginUnconfirmedUserErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorUnconfirmedUser instead"),
|
||||||
|
FBSDKLoginSystemAccountAppDisabledErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorSystemAccountAppDisabled instead"),
|
||||||
|
FBSDKLoginSystemAccountUnavailableErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorSystemAccountUnavailable instead"),
|
||||||
|
FBSDKLoginBadChallengeString DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginErrorBadChallengeString instead"),
|
||||||
|
} DEPRECATED_MSG_ATTRIBUTE("use FBSDKLoginError instead");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deprecated
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKDeviceLoginErrorSubcode) {
|
||||||
|
FBSDKDeviceLoginExcessivePollingErrorSubcode DEPRECATED_MSG_ATTRIBUTE("use FBSDKDeviceLoginErrorExcessivePolling instead") = FBSDKDeviceLoginErrorExcessivePolling,
|
||||||
|
FBSDKDeviceLoginAuthorizationDeclinedErrorSubcode DEPRECATED_MSG_ATTRIBUTE("use FBSDKDeviceLoginErrorAuthorizationDeclined instead") = FBSDKDeviceLoginErrorAuthorizationDeclined,
|
||||||
|
FBSDKDeviceLoginAuthorizationPendingErrorSubcode DEPRECATED_MSG_ATTRIBUTE("use FBSDKDeviceLoginErrorAuthorizationPending instead") = FBSDKDeviceLoginErrorAuthorizationPending,
|
||||||
|
FBSDKDeviceLoginCodeExpiredErrorSubcode DEPRECATED_MSG_ATTRIBUTE("use FBSDKDeviceLoginErrorCodeExpired instead") = FBSDKDeviceLoginErrorCodeExpired
|
||||||
|
} DEPRECATED_MSG_ATTRIBUTE("use FBSDKDeviceLoginError instead");
|
||||||
29
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginConstants.m
generated
Normal file
29
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginConstants.m
generated
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginConstants.h"
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||||
|
|
||||||
|
NSErrorDomain const FBSDKLoginErrorDomain = @"com.facebook.sdk.login";
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NSString *const FBSDKLoginErrorDomain = @"com.facebook.sdk.login";
|
||||||
|
|
||||||
|
#endif
|
||||||
31
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit.h
generated
Normal file
31
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit.h
generated
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKDeviceLoginManager.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKDeviceLoginManagerResult.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginConstants.h>
|
||||||
|
|
||||||
|
#if !TARGET_TV_OS
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginButton.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginManager.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginManagerLoginResult.h>
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginTooltipView.h>
|
||||||
|
#endif
|
||||||
227
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h
generated
Normal file
227
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h
generated
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Accounts/Accounts.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@class FBSDKLoginManagerLoginResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Describes the call back to the FBSDKLoginManager
|
||||||
|
@param result the result of the authorization
|
||||||
|
@param error the authorization error, if any.
|
||||||
|
*/
|
||||||
|
typedef void (^FBSDKLoginManagerRequestTokenHandler)(FBSDKLoginManagerLoginResult *result, NSError *error);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKDefaultAudience enum
|
||||||
|
|
||||||
|
Passed to open to indicate which default audience to use for sessions that post data to Facebook.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Certain operations such as publishing a status or publishing a photo require an audience. When the user
|
||||||
|
grants an application permission to perform a publish operation, a default audience is selected as the
|
||||||
|
publication ceiling for the application. This enumerated value allows the application to select which
|
||||||
|
audience to ask the user to grant publish permission for.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKDefaultAudience)
|
||||||
|
{
|
||||||
|
/** Indicates that the user's friends are able to see posts made by the application */
|
||||||
|
FBSDKDefaultAudienceFriends = 0,
|
||||||
|
/** Indicates that only the user is able to see posts made by the application */
|
||||||
|
FBSDKDefaultAudienceOnlyMe,
|
||||||
|
/** Indicates that all Facebook users are able to see posts made by the application */
|
||||||
|
FBSDKDefaultAudienceEveryone,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKLoginBehavior enum
|
||||||
|
|
||||||
|
Passed to the \c FBSDKLoginManager to indicate how Facebook Login should be attempted.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Facebook Login authorizes the application to act on behalf of the user, using the user's
|
||||||
|
Facebook account. Usually a Facebook Login will rely on an account maintained outside of
|
||||||
|
the application, by the native Facebook application, the browser, or perhaps the device
|
||||||
|
itself. This avoids the need for a user to enter their username and password directly, and
|
||||||
|
provides the most secure and lowest friction way for a user to authorize the application to
|
||||||
|
interact with Facebook.
|
||||||
|
|
||||||
|
The \c FBSDKLoginBehavior enum specifies which log-in methods may be used. The SDK
|
||||||
|
will determine the best behavior based on the current device (such as iOS version).
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
This is the default behavior, and indicates logging in through the native
|
||||||
|
Facebook app may be used. The SDK may still use Safari instead.
|
||||||
|
*/
|
||||||
|
FBSDKLoginBehaviorNative = 0,
|
||||||
|
/**
|
||||||
|
Attempts log in through the Safari or SFSafariViewController, if available.
|
||||||
|
*/
|
||||||
|
FBSDKLoginBehaviorBrowser,
|
||||||
|
/**
|
||||||
|
Attempts log in through the Facebook account currently signed in through
|
||||||
|
the device Settings.
|
||||||
|
@note If the account is not available to the app (either not configured by user or
|
||||||
|
as determined by the SDK) this behavior falls back to \c FBSDKLoginBehaviorNative.
|
||||||
|
*/
|
||||||
|
FBSDKLoginBehaviorSystemAccount,
|
||||||
|
/**
|
||||||
|
Attempts log in through a modal \c UIWebView pop up
|
||||||
|
|
||||||
|
@note This behavior is only available to certain types of apps. Please check the Facebook
|
||||||
|
Platform Policy to verify your app meets the restrictions.
|
||||||
|
*/
|
||||||
|
FBSDKLoginBehaviorWeb,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
`FBSDKLoginManager` provides methods for logging the user in and out.
|
||||||
|
|
||||||
|
`FBSDKLoginManager` works directly with `[FBSDKAccessToken currentAccessToken]` and
|
||||||
|
sets the "currentAccessToken" upon successful authorizations (or sets `nil` in case of `logOut`).
|
||||||
|
|
||||||
|
You should check `[FBSDKAccessToken currentAccessToken]` before calling logIn* to see if there is
|
||||||
|
a cached token available (typically in your viewDidLoad).
|
||||||
|
|
||||||
|
If you are managing your own token instances outside of "currentAccessToken", you will need to set
|
||||||
|
"currentAccessToken" before calling logIn* to authorize further permissions on your tokens.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginManager : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
Auth type
|
||||||
|
*/
|
||||||
|
@property (strong, nonatomic) NSString *authType;
|
||||||
|
/**
|
||||||
|
the default audience.
|
||||||
|
|
||||||
|
you should set this if you intend to ask for publish permissions.
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) FBSDKDefaultAudience defaultAudience;
|
||||||
|
|
||||||
|
/**
|
||||||
|
the login behavior
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning use logInWithReadPermissions:fromViewController:handler: instead
|
||||||
|
*/
|
||||||
|
- (void)logInWithReadPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("use logInWithReadPermissions:fromViewController:handler: instead");
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning use logInWithPublishPermissions:fromViewController:handler: instead
|
||||||
|
*/
|
||||||
|
- (void)logInWithPublishPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("use logInWithPublishPermissions:fromViewController:handler: instead");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs the user in or authorizes additional permissions.
|
||||||
|
@param permissions the optional array of permissions. Note this is converted to NSSet and is only
|
||||||
|
an NSArray for the convenience of literal syntax.
|
||||||
|
@param fromViewController the view controller to present from. If nil, the topmost view controller will be
|
||||||
|
automatically determined as best as possible.
|
||||||
|
@param handler the callback.
|
||||||
|
|
||||||
|
Use this method when asking for read permissions. You should only ask for permissions when they
|
||||||
|
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also
|
||||||
|
provide more information to the user if they decline permissions.
|
||||||
|
|
||||||
|
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]`
|
||||||
|
already contains the permissions you need before asking to reduce unnecessary app switching. For example,
|
||||||
|
you could make that check at viewDidLoad.
|
||||||
|
You can only do one login call at a time. Calling a login method before the completion handler is called
|
||||||
|
on a previous login will return an error.
|
||||||
|
*/
|
||||||
|
- (void)logInWithReadPermissions:(NSArray *)permissions
|
||||||
|
fromViewController:(UIViewController *)fromViewController
|
||||||
|
handler:(FBSDKLoginManagerRequestTokenHandler)handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs the user in or authorizes additional permissions.
|
||||||
|
@param permissions the optional array of permissions. Note this is converted to NSSet and is only
|
||||||
|
an NSArray for the convenience of literal syntax.
|
||||||
|
@param fromViewController the view controller to present from. If nil, the topmost view controller will be
|
||||||
|
automatically determined as best as possible.
|
||||||
|
@param handler the callback.
|
||||||
|
|
||||||
|
Use this method when asking for publish permissions. You should only ask for permissions when they
|
||||||
|
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also
|
||||||
|
provide more information to the user if they decline permissions.
|
||||||
|
|
||||||
|
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]`
|
||||||
|
already contains the permissions you need before asking to reduce unnecessary app switching. For example,
|
||||||
|
you could make that check at viewDidLoad.
|
||||||
|
You can only do one login call at a time. Calling a login method before the completion handler is called
|
||||||
|
on a previous login will return an error.
|
||||||
|
*/
|
||||||
|
- (void)logInWithPublishPermissions:(NSArray *)permissions
|
||||||
|
fromViewController:(UIViewController *)fromViewController
|
||||||
|
handler:(FBSDKLoginManagerRequestTokenHandler)handler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Requests user's permission to reathorize application's data access, after it has expired due to inactivity.
|
||||||
|
@param fromViewController the view controller to present from. If nil, the topmost view controller will be
|
||||||
|
automatically determined as best as possible.
|
||||||
|
@param handler the callback.
|
||||||
|
Use this method when you need to reathorize your app's access to user data via Graph API, after such an access has expired.
|
||||||
|
You should provide as much context to the user as possible as to why you need to reauthorize the access, the scope of
|
||||||
|
access being reathorized, and what added value your app provides when the access is reathorized.
|
||||||
|
You can inspect the result.declinedPermissions to also provide more information to the user if they decline permissions.
|
||||||
|
This method will present UI the user. You typically should call this if `[FBSDKAccessToken isDataAccessExpired]` returns true.
|
||||||
|
*/
|
||||||
|
- (void)reauthorizeDataAccess:(UIViewController *)fromViewController
|
||||||
|
handler:(FBSDKLoginManagerRequestTokenHandler)handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Logs the user out
|
||||||
|
|
||||||
|
This calls [FBSDKAccessToken setCurrentAccessToken:nil] and [FBSDKProfile setCurrentProfile:nil].
|
||||||
|
*/
|
||||||
|
- (void)logOut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@method
|
||||||
|
|
||||||
|
Issues an asynchronous renewCredentialsForAccount call to the device's Facebook account store.
|
||||||
|
|
||||||
|
@param handler The completion handler to call when the renewal is completed. This can be invoked on an arbitrary thread.
|
||||||
|
|
||||||
|
|
||||||
|
This can be used to explicitly renew account credentials and is provided as a convenience wrapper around
|
||||||
|
`[ACAccountStore renewCredentialsForAccount:completion]`. Note the method will not issue the renewal call if the the
|
||||||
|
Facebook account has not been set on the device, or if access had not been granted to the account (though the handler
|
||||||
|
wil receive an error).
|
||||||
|
|
||||||
|
If the `[FBSDKAccessToken currentAccessToken]` was from the account store, a succesful renewal will also set
|
||||||
|
a new "currentAccessToken".
|
||||||
|
*/
|
||||||
|
+ (void)renewSystemCredentials:(void (^)(ACAccountCredentialRenewResult result, NSError *error))handler;
|
||||||
|
|
||||||
|
@end
|
||||||
881
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.m
generated
Normal file
881
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.m
generated
Normal file
@ -0,0 +1,881 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginManager+Internal.h"
|
||||||
|
#import "FBSDKLoginManagerLoginResult+Internal.h"
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKAccessToken.h>
|
||||||
|
#import <FBSDKCoreKit/FBSDKSettings.h>
|
||||||
|
|
||||||
|
#import "_FBSDKLoginRecoveryAttempter.h"
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLoginCompletion.h"
|
||||||
|
#import "FBSDKLoginConstants.h"
|
||||||
|
#import "FBSDKLoginError.h"
|
||||||
|
#import "FBSDKLoginManagerLogger.h"
|
||||||
|
#import "FBSDKLoginUtility.h"
|
||||||
|
|
||||||
|
static int const FBClientStateChallengeLength = 20;
|
||||||
|
static NSString *const FBSDKExpectedChallengeKey = @"expected_login_challenge";
|
||||||
|
static NSString *const FBSDKOauthPath = @"/dialog/oauth";
|
||||||
|
static NSString *const SFVCCanceledLogin = @"com.apple.SafariServices.Authentication";
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSInteger, FBSDKLoginManagerState) {
|
||||||
|
FBSDKLoginManagerStateIdle,
|
||||||
|
// We received a call to start login.
|
||||||
|
FBSDKLoginManagerStateStart,
|
||||||
|
// We're calling out to the Facebook app or Safari to perform a log in
|
||||||
|
FBSDKLoginManagerStatePerformingLogin,
|
||||||
|
};
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManager
|
||||||
|
{
|
||||||
|
FBSDKLoginManagerRequestTokenHandler _handler;
|
||||||
|
FBSDKLoginManagerLogger *_logger;
|
||||||
|
FBSDKLoginManagerState _state;
|
||||||
|
FBSDKKeychainStore *_keychainStore;
|
||||||
|
BOOL _usedSFAuthSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if (self == [FBSDKLoginManager class]) {
|
||||||
|
[_FBSDKLoginRecoveryAttempter class];
|
||||||
|
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:NULL];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
self.authType = @"rerequest";
|
||||||
|
NSString *keyChainServiceIdentifier = [NSString stringWithFormat:@"com.facebook.sdk.loginmanager.%@", [NSBundle mainBundle].bundleIdentifier];
|
||||||
|
_keychainStore = [[FBSDKKeychainStore alloc] initWithService:keyChainServiceIdentifier accessGroup:nil];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logInWithReadPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
[self logInWithReadPermissions:permissions
|
||||||
|
fromViewController:nil
|
||||||
|
handler:handler];
|
||||||
|
}
|
||||||
|
- (void)logInWithReadPermissions:(NSArray *)permissions
|
||||||
|
fromViewController:(UIViewController *)fromViewController
|
||||||
|
handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
if (![self validateLoginStartState]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self assertPermissions:permissions];
|
||||||
|
NSSet *permissionSet = [NSSet setWithArray:permissions];
|
||||||
|
if (![FBSDKInternalUtility areAllPermissionsReadPermissions:permissionSet]) {
|
||||||
|
[self raiseLoginException:[NSException exceptionWithName:NSInvalidArgumentException
|
||||||
|
reason:@"Publish or manage permissions are not permitted to be requested with read permissions."
|
||||||
|
userInfo:nil]];
|
||||||
|
}
|
||||||
|
self.fromViewController = fromViewController;
|
||||||
|
[self logInWithPermissions:permissionSet handler:handler];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logInWithPublishPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
[self logInWithPublishPermissions:permissions
|
||||||
|
fromViewController:nil
|
||||||
|
handler:handler];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logInWithPublishPermissions:(NSArray *)permissions
|
||||||
|
fromViewController:(UIViewController *)fromViewController
|
||||||
|
handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
if (![self validateLoginStartState]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self assertPermissions:permissions];
|
||||||
|
NSSet *permissionSet = [NSSet setWithArray:permissions];
|
||||||
|
if (![FBSDKInternalUtility areAllPermissionsPublishPermissions:permissionSet]) {
|
||||||
|
[self raiseLoginException:[NSException exceptionWithName:NSInvalidArgumentException
|
||||||
|
reason:@"Read permissions are not permitted to be requested with publish or manage permissions."
|
||||||
|
userInfo:nil]];
|
||||||
|
}
|
||||||
|
self.fromViewController = fromViewController;
|
||||||
|
[self logInWithPermissions:permissionSet handler:handler];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reauthorizeDataAccess:(UIViewController *)fromViewController handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
if (![self validateLoginStartState]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.fromViewController = fromViewController;
|
||||||
|
[self reauthorizeDataAccess:handler];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)logOut
|
||||||
|
{
|
||||||
|
[FBSDKAccessToken setCurrentAccessToken:nil];
|
||||||
|
[FBSDKProfile setCurrentProfile:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)renewSystemCredentials:(void (^)(ACAccountCredentialRenewResult result, NSError *error))handler
|
||||||
|
{
|
||||||
|
FBSDKSystemAccountStoreAdapter *adapter = [FBSDKSystemAccountStoreAdapter sharedInstance];
|
||||||
|
|
||||||
|
if (!adapter.accountType) {
|
||||||
|
handler(ACAccountCredentialRenewResultFailed, [NSError fbErrorForFailedLoginWithCode:FBSDKLoginErrorSystemAccountUnavailable]);
|
||||||
|
} else if (!adapter.accountType.accessGranted) {
|
||||||
|
handler(ACAccountCredentialRenewResultFailed, [NSError fbErrorForFailedLoginWithCode:FBSDKLoginErrorSystemAccountAppDisabled]);
|
||||||
|
} else {
|
||||||
|
[[FBSDKSystemAccountStoreAdapter sharedInstance] renewSystemAuthorization:handler];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
- (void)raiseLoginException:(NSException *)exception
|
||||||
|
{
|
||||||
|
_state = FBSDKLoginManagerStateIdle;
|
||||||
|
[exception raise];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)handleImplicitCancelOfLogIn
|
||||||
|
{
|
||||||
|
FBSDKLoginManagerLoginResult *result = [[FBSDKLoginManagerLoginResult alloc] initWithToken:nil
|
||||||
|
isCancelled:YES
|
||||||
|
grantedPermissions:nil
|
||||||
|
declinedPermissions:nil];
|
||||||
|
[result addLoggingExtra:@YES forKey:@"implicit_cancel"];
|
||||||
|
[self invokeHandler:result error:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateLoginStartState
|
||||||
|
{
|
||||||
|
switch (_state) {
|
||||||
|
case FBSDKLoginManagerStateStart: {
|
||||||
|
if (self->_usedSFAuthSession) {
|
||||||
|
// Using SFAuthenticationSession makes an interestitial dialog that blocks the app, but in certain situations such as
|
||||||
|
// screen lock it can be dismissed and have the control returned to the app without invoking the completionHandler.
|
||||||
|
// In this case, the viewcontroller has the control back and tried to reinvoke the login. This is acceptable behavior
|
||||||
|
// and we should pop up the dialog again
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *errorStr = @"** WARNING: You are trying to start a login while a previous login has not finished yet."
|
||||||
|
"This is unsupported behavior. You should wait until the previous login handler gets called to start a new login.";
|
||||||
|
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||||
|
formatString:@"%@", errorStr];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
case FBSDKLoginManagerStatePerformingLogin:{
|
||||||
|
[self handleImplicitCancelOfLogIn];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
case FBSDKLoginManagerStateIdle:
|
||||||
|
_state = FBSDKLoginManagerStateStart;
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isPerformingLogin
|
||||||
|
{
|
||||||
|
return _state == FBSDKLoginManagerStatePerformingLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)assertPermissions:(NSArray *)permissions
|
||||||
|
{
|
||||||
|
for (NSString *permission in permissions) {
|
||||||
|
if (![permission isKindOfClass:[NSString class]]) {
|
||||||
|
[self raiseLoginException:[NSException exceptionWithName:NSInvalidArgumentException
|
||||||
|
reason:@"Permissions must be string values."
|
||||||
|
userInfo:nil]];
|
||||||
|
}
|
||||||
|
if ([permission rangeOfString:@","].location != NSNotFound) {
|
||||||
|
[self raiseLoginException:[NSException exceptionWithName:NSInvalidArgumentException
|
||||||
|
reason:@"Permissions should each be specified in separate string values in the array."
|
||||||
|
userInfo:nil]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)completeAuthentication:(FBSDKLoginCompletionParameters *)parameters expectChallenge:(BOOL)expectChallenge
|
||||||
|
{
|
||||||
|
NSSet *recentlyGrantedPermissions = nil;
|
||||||
|
NSSet *recentlyDeclinedPermissions = nil;
|
||||||
|
FBSDKLoginManagerLoginResult *result = nil;
|
||||||
|
NSError *error = parameters.error;
|
||||||
|
|
||||||
|
NSString *tokenString = parameters.accessTokenString;
|
||||||
|
BOOL cancelled = (tokenString == nil);
|
||||||
|
|
||||||
|
BOOL challengePassed = YES;
|
||||||
|
if (expectChallenge) {
|
||||||
|
// Perform this check early so we be sure to clear expected challenge in all cases.
|
||||||
|
NSString *challengeReceived = parameters.challenge;
|
||||||
|
NSString *challengeExpected = [[self loadExpectedChallenge] stringByReplacingOccurrencesOfString:@"+" withString:@" "];
|
||||||
|
if (![challengeExpected isEqualToString:challengeReceived]) {
|
||||||
|
challengePassed = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't overwrite an existing error, if any.
|
||||||
|
if (!error && !cancelled && !challengePassed) {
|
||||||
|
error = [NSError fbErrorForFailedLoginWithCode:FBSDKLoginErrorBadChallengeString];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self storeExpectedChallenge:nil];
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
if (!cancelled) {
|
||||||
|
NSSet *grantedPermissions = parameters.permissions;
|
||||||
|
NSSet *declinedPermissions = parameters.declinedPermissions;
|
||||||
|
|
||||||
|
[self determineRecentlyGrantedPermissions:&recentlyGrantedPermissions
|
||||||
|
recentlyDeclinedPermissions:&recentlyDeclinedPermissions
|
||||||
|
forGrantedPermission:grantedPermissions
|
||||||
|
declinedPermissions:declinedPermissions];
|
||||||
|
|
||||||
|
if (recentlyGrantedPermissions.count > 0) {
|
||||||
|
FBSDKAccessToken *token = [[FBSDKAccessToken alloc] initWithTokenString:tokenString
|
||||||
|
permissions:grantedPermissions.allObjects
|
||||||
|
declinedPermissions:declinedPermissions.allObjects
|
||||||
|
appID:parameters.appID
|
||||||
|
userID:parameters.userID
|
||||||
|
expirationDate:parameters.expirationDate
|
||||||
|
refreshDate:[NSDate date]
|
||||||
|
dataAccessExpirationDate:parameters.dataAccessExpirationDate];
|
||||||
|
result = [[FBSDKLoginManagerLoginResult alloc] initWithToken:token
|
||||||
|
isCancelled:NO
|
||||||
|
grantedPermissions:recentlyGrantedPermissions
|
||||||
|
declinedPermissions:recentlyDeclinedPermissions];
|
||||||
|
|
||||||
|
if ([FBSDKAccessToken currentAccessToken]) {
|
||||||
|
[self validateReauthentication:[FBSDKAccessToken currentAccessToken] withResult:result];
|
||||||
|
// in a reauth, short circuit and let the login handler be called when the validation finishes.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancelled || recentlyGrantedPermissions.count == 0) {
|
||||||
|
NSSet *declinedPermissions = nil;
|
||||||
|
if ([FBSDKAccessToken currentAccessToken] != nil) {
|
||||||
|
if (parameters.isSystemAccount) {
|
||||||
|
// If a System Account reauthorization was cancelled by the user tapping Don't Allow
|
||||||
|
// then add the declined permissions to the login result. The Accounts framework
|
||||||
|
// doesn't register the decline with Facebook, which is why we don't update the
|
||||||
|
// access token.
|
||||||
|
declinedPermissions = parameters.declinedPermissions;
|
||||||
|
} else {
|
||||||
|
// Always include the list of declined permissions from this login request
|
||||||
|
// if an access token is already cached by the SDK
|
||||||
|
declinedPermissions = recentlyDeclinedPermissions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = [[FBSDKLoginManagerLoginResult alloc] initWithToken:nil
|
||||||
|
isCancelled:cancelled
|
||||||
|
grantedPermissions:nil
|
||||||
|
declinedPermissions:declinedPermissions];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.token) {
|
||||||
|
[FBSDKAccessToken setCurrentAccessToken:result.token];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self invokeHandler:result error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)determineRecentlyGrantedPermissions:(NSSet **)recentlyGrantedPermissionsRef
|
||||||
|
recentlyDeclinedPermissions:(NSSet **)recentlyDeclinedPermissionsRef
|
||||||
|
forGrantedPermission:(NSSet *)grantedPermissions
|
||||||
|
declinedPermissions:(NSSet *)declinedPermissions
|
||||||
|
{
|
||||||
|
NSMutableSet *recentlyGrantedPermissions = [grantedPermissions mutableCopy];
|
||||||
|
NSSet *previouslyGrantedPermissions = ([FBSDKAccessToken currentAccessToken] ?
|
||||||
|
[FBSDKAccessToken currentAccessToken].permissions :
|
||||||
|
nil);
|
||||||
|
if (previouslyGrantedPermissions.count > 0) {
|
||||||
|
// If there were no requested permissions for this auth - treat all permissions as granted.
|
||||||
|
// Otherwise this is a reauth, so recentlyGranted should be a subset of what was requested.
|
||||||
|
if (_requestedPermissions.count != 0) {
|
||||||
|
[recentlyGrantedPermissions intersectSet:_requestedPermissions];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableSet *recentlyDeclinedPermissions = [_requestedPermissions mutableCopy];
|
||||||
|
[recentlyDeclinedPermissions intersectSet:declinedPermissions];
|
||||||
|
|
||||||
|
if (recentlyGrantedPermissionsRef != NULL) {
|
||||||
|
*recentlyGrantedPermissionsRef = [recentlyGrantedPermissions copy];
|
||||||
|
}
|
||||||
|
if (recentlyDeclinedPermissionsRef != NULL) {
|
||||||
|
*recentlyDeclinedPermissionsRef = [recentlyDeclinedPermissions copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)invokeHandler:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
|
||||||
|
{
|
||||||
|
[_logger endLoginWithResult:result error:error];
|
||||||
|
[_logger endSession];
|
||||||
|
_logger = nil;
|
||||||
|
_state = FBSDKLoginManagerStateIdle;
|
||||||
|
|
||||||
|
if (_handler) {
|
||||||
|
FBSDKLoginManagerRequestTokenHandler handler = _handler;
|
||||||
|
_handler(result, error);
|
||||||
|
if (handler == _handler) {
|
||||||
|
_handler = nil;
|
||||||
|
} else {
|
||||||
|
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||||
|
formatString:@"** WARNING: You are requesting permissions inside the completion block of an existing login."
|
||||||
|
"This is unsupported behavior. You should request additional permissions only when they are needed, such as requesting for publish_actions"
|
||||||
|
"when the user performs a sharing action."];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)loadExpectedChallenge
|
||||||
|
{
|
||||||
|
return [_keychainStore stringForKey:FBSDKExpectedChallengeKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)logInParametersWithPermissions:(NSSet *)permissions serverConfiguration:(FBSDKServerConfiguration *)serverConfiguration
|
||||||
|
{
|
||||||
|
[FBSDKInternalUtility validateURLSchemes];
|
||||||
|
|
||||||
|
NSMutableDictionary *loginParams = [NSMutableDictionary dictionary];
|
||||||
|
loginParams[@"client_id"] = [FBSDKSettings appID];
|
||||||
|
loginParams[@"response_type"] = @"token,signed_request";
|
||||||
|
loginParams[@"redirect_uri"] = @"fbconnect://success";
|
||||||
|
loginParams[@"display"] = @"touch";
|
||||||
|
loginParams[@"sdk"] = @"ios";
|
||||||
|
loginParams[@"return_scopes"] = @"true";
|
||||||
|
loginParams[@"sdk_version"] = FBSDK_VERSION_STRING;
|
||||||
|
loginParams[@"fbapp_pres"] = @([FBSDKInternalUtility isFacebookAppInstalled]);
|
||||||
|
loginParams[@"auth_type"] = self.authType;
|
||||||
|
loginParams[@"logging_token"] = serverConfiguration.loggingToken;
|
||||||
|
|
||||||
|
[FBSDKInternalUtility dictionary:loginParams setObject:[FBSDKSettings appURLSchemeSuffix] forKey:@"local_client_id"];
|
||||||
|
[FBSDKInternalUtility dictionary:loginParams setObject:[FBSDKLoginUtility stringForAudience:self.defaultAudience] forKey:@"default_audience"];
|
||||||
|
[FBSDKInternalUtility dictionary:loginParams setObject:[permissions.allObjects componentsJoinedByString:@","] forKey:@"scope"];
|
||||||
|
|
||||||
|
NSString *expectedChallenge = [FBSDKLoginManager stringForChallenge];
|
||||||
|
NSDictionary *state = @{@"challenge": [FBSDKUtility URLEncode:expectedChallenge]};
|
||||||
|
loginParams[@"state"] = [FBSDKInternalUtility JSONStringForObject:state error:NULL invalidObjectHandler:nil];
|
||||||
|
|
||||||
|
[self storeExpectedChallenge:expectedChallenge];
|
||||||
|
|
||||||
|
return loginParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logInWithPermissions:(NSSet *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
FBSDKServerConfiguration *serverConfiguration = [FBSDKServerConfigurationManager cachedServerConfiguration];
|
||||||
|
_logger = [[FBSDKLoginManagerLogger alloc] initWithLoggingToken:serverConfiguration.loggingToken];
|
||||||
|
|
||||||
|
_handler = [handler copy];
|
||||||
|
_requestedPermissions = permissions;
|
||||||
|
|
||||||
|
[_logger startSessionForLoginManager:self];
|
||||||
|
|
||||||
|
[self logInWithBehavior:self.loginBehavior];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reauthorizeDataAccess:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
FBSDKServerConfiguration *serverConfiguration = [FBSDKServerConfigurationManager cachedServerConfiguration];
|
||||||
|
_logger = [[FBSDKLoginManagerLogger alloc] initWithLoggingToken:serverConfiguration.loggingToken];
|
||||||
|
_handler = [handler copy];
|
||||||
|
// Don't need to pass permissions for data reauthorization.
|
||||||
|
_requestedPermissions = [NSSet set];
|
||||||
|
self.authType = @"reauthorize";
|
||||||
|
[_logger startSessionForLoginManager:self];
|
||||||
|
[self logInWithBehavior:self.loginBehavior];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior
|
||||||
|
{
|
||||||
|
FBSDKServerConfiguration *serverConfiguration = [FBSDKServerConfigurationManager cachedServerConfiguration];
|
||||||
|
NSDictionary *loginParams = [self logInParametersWithPermissions:_requestedPermissions serverConfiguration:serverConfiguration];
|
||||||
|
self->_usedSFAuthSession = NO;
|
||||||
|
|
||||||
|
void(^completion)(BOOL, NSString *, NSError *) = ^void(BOOL didPerformLogIn, NSString *authMethod, NSError *error) {
|
||||||
|
if (didPerformLogIn) {
|
||||||
|
[self->_logger startAuthMethod:authMethod];
|
||||||
|
self->_state = FBSDKLoginManagerStatePerformingLogin;
|
||||||
|
} else if (error && [error.domain isEqualToString:SFVCCanceledLogin]) {
|
||||||
|
[self handleImplicitCancelOfLogIn];
|
||||||
|
} else {
|
||||||
|
if (!error) {
|
||||||
|
error = [NSError errorWithDomain:FBSDKLoginErrorDomain code:FBSDKLoginErrorUnknown userInfo:nil];
|
||||||
|
}
|
||||||
|
[self invokeHandler:nil error:error];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (loginBehavior) {
|
||||||
|
case FBSDKLoginBehaviorNative: {
|
||||||
|
if ([FBSDKInternalUtility isFacebookAppInstalled]) {
|
||||||
|
BOOL useNativeDialog = [serverConfiguration useNativeDialogForDialogName:FBSDKDialogConfigurationNameLogin];
|
||||||
|
if (useNativeDialog) {
|
||||||
|
[self performNativeLogInWithParameters:loginParams handler:^(BOOL openedURL, NSError *openedURLError) {
|
||||||
|
if (openedURLError) {
|
||||||
|
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||||
|
formatString:@"FBSDKLoginBehaviorNative failed : %@\nTrying FBSDKLoginBehaviorBrowser", openedURLError];
|
||||||
|
}
|
||||||
|
if (openedURL) {
|
||||||
|
completion(YES, FBSDKLoginManagerLoggerAuthMethod_Native, openedURLError);
|
||||||
|
} else {
|
||||||
|
[self logInWithBehavior:FBSDKLoginBehaviorBrowser];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
[self logInWithBehavior:FBSDKLoginBehaviorBrowser];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Intentional fall through. Switching to browser login instead.
|
||||||
|
}
|
||||||
|
case FBSDKLoginBehaviorBrowser: {
|
||||||
|
[self performBrowserLogInWithParameters:loginParams handler:^(BOOL openedURL,
|
||||||
|
NSString *authMethod,
|
||||||
|
NSError *openedURLError) {
|
||||||
|
completion(openedURL, authMethod, openedURLError);
|
||||||
|
}];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLoginBehaviorSystemAccount: {
|
||||||
|
if (serverConfiguration.isSystemAuthenticationEnabled) {
|
||||||
|
[self beginSystemLogIn];
|
||||||
|
} else {
|
||||||
|
[self logInWithBehavior:FBSDKLoginBehaviorNative];
|
||||||
|
}
|
||||||
|
completion(YES, FBSDKLoginManagerLoggerAuthMethod_System, nil);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLoginBehaviorWeb:
|
||||||
|
[self performWebLogInWithParameters:loginParams handler:^(BOOL openedURL, NSError *openedURLError) {
|
||||||
|
completion(openedURL, FBSDKLoginManagerLoggerAuthMethod_Webview, openedURLError);
|
||||||
|
}];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)storeExpectedChallenge:(NSString *)challengeExpected
|
||||||
|
{
|
||||||
|
[_keychainStore setString:challengeExpected
|
||||||
|
forKey:FBSDKExpectedChallengeKey
|
||||||
|
accessibility:[FBSDKDynamicFrameworkLoader loadkSecAttrAccessibleAfterFirstUnlockThisDeviceOnly]];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString *)stringForChallenge {
|
||||||
|
return [FBSDKCrypto randomString:FBClientStateChallengeLength];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)validateReauthentication:(FBSDKAccessToken *)currentToken withResult:(FBSDKLoginManagerLoginResult *)loginResult
|
||||||
|
{
|
||||||
|
FBSDKGraphRequest *requestMe = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
|
||||||
|
parameters:@{@"fields":@""}
|
||||||
|
tokenString:loginResult.token.tokenString
|
||||||
|
HTTPMethod:nil
|
||||||
|
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||||
|
[requestMe startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
NSString *actualID = result[@"id"];
|
||||||
|
if ([currentToken.userID isEqualToString:actualID]) {
|
||||||
|
[FBSDKAccessToken setCurrentAccessToken:loginResult.token];
|
||||||
|
[self invokeHandler:loginResult error:nil];
|
||||||
|
} else {
|
||||||
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:error forKey:NSUnderlyingErrorKey];
|
||||||
|
NSError *resultError = [NSError errorWithDomain:FBSDKLoginErrorDomain
|
||||||
|
code:FBSDKLoginErrorUserMismatch
|
||||||
|
userInfo:userInfo];
|
||||||
|
[self invokeHandler:nil error:resultError];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Test Methods
|
||||||
|
|
||||||
|
- (void)setHandler:(FBSDKLoginManagerRequestTokenHandler)handler
|
||||||
|
{
|
||||||
|
_handler = [handler copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setRequestedPermissions:(NSSet *)requestedPermissions
|
||||||
|
{
|
||||||
|
_requestedPermissions = [requestedPermissions copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManager (Native)
|
||||||
|
|
||||||
|
- (void)performNativeLogInWithParameters:(NSDictionary *)loginParams handler:(void(^)(BOOL, NSError*))handler
|
||||||
|
{
|
||||||
|
[_logger willAttemptAppSwitchingBehavior];
|
||||||
|
loginParams = [_logger parametersWithTimeStampAndClientState:loginParams forAuthMethod:FBSDKLoginManagerLoggerAuthMethod_Native];
|
||||||
|
|
||||||
|
NSString *scheme = ([FBSDKSettings appURLSchemeSuffix] ? @"fbauth2" : @"fbauth");
|
||||||
|
NSMutableDictionary *mutableParams = [NSMutableDictionary dictionaryWithDictionary:loginParams];
|
||||||
|
mutableParams[@"legacy_override"] = FBSDK_TARGET_PLATFORM_VERSION;
|
||||||
|
NSError *error;
|
||||||
|
NSURL *authURL = [FBSDKInternalUtility URLWithScheme:scheme host:@"authorize" path:@"" queryParameters:mutableParams error:&error];
|
||||||
|
|
||||||
|
NSDate *start = [NSDate date];
|
||||||
|
[[FBSDKApplicationDelegate sharedInstance] openURL:authURL sender:self handler:^(BOOL openedURL, NSError *anError) {
|
||||||
|
[self->_logger logNativeAppDialogResult:openedURL dialogDuration:-start.timeIntervalSinceNow];
|
||||||
|
if (handler) {
|
||||||
|
handler(openedURL, anError);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
// change bool to auth method string.
|
||||||
|
- (void)performBrowserLogInWithParameters:(NSDictionary *)loginParams
|
||||||
|
handler:(void(^)(BOOL didOpen, NSString *authMethod, NSError *error))handler
|
||||||
|
{
|
||||||
|
[_logger willAttemptAppSwitchingBehavior];
|
||||||
|
|
||||||
|
FBSDKServerConfiguration *configuration = [FBSDKServerConfigurationManager cachedServerConfiguration];
|
||||||
|
BOOL useSafariViewController = [configuration useSafariViewControllerForDialogName:FBSDKDialogConfigurationNameLogin];
|
||||||
|
NSString *authMethod = (useSafariViewController ? FBSDKLoginManagerLoggerAuthMethod_SFVC : FBSDKLoginManagerLoggerAuthMethod_Browser);
|
||||||
|
|
||||||
|
loginParams = [_logger parametersWithTimeStampAndClientState:loginParams forAuthMethod:authMethod];
|
||||||
|
|
||||||
|
NSURL *authURL = nil;
|
||||||
|
NSError *error;
|
||||||
|
NSURL *redirectURL = [FBSDKInternalUtility appURLWithHost:@"authorize" path:nil queryParameters:nil error:&error];
|
||||||
|
if (!error) {
|
||||||
|
NSMutableDictionary *browserParams = [loginParams mutableCopy];
|
||||||
|
[FBSDKInternalUtility dictionary:browserParams
|
||||||
|
setObject:redirectURL
|
||||||
|
forKey:@"redirect_uri"];
|
||||||
|
authURL = [FBSDKInternalUtility facebookURLWithHostPrefix:@"m."
|
||||||
|
path:FBSDKOauthPath
|
||||||
|
queryParameters:browserParams
|
||||||
|
error:&error];
|
||||||
|
}
|
||||||
|
if (authURL) {
|
||||||
|
void(^handlerWrapper)(BOOL, NSError*) = ^(BOOL didOpen, NSError *anError) {
|
||||||
|
if (handler) {
|
||||||
|
handler(didOpen, authMethod, anError);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (useSafariViewController) {
|
||||||
|
// Note based on above, authURL must be a http scheme. If that changes, add a guard, otherwise SFVC can throw
|
||||||
|
self->_usedSFAuthSession = YES;
|
||||||
|
[[FBSDKApplicationDelegate sharedInstance] openURLWithSafariViewController:authURL
|
||||||
|
sender:self
|
||||||
|
fromViewController:self.fromViewController
|
||||||
|
handler:handlerWrapper];
|
||||||
|
} else {
|
||||||
|
[[FBSDKApplicationDelegate sharedInstance] openURL:authURL sender:self handler:handlerWrapper];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error = error ?: [NSError fbErrorWithCode:FBSDKLoginErrorUnknown message:@"Failed to construct oauth browser url"];
|
||||||
|
if (handler) {
|
||||||
|
handler(NO, nil, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
||||||
|
{
|
||||||
|
BOOL isFacebookURL = [self canOpenURL:url forApplication:application sourceApplication:sourceApplication annotation:annotation];
|
||||||
|
|
||||||
|
if (!isFacebookURL && [self isPerformingLogin]) {
|
||||||
|
[self handleImplicitCancelOfLogIn];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFacebookURL) {
|
||||||
|
NSDictionary *urlParameters = [FBSDKLoginUtility queryParamsFromLoginURL:url];
|
||||||
|
id<FBSDKLoginCompleting> completer = [[FBSDKLoginURLCompleter alloc] initWithURLParameters:urlParameters appID:[FBSDKSettings appID]];
|
||||||
|
|
||||||
|
if (_logger == nil) {
|
||||||
|
_logger = [FBSDKLoginManagerLogger loggerFromParameters:urlParameters];
|
||||||
|
}
|
||||||
|
|
||||||
|
// any necessary strong reference is maintained by the FBSDKLoginURLCompleter handler
|
||||||
|
[completer completeLogIn:self withHandler:^(FBSDKLoginCompletionParameters *parameters) {
|
||||||
|
[self completeAuthentication:parameters expectChallenge:YES];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
return isFacebookURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)canOpenURL:(NSURL *)url
|
||||||
|
forApplication:(UIApplication *)application
|
||||||
|
sourceApplication:(NSString *)sourceApplication
|
||||||
|
annotation:(id)annotation
|
||||||
|
{
|
||||||
|
// verify the URL is intended as a callback for the SDK's log in
|
||||||
|
BOOL isFacebookURL = [url.scheme hasPrefix:[NSString stringWithFormat:@"fb%@", [FBSDKSettings appID]]] &&
|
||||||
|
[url.host isEqualToString:@"authorize"];
|
||||||
|
|
||||||
|
BOOL isExpectedSourceApplication = [sourceApplication hasPrefix:@"com.facebook"] || [sourceApplication hasPrefix:@"com.apple"] || [sourceApplication hasPrefix:@"com.burbn"];
|
||||||
|
|
||||||
|
return isFacebookURL && isExpectedSourceApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||||
|
{
|
||||||
|
if ([self isPerformingLogin]) {
|
||||||
|
[self handleImplicitCancelOfLogIn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isAuthenticationURL:(NSURL *)url
|
||||||
|
{
|
||||||
|
return [url.path hasSuffix:FBSDKOauthPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManager (Accounts)
|
||||||
|
|
||||||
|
- (void)beginSystemLogIn
|
||||||
|
{
|
||||||
|
// First, we need to validate the current access token. The user may have uninstalled the
|
||||||
|
// app, changed their password, etc., or the access token may have expired, which
|
||||||
|
// requires us to renew the account before asking for additional permissions.
|
||||||
|
NSString *accessTokenString = [FBSDKSystemAccountStoreAdapter sharedInstance].accessTokenString;
|
||||||
|
if (accessTokenString.length > 0) {
|
||||||
|
FBSDKGraphRequest *meRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
|
||||||
|
parameters:@{ @"fields" : @"id" }
|
||||||
|
tokenString:accessTokenString
|
||||||
|
HTTPMethod:nil
|
||||||
|
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||||
|
[meRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
if (!error) {
|
||||||
|
// If there was no error, make an explicit renewal call anyway to cover cases where user has revoked some read permission like email.
|
||||||
|
// Otherwise, iOS system account may continue to think email was granted and never prompt UI again.
|
||||||
|
[[FBSDKSystemAccountStoreAdapter sharedInstance] renewSystemAuthorization:^(ACAccountCredentialRenewResult renewResult, NSError *renewError) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self performSystemLogIn];
|
||||||
|
});
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
// If there was an error, FBSDKGraphRequestConnection would have already done work already (like renewal calls)
|
||||||
|
[self performSystemLogIn];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
[self performSystemLogIn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)performSystemLogIn
|
||||||
|
{
|
||||||
|
if (![FBSDKSystemAccountStoreAdapter sharedInstance].accountType) {
|
||||||
|
// There is no Facebook system account type. Fallback to Native behavior
|
||||||
|
[self fallbackToNativeBehavior];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BOOL isReauthorize = [FBSDKAccessToken currentAccessToken] != nil;
|
||||||
|
|
||||||
|
// app may be asking for nothing, but we will always have a set here
|
||||||
|
NSMutableSet *permissionsToUse = _requestedPermissions ? [_requestedPermissions mutableCopy] : [NSMutableSet set];
|
||||||
|
// Only add basic info if this is not reauthorize case, if it is the app should already have basic info ToSed
|
||||||
|
if (!isReauthorize) {
|
||||||
|
// Ensure that basic info is among the permissions requested so that the app will install if necessary.
|
||||||
|
// "email" is used as a proxy for basic_info permission.
|
||||||
|
[permissionsToUse addObject:@"email"];
|
||||||
|
}
|
||||||
|
|
||||||
|
[permissionsToUse removeObject:@"public_profile"];
|
||||||
|
[permissionsToUse removeObject:@"user_friends"];
|
||||||
|
|
||||||
|
NSString *audience;
|
||||||
|
switch (self.defaultAudience) {
|
||||||
|
case FBSDKDefaultAudienceOnlyMe:
|
||||||
|
audience = fbsdkdfl_ACFacebookAudienceOnlyMe();
|
||||||
|
break;
|
||||||
|
case FBSDKDefaultAudienceFriends:
|
||||||
|
audience = fbsdkdfl_ACFacebookAudienceFriends();
|
||||||
|
break;
|
||||||
|
case FBSDKDefaultAudienceEveryone:
|
||||||
|
audience = fbsdkdfl_ACFacebookAudienceEveryone();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
audience = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t timePriorToSystemAuthUI = [FBSDKInternalUtility currentTimeInMilliseconds];
|
||||||
|
|
||||||
|
// the FBSDKSystemAccountStoreAdapter completion handler maintains the strong reference during the the asynchronous operation
|
||||||
|
[[FBSDKSystemAccountStoreAdapter sharedInstance]
|
||||||
|
requestAccessToFacebookAccountStore:permissionsToUse
|
||||||
|
defaultAudience:audience
|
||||||
|
isReauthorize:isReauthorize
|
||||||
|
appID:[FBSDKSettings appID]
|
||||||
|
handler:^(NSString *oauthToken, NSError *accountStoreError) {
|
||||||
|
|
||||||
|
// There doesn't appear to be a reliable way to determine whether UI was shown or
|
||||||
|
// whether the cached token was sufficient. So we use a timer heuristic assuming that
|
||||||
|
// human response time couldn't complete a dialog in under the interval given here, but
|
||||||
|
// the process will return here fast enough if the token is cached. The threshold was
|
||||||
|
// chosen empirically, so there may be some edge cases that are false negatives or
|
||||||
|
// false positives.
|
||||||
|
BOOL didShowDialog = [FBSDKInternalUtility currentTimeInMilliseconds] - timePriorToSystemAuthUI > 350;
|
||||||
|
BOOL isUnTOSedDevice = !oauthToken && accountStoreError.code == ACErrorAccountNotFound;
|
||||||
|
[self->_logger systemAuthDidShowDialog:didShowDialog isUnTOSedDevice:isUnTOSedDevice];
|
||||||
|
|
||||||
|
if (accountStoreError && [FBSDKSystemAccountStoreAdapter sharedInstance].forceBlockingRenew) {
|
||||||
|
accountStoreError = [NSError fbErrorForSystemPasswordChange:accountStoreError];
|
||||||
|
}
|
||||||
|
if (!oauthToken && !accountStoreError) {
|
||||||
|
// This means iOS did not give an error nor granted, even after a renew. In order to
|
||||||
|
// surface this to users, stuff in our own error that can be inspected.
|
||||||
|
accountStoreError = [NSError fbErrorForFailedLoginWithCode:FBSDKLoginErrorSystemAccountAppDisabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
FBSDKLoginManagerSystemAccountState *state = [[FBSDKLoginManagerSystemAccountState alloc] init];
|
||||||
|
state.didShowDialog = didShowDialog;
|
||||||
|
state.reauthorize = isReauthorize;
|
||||||
|
state.unTOSedDevice = isUnTOSedDevice;
|
||||||
|
|
||||||
|
[self continueSystemLogInWithTokenString:oauthToken error:accountStoreError state:state];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)continueSystemLogInWithTokenString:(NSString *)oauthToken error:(NSError *)accountStoreError state:(FBSDKLoginManagerSystemAccountState *)state
|
||||||
|
{
|
||||||
|
id<FBSDKLoginCompleting> completer = nil;
|
||||||
|
|
||||||
|
if (!oauthToken && accountStoreError.code == ACErrorAccountNotFound) {
|
||||||
|
// Even with the Accounts framework we use the Facebook app or Safari to log in if
|
||||||
|
// the user has not signed in. This condition can only be detected by attempting to
|
||||||
|
// log in because the framework does not otherwise indicate whether a Facebook account
|
||||||
|
// exists on the device unless the user has granted the app permissions.
|
||||||
|
|
||||||
|
// Do this asynchronously so the logger correctly notes the system account was skipped
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self fallbackToNativeBehavior];
|
||||||
|
});
|
||||||
|
} else if (oauthToken) {
|
||||||
|
completer = [[FBSDKLoginSystemAccountCompleter alloc] initWithTokenString:oauthToken appID:[FBSDKSettings appID]];
|
||||||
|
} else {
|
||||||
|
completer = [[FBSDKLoginSystemAccountErrorCompleter alloc] initWithError:accountStoreError permissions:_requestedPermissions];
|
||||||
|
}
|
||||||
|
|
||||||
|
// any necessary strong reference is maintained by the FBSDKLoginSystemAccount[Error]Completer handler
|
||||||
|
[completer completeLogIn:self withHandler:^(FBSDKLoginCompletionParameters *parameters) {
|
||||||
|
NSString *eventName = [NSString stringWithFormat:@"%@ %@",
|
||||||
|
(state.isReauthorize ? @"Reauthorization" : @"Authorization"),
|
||||||
|
(parameters.error ? @"Error" : (parameters.accessTokenString ? @"succeeded" : @"cancelled"))
|
||||||
|
];
|
||||||
|
|
||||||
|
[self completeAuthentication:parameters expectChallenge:NO];
|
||||||
|
|
||||||
|
if (eventName != nil) {
|
||||||
|
NSString *sortedPermissions = (parameters.permissions.count == 0)
|
||||||
|
? @"<NoPermissionsSpecified>"
|
||||||
|
: [[parameters.permissions.allObjects sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] componentsJoinedByString:@","];
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNamePermissionsUILaunch
|
||||||
|
valueToSum:nil
|
||||||
|
parameters:@{ @"ui_dialog_type" : @"iOS integrated auth",
|
||||||
|
@"permissions_requested" : sortedPermissions }
|
||||||
|
accessToken:nil];
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNamePermissionsUIDismiss
|
||||||
|
valueToSum:nil
|
||||||
|
parameters:@{ @"ui_dialog_type" : @"iOS integrated auth",
|
||||||
|
FBSDKAppEventParameterDialogOutcome : eventName,
|
||||||
|
@"permissions_requested" : sortedPermissions }
|
||||||
|
accessToken:nil];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)fallbackToNativeBehavior
|
||||||
|
{
|
||||||
|
FBSDKLoginManagerLoginResult *skippedResult = [[FBSDKLoginManagerLoginResult alloc] initWithToken:nil
|
||||||
|
isCancelled:NO
|
||||||
|
grantedPermissions:nil
|
||||||
|
declinedPermissions:nil];
|
||||||
|
skippedResult.isSkipped = YES;
|
||||||
|
[_logger endLoginWithResult:skippedResult error:nil];
|
||||||
|
// any necessary strong reference will be maintained by the mechanism that is used
|
||||||
|
[self logInWithBehavior:FBSDKLoginBehaviorNative];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManager (WebDialog)
|
||||||
|
|
||||||
|
- (void)performWebLogInWithParameters:(NSDictionary *)loginParams handler:(void(^)(BOOL, NSError*))handler
|
||||||
|
{
|
||||||
|
[FBSDKInternalUtility registerTransientObject:self];
|
||||||
|
[FBSDKInternalUtility deleteFacebookCookies];
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] initWithDictionary:loginParams];
|
||||||
|
parameters[@"title"] = NSLocalizedStringWithDefaultValue(@"LoginWeb.LogInTitle",
|
||||||
|
@"FacebookSDK",
|
||||||
|
[FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Log In",
|
||||||
|
@"Title of the web dialog that prompts the user to log in to Facebook.");
|
||||||
|
[FBSDKWebDialog showWithName:@"oauth" parameters:parameters delegate:self];
|
||||||
|
|
||||||
|
if (handler) {
|
||||||
|
handler(YES, nil);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didCompleteWithResults:(NSDictionary *)results
|
||||||
|
{
|
||||||
|
NSString *token = results[@"access_token"];
|
||||||
|
|
||||||
|
if (token.length == 0) {
|
||||||
|
[self webDialogDidCancel:webDialog];
|
||||||
|
} else {
|
||||||
|
id<FBSDKLoginCompleting> completer = [[FBSDKLoginURLCompleter alloc] initWithURLParameters:results appID:[FBSDKSettings appID]];
|
||||||
|
[completer completeLogIn:self withHandler:^(FBSDKLoginCompletionParameters *parameters) {
|
||||||
|
[self completeAuthentication:parameters expectChallenge:YES];
|
||||||
|
}];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
FBSDKLoginCompletionParameters *parameters = [[FBSDKLoginCompletionParameters alloc] initWithError:error];
|
||||||
|
[self completeAuthentication:parameters expectChallenge:YES];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialogDidCancel:(FBSDKWebDialog *)webDialog
|
||||||
|
{
|
||||||
|
FBSDKLoginCompletionParameters *parameters = [[FBSDKLoginCompletionParameters alloc] init];
|
||||||
|
[self completeAuthentication:parameters expectChallenge:YES];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManagerSystemAccountState
|
||||||
|
@end
|
||||||
67
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManagerLoginResult.h
generated
Normal file
67
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManagerLoginResult.h
generated
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@class FBSDKAccessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Describes the result of a login attempt.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginManagerLoginResult : NSObject
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
the access token.
|
||||||
|
*/
|
||||||
|
@property (copy, nonatomic) FBSDKAccessToken *token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
whether the login was cancelled by the user.
|
||||||
|
*/
|
||||||
|
@property (readonly, nonatomic) BOOL isCancelled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
the set of permissions granted by the user in the associated request.
|
||||||
|
|
||||||
|
inspect the token's permissions set for a complete list.
|
||||||
|
*/
|
||||||
|
@property (copy, nonatomic) NSSet *grantedPermissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
the set of permissions declined by the user in the associated request.
|
||||||
|
|
||||||
|
inspect the token's permissions set for a complete list.
|
||||||
|
*/
|
||||||
|
@property (copy, nonatomic) NSSet *declinedPermissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes a new instance.
|
||||||
|
@param token the access token
|
||||||
|
@param isCancelled whether the login was cancelled by the user
|
||||||
|
@param grantedPermissions the set of granted permissions
|
||||||
|
@param declinedPermissions the set of declined permissions
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithToken:(FBSDKAccessToken *)token
|
||||||
|
isCancelled:(BOOL)isCancelled
|
||||||
|
grantedPermissions:(NSSet *)grantedPermissions
|
||||||
|
declinedPermissions:(NSSet *)declinedPermissions
|
||||||
|
NS_DESIGNATED_INITIALIZER;
|
||||||
|
@end
|
||||||
51
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManagerLoginResult.m
generated
Normal file
51
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManagerLoginResult.m
generated
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginManagerLoginResult+Internal.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManagerLoginResult {
|
||||||
|
NSMutableDictionary *_mutableLoggingExtras;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithToken:(FBSDKAccessToken *)token
|
||||||
|
isCancelled:(BOOL)isCancelled
|
||||||
|
grantedPermissions:(NSSet *)grantedPermissions
|
||||||
|
declinedPermissions:(NSSet *)declinedPermissions {
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_mutableLoggingExtras = [NSMutableDictionary dictionary];
|
||||||
|
_token = [token copy];
|
||||||
|
_isCancelled = isCancelled;
|
||||||
|
_grantedPermissions = [grantedPermissions copy];
|
||||||
|
_declinedPermissions = [declinedPermissions copy];
|
||||||
|
};
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)addLoggingExtra:(id)object forKey:(id<NSCopying>)key
|
||||||
|
{
|
||||||
|
[FBSDKInternalUtility dictionary:_mutableLoggingExtras setObject:object forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)loggingExtras
|
||||||
|
{
|
||||||
|
return [_mutableLoggingExtras copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
90
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginTooltipView.h
generated
Normal file
90
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginTooltipView.h
generated
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKTooltipView.h>
|
||||||
|
|
||||||
|
@protocol FBSDKLoginTooltipViewDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Represents a tooltip to be displayed next to a Facebook login button
|
||||||
|
to highlight features for new users.
|
||||||
|
|
||||||
|
|
||||||
|
The `FBSDKLoginButton` may display this view automatically. If you do
|
||||||
|
not use the `FBSDKLoginButton`, you can manually call one of the `present*` methods
|
||||||
|
as appropriate and customize behavior via `FBSDKLoginTooltipViewDelegate` delegate.
|
||||||
|
|
||||||
|
By default, the `FBSDKLoginTooltipView` is not added to the superview until it is
|
||||||
|
determined the app has migrated to the new login experience. You can override this
|
||||||
|
(e.g., to test the UI layout) by implementing the delegate or setting `forceDisplay` to YES.
|
||||||
|
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginTooltipView : FBSDKTooltipView
|
||||||
|
|
||||||
|
/** the delegate */
|
||||||
|
@property (nonatomic, weak) id<FBSDKLoginTooltipViewDelegate> delegate;
|
||||||
|
|
||||||
|
/** if set to YES, the view will always be displayed and the delegate's
|
||||||
|
`loginTooltipView:shouldAppear:` will NOT be called. */
|
||||||
|
@property (nonatomic, assign) BOOL forceDisplay;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
@protocol
|
||||||
|
|
||||||
|
The `FBSDKLoginTooltipViewDelegate` protocol defines the methods used to receive event
|
||||||
|
notifications from `FBSDKLoginTooltipView` objects.
|
||||||
|
*/
|
||||||
|
@protocol FBSDKLoginTooltipViewDelegate <NSObject>
|
||||||
|
|
||||||
|
@optional
|
||||||
|
|
||||||
|
/**
|
||||||
|
Asks the delegate if the tooltip view should appear
|
||||||
|
|
||||||
|
@param view The tooltip view.
|
||||||
|
@param appIsEligible The value fetched from the server identifying if the app
|
||||||
|
is eligible for the new login experience.
|
||||||
|
|
||||||
|
|
||||||
|
Use this method to customize display behavior.
|
||||||
|
*/
|
||||||
|
- (BOOL)loginTooltipView:(FBSDKLoginTooltipView *)view shouldAppear:(BOOL)appIsEligible;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Tells the delegate the tooltip view will appear, specifically after it's been
|
||||||
|
added to the super view but before the fade in animation.
|
||||||
|
|
||||||
|
@param view The tooltip view.
|
||||||
|
*/
|
||||||
|
- (void)loginTooltipViewWillAppear:(FBSDKLoginTooltipView *)view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Tells the delegate the tooltip view will not appear (i.e., was not
|
||||||
|
added to the super view).
|
||||||
|
|
||||||
|
@param view The tooltip view.
|
||||||
|
*/
|
||||||
|
- (void)loginTooltipViewWillNotAppear:(FBSDKLoginTooltipView *)view;
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
62
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginTooltipView.m
generated
Normal file
62
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginTooltipView.m
generated
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginTooltipView.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
@interface FBSDKLoginTooltipView ()
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginTooltipView
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
NSString *tooltipMessage =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginTooltip.Message", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"You're in control - choose what info you want to share with apps.",
|
||||||
|
@"The message of the FBSDKLoginTooltipView");
|
||||||
|
return [super initWithTagline:nil message:tooltipMessage colorStyle:FBSDKTooltipColorStyleFriendlyBlue];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)presentInView:(UIView *)view withArrowPosition:(CGPoint)arrowPosition direction:(FBSDKTooltipViewArrowDirection)arrowDirection
|
||||||
|
{
|
||||||
|
if (self.forceDisplay) {
|
||||||
|
[super presentInView:view withArrowPosition:arrowPosition direction:arrowDirection];
|
||||||
|
} else {
|
||||||
|
|
||||||
|
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *error) {
|
||||||
|
self.message = serverConfiguration.loginTooltipText;
|
||||||
|
BOOL shouldDisplay = serverConfiguration.loginTooltipEnabled;
|
||||||
|
if ([self.delegate respondsToSelector:@selector(loginTooltipView:shouldAppear:)]) {
|
||||||
|
shouldDisplay = [self.delegate loginTooltipView:self shouldAppear:shouldDisplay];
|
||||||
|
}
|
||||||
|
if (shouldDisplay) {
|
||||||
|
[super presentInView:view withArrowPosition:arrowPosition direction:arrowDirection];
|
||||||
|
if ([self.delegate respondsToSelector:@selector(loginTooltipViewWillAppear:)]) {
|
||||||
|
[self.delegate loginTooltipViewWillAppear:self];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(loginTooltipViewWillNotAppear:)]) {
|
||||||
|
[self.delegate loginTooltipViewWillNotAppear:self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
136
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKTooltipView.h
generated
Normal file
136
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKTooltipView.h
generated
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKTooltipViewArrowDirection enum
|
||||||
|
|
||||||
|
Passed on construction to determine arrow orientation.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKTooltipViewArrowDirection)
|
||||||
|
{
|
||||||
|
/** View is located above given point, arrow is pointing down. */
|
||||||
|
FBSDKTooltipViewArrowDirectionDown = 0,
|
||||||
|
/** View is located below given point, arrow is pointing up. */
|
||||||
|
FBSDKTooltipViewArrowDirectionUp = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKTooltipColorStyle enum
|
||||||
|
|
||||||
|
Passed on construction to determine color styling.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKTooltipColorStyle)
|
||||||
|
{
|
||||||
|
/** Light blue background, white text, faded blue close button. */
|
||||||
|
FBSDKTooltipColorStyleFriendlyBlue = 0,
|
||||||
|
/** Dark gray background, white text, light gray close button. */
|
||||||
|
FBSDKTooltipColorStyleNeutralGray = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
Tooltip bubble with text in it used to display tips for UI elements,
|
||||||
|
with a pointed arrow (to refer to the UI element).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The tooltip fades in and will automatically fade out. See `displayDuration`.
|
||||||
|
*/
|
||||||
|
@interface FBSDKTooltipView : UIView
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets or sets the amount of time in seconds the tooltip should be displayed.
|
||||||
|
Set this to zero to make the display permanent until explicitly dismissed.
|
||||||
|
Defaults to six seconds.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) CFTimeInterval displayDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets or sets the color style after initialization.
|
||||||
|
Defaults to value passed to -initWithTagline:message:colorStyle:.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKTooltipColorStyle colorStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets or sets the message.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets or sets the optional phrase that comprises the first part of the label (and is highlighted differently).
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *tagline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Designated initializer.
|
||||||
|
|
||||||
|
@param tagline First part of the label, that will be highlighted with different color. Can be nil.
|
||||||
|
|
||||||
|
@param message Main message to display.
|
||||||
|
|
||||||
|
@param colorStyle Color style to use for tooltip.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
If you need to show a tooltip for login, consider using the `FBSDKLoginTooltipView` view.
|
||||||
|
|
||||||
|
|
||||||
|
@see FBSDKLoginTooltipView
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithTagline:(NSString *)tagline message:(NSString *)message colorStyle:(FBSDKTooltipColorStyle)colorStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Show tooltip at the top or at the bottom of given view.
|
||||||
|
Tooltip will be added to anchorView.window.rootViewController.view
|
||||||
|
|
||||||
|
@param anchorView view to show at, must be already added to window view hierarchy, in order to decide
|
||||||
|
where tooltip will be shown. (If there's not enough space at the top of the anchorView in window bounds -
|
||||||
|
tooltip will be shown at the bottom of it)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Use this method to present the tooltip with automatic positioning or
|
||||||
|
use -presentInView:withArrowPosition:direction: for manual positioning
|
||||||
|
If anchorView is nil or has no window - this method does nothing.
|
||||||
|
*/
|
||||||
|
- (void)presentFromView:(UIView *)anchorView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds tooltip to given view, with given position and arrow direction.
|
||||||
|
|
||||||
|
@param view View to be used as superview.
|
||||||
|
|
||||||
|
@param arrowPosition Point in view's cordinates, where arrow will be pointing
|
||||||
|
|
||||||
|
@param arrowDirection whenever arrow should be pointing up (message bubble is below the arrow) or
|
||||||
|
down (message bubble is above the arrow).
|
||||||
|
*/
|
||||||
|
- (void)presentInView:(UIView *)view withArrowPosition:(CGPoint)arrowPosition direction:(FBSDKTooltipViewArrowDirection)arrowDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Remove tooltip manually.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Calling this method isn't necessary - tooltip will dismiss itself automatically after the `displayDuration`.
|
||||||
|
*/
|
||||||
|
- (void)dismiss;
|
||||||
|
|
||||||
|
@end
|
||||||
603
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKTooltipView.m
generated
Normal file
603
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/FBSDKTooltipView.m
generated
Normal file
@ -0,0 +1,603 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKTooltipView.h"
|
||||||
|
|
||||||
|
#import <CoreText/CoreText.h>
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
static const CGFloat kTransitionDuration = 0.3;
|
||||||
|
static const CGFloat kZoomOutScale = 0.001f;
|
||||||
|
static const CGFloat kZoomInScale = 1.1f;
|
||||||
|
static const CGFloat kZoomBounceScale = 0.98f;
|
||||||
|
|
||||||
|
static const CGFloat kNUXRectInset = 6;
|
||||||
|
static const CGFloat kNUXBubbleMargin = 17 - kNUXRectInset;
|
||||||
|
static const CGFloat kNUXPointMargin = -3;
|
||||||
|
static const CGFloat kNUXCornerRadius = 4;
|
||||||
|
static const CGFloat kNUXStrokeLineWidth = 0.5f;
|
||||||
|
static const CGFloat kNUXSideCap = 6;
|
||||||
|
static const CGFloat kNUXFontSize = 10;
|
||||||
|
static const CGFloat kNUXCrossGlyphSize = 11;
|
||||||
|
|
||||||
|
static CGMutablePathRef _fbsdkCreateUpPointingBubbleWithRect(CGRect rect, CGFloat arrowMidpoint, CGFloat arrowHeight, CGFloat radius);
|
||||||
|
static CGMutablePathRef _fbsdkCreateDownPointingBubbleWithRect(CGRect rect, CGFloat arrowMidpoint, CGFloat arrowHeight, CGFloat radius);
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
@implementation FBSDKTooltipView
|
||||||
|
{
|
||||||
|
CGPoint _positionInView;
|
||||||
|
CFAbsoluteTime _displayTime;
|
||||||
|
CFTimeInterval _minimumDisplayDuration;
|
||||||
|
UILabel *_textLabel;
|
||||||
|
UITapGestureRecognizer *_insideTapGestureRecognizer;
|
||||||
|
CGFloat _leftWidth;
|
||||||
|
CGFloat _rightWidth;
|
||||||
|
CGFloat _arrowMidpoint;
|
||||||
|
BOOL _pointingUp;
|
||||||
|
BOOL _isFadingOut;
|
||||||
|
// style
|
||||||
|
UIColor *_innerStrokeColor;
|
||||||
|
CGFloat _arrowHeight;
|
||||||
|
CGFloat _textPadding;
|
||||||
|
CGFloat _maximumTextWidth;
|
||||||
|
CGFloat _verticalTextOffset;
|
||||||
|
CGFloat _verticalCrossOffset;
|
||||||
|
FBSDKTooltipColorStyle _colorStyle;
|
||||||
|
NSArray *_gradientColors;
|
||||||
|
UIColor *_crossCloseGlyphColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithTagline:(NSString *)tagline message:(NSString *)message colorStyle:(FBSDKTooltipColorStyle)colorStyle
|
||||||
|
{
|
||||||
|
self = [super initWithFrame:CGRectZero];
|
||||||
|
if (self) {
|
||||||
|
// Define style
|
||||||
|
_textLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
|
_textLabel.backgroundColor = [UIColor clearColor];
|
||||||
|
_textLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
||||||
|
_textLabel.numberOfLines = 0;
|
||||||
|
_textLabel.font = [UIFont boldSystemFontOfSize: kNUXFontSize];
|
||||||
|
_textLabel.textAlignment = NSTextAlignmentLeft;
|
||||||
|
_arrowHeight = 7;
|
||||||
|
_textPadding = 10;
|
||||||
|
_maximumTextWidth = 185;
|
||||||
|
_verticalCrossOffset = - 2.5f;
|
||||||
|
_verticalTextOffset = 0;
|
||||||
|
_displayDuration = 6.0;
|
||||||
|
self.colorStyle = colorStyle;
|
||||||
|
|
||||||
|
_message = [message copy];
|
||||||
|
_tagline = [tagline copy];
|
||||||
|
[self setMessage:message tagline:tagline];
|
||||||
|
[self addSubview:_textLabel];
|
||||||
|
|
||||||
|
_insideTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapInTooltip:)];
|
||||||
|
[self addGestureRecognizer:_insideTapGestureRecognizer];
|
||||||
|
|
||||||
|
self.opaque = NO;
|
||||||
|
self.backgroundColor = [UIColor clearColor];
|
||||||
|
self.layer.needsDisplayOnBoundsChange = YES;
|
||||||
|
self.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||||
|
self.layer.shadowOpacity = 0.5f;
|
||||||
|
self.layer.shadowOffset = CGSizeMake(0.0f, 2.0f);
|
||||||
|
self.layer.shadowRadius = 5.0f;
|
||||||
|
self.layer.masksToBounds = NO;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[_insideTapGestureRecognizer removeTarget:self action:NULL];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (void)setMessage:(NSString *)message
|
||||||
|
{
|
||||||
|
if (![message isEqualToString:_message]) {
|
||||||
|
_message = [message copy];
|
||||||
|
[self setMessage:_message tagline:self.tagline];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTagline:(NSString *)tagline
|
||||||
|
{
|
||||||
|
if (![tagline isEqualToString:_tagline]) {
|
||||||
|
_tagline = [tagline copy];
|
||||||
|
[self setMessage:self.message tagline:_tagline];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Presentation
|
||||||
|
|
||||||
|
- (void)presentFromView:(UIView *)anchorView
|
||||||
|
{
|
||||||
|
UIView *superview = anchorView.window.rootViewController.view;
|
||||||
|
if (!superview) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// By default - attach to the top, pointing down
|
||||||
|
CGPoint position = CGPointMake(CGRectGetMidX(anchorView.bounds), CGRectGetMinY(anchorView.bounds));
|
||||||
|
CGPoint positionInSuperview = [superview convertPoint:position fromView:anchorView];
|
||||||
|
FBSDKTooltipViewArrowDirection direction = FBSDKTooltipViewArrowDirectionDown;
|
||||||
|
|
||||||
|
// If not enough space to point up from top of anchor view - point up to it's bottom
|
||||||
|
CGFloat bubbleHeight = CGRectGetHeight(_textLabel.bounds) + _verticalTextOffset + _textPadding * 2;
|
||||||
|
if (positionInSuperview.y - bubbleHeight - kNUXBubbleMargin < CGRectGetMinY(superview.bounds)) {
|
||||||
|
direction = FBSDKTooltipViewArrowDirectionUp;
|
||||||
|
position = CGPointMake(CGRectGetMidX(anchorView.bounds), CGRectGetMaxY(anchorView.bounds));
|
||||||
|
positionInSuperview = [superview convertPoint:position fromView:anchorView];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self presentInView:superview withArrowPosition:positionInSuperview direction:direction];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)presentInView:(UIView *)view withArrowPosition:(CGPoint)arrowPosition direction:(FBSDKTooltipViewArrowDirection)arrowDirection
|
||||||
|
{
|
||||||
|
_pointingUp = arrowDirection == FBSDKTooltipViewArrowDirectionUp;
|
||||||
|
_positionInView = arrowPosition;
|
||||||
|
self.frame = [self layoutSubviewsAndDetermineFrame];
|
||||||
|
|
||||||
|
// Add to view, while invisible.
|
||||||
|
self.hidden = YES;
|
||||||
|
if (self.superview) {
|
||||||
|
[self removeFromSuperview];
|
||||||
|
}
|
||||||
|
[view addSubview:self];
|
||||||
|
|
||||||
|
// Layout & schedule dismissal.
|
||||||
|
_displayTime = CFAbsoluteTimeGetCurrent();
|
||||||
|
_isFadingOut = NO;
|
||||||
|
[self scheduleAutomaticFadeout];
|
||||||
|
[self layoutSubviews];
|
||||||
|
|
||||||
|
[self animateFadeIn];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dismiss
|
||||||
|
{
|
||||||
|
if (_isFadingOut) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_isFadingOut = YES;
|
||||||
|
|
||||||
|
[self animateFadeOutWithCompletion:^{
|
||||||
|
[self removeFromSuperview];
|
||||||
|
[self cancelAllScheduledFadeOutMethods];
|
||||||
|
self->_isFadingOut = NO;
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Style
|
||||||
|
|
||||||
|
- (FBSDKTooltipColorStyle)colorStyle
|
||||||
|
{
|
||||||
|
return _colorStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setColorStyle:(FBSDKTooltipColorStyle)colorStyle
|
||||||
|
{
|
||||||
|
_colorStyle = colorStyle;
|
||||||
|
switch (colorStyle) {
|
||||||
|
case FBSDKTooltipColorStyleNeutralGray:
|
||||||
|
_gradientColors = @[
|
||||||
|
(id)(FBSDKUIColorWithRGB(0x51, 0x50, 0x4f).CGColor),
|
||||||
|
(id)(FBSDKUIColorWithRGB(0x2d, 0x2c, 0x2c).CGColor)
|
||||||
|
];
|
||||||
|
_innerStrokeColor = [UIColor colorWithWhite:0.13f alpha:1.0f];
|
||||||
|
_crossCloseGlyphColor = [UIColor colorWithWhite:0.69f alpha:1.0f];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FBSDKTooltipColorStyleFriendlyBlue:
|
||||||
|
default:
|
||||||
|
_gradientColors = @[
|
||||||
|
(id)(FBSDKUIColorWithRGB(0x6e, 0x9c, 0xf5).CGColor),
|
||||||
|
(id)(FBSDKUIColorWithRGB(0x49, 0x74, 0xc6).CGColor)
|
||||||
|
];
|
||||||
|
_innerStrokeColor = [UIColor colorWithRed:0.12f green:0.26f blue:0.55f alpha:1.0f];
|
||||||
|
_crossCloseGlyphColor = [UIColor colorWithRed:0.60f green:0.73f blue:1.0f alpha:1.0f];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_textLabel.textColor = [UIColor whiteColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private Methods
|
||||||
|
#pragma mark Animation
|
||||||
|
|
||||||
|
- (void)animateFadeIn
|
||||||
|
{
|
||||||
|
// Prepare Animation: Zoom in with bounce. Keep the arrow point in place.
|
||||||
|
// Set initial transform (zoomed out) & become visible.
|
||||||
|
CGFloat centerPos = self.bounds.size.width / 2.0;
|
||||||
|
CGFloat zoomOffsetX = (centerPos - _arrowMidpoint) * (kZoomOutScale - 1.0f);
|
||||||
|
CGFloat zoomOffsetY = -0.5f * self.bounds.size.height * (kZoomOutScale - 1.0f);
|
||||||
|
if (_pointingUp) {
|
||||||
|
zoomOffsetY = -zoomOffsetY;
|
||||||
|
}
|
||||||
|
self.layer.transform = fbsdkdfl_CATransform3DConcat(fbsdkdfl_CATransform3DMakeScale(kZoomOutScale, kZoomOutScale, kZoomOutScale),
|
||||||
|
fbsdkdfl_CATransform3DMakeTranslation(zoomOffsetX, zoomOffsetY, 0));
|
||||||
|
self.hidden = NO;
|
||||||
|
|
||||||
|
// Prepare animation steps
|
||||||
|
// 1st Step.
|
||||||
|
void (^zoomIn)(void) = ^{
|
||||||
|
self.alpha = 1.0;
|
||||||
|
|
||||||
|
CGFloat newZoomOffsetX = (centerPos - self->_arrowMidpoint) * (kZoomInScale - 1.0f);
|
||||||
|
CGFloat newZoomOffsetY = -0.5f * self.bounds.size.height * (kZoomInScale - 1.0f);
|
||||||
|
if (self->_pointingUp) {
|
||||||
|
newZoomOffsetY = -newZoomOffsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
CATransform3D scale = fbsdkdfl_CATransform3DMakeScale(kZoomInScale, kZoomInScale, kZoomInScale);
|
||||||
|
CATransform3D translate =fbsdkdfl_CATransform3DMakeTranslation(newZoomOffsetX, newZoomOffsetY, 0);
|
||||||
|
self.layer.transform = fbsdkdfl_CATransform3DConcat(scale, translate);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 2nd Step.
|
||||||
|
void (^bounceZoom)(void) = ^{
|
||||||
|
CGFloat centerPos2 = self.bounds.size.width / 2.0;
|
||||||
|
CGFloat zoomOffsetX2 = (centerPos2 - self->_arrowMidpoint) * (kZoomBounceScale - 1.0f);
|
||||||
|
CGFloat zoomOffsetY2 = -0.5f * self.bounds.size.height * (kZoomBounceScale - 1.0f);
|
||||||
|
if (self->_pointingUp) {
|
||||||
|
zoomOffsetY2 = -zoomOffsetY2;
|
||||||
|
}
|
||||||
|
self.layer.transform = fbsdkdfl_CATransform3DConcat(fbsdkdfl_CATransform3DMakeScale(kZoomBounceScale, kZoomBounceScale, kZoomBounceScale),
|
||||||
|
fbsdkdfl_CATransform3DMakeTranslation(zoomOffsetX2, zoomOffsetY2, 0));
|
||||||
|
};
|
||||||
|
|
||||||
|
// 3rd Step.
|
||||||
|
void (^normalizeZoom)(void) = ^{
|
||||||
|
self.layer.transform = fbsdkdfl_CATransform3DIdentity;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Animate 3 steps sequentially
|
||||||
|
[UIView animateWithDuration:kTransitionDuration/1.5
|
||||||
|
delay:0
|
||||||
|
options:UIViewAnimationOptionCurveEaseInOut
|
||||||
|
animations:zoomIn
|
||||||
|
completion:^(BOOL finished) {
|
||||||
|
[UIView animateWithDuration:kTransitionDuration/2.2
|
||||||
|
animations:bounceZoom
|
||||||
|
completion:^(BOOL innerFinished) {
|
||||||
|
[UIView animateWithDuration:kTransitionDuration/5
|
||||||
|
animations:normalizeZoom];
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) animateFadeOutWithCompletion: (void(^)(void)) completionHandler
|
||||||
|
{
|
||||||
|
[UIView animateWithDuration:0.3
|
||||||
|
delay:0
|
||||||
|
options:UIViewAnimationOptionCurveEaseInOut
|
||||||
|
animations:^{
|
||||||
|
self.alpha = 0.0;
|
||||||
|
}
|
||||||
|
completion:^(BOOL complete) {
|
||||||
|
if(completionHandler)
|
||||||
|
completionHandler();
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Gestures
|
||||||
|
|
||||||
|
- (void)onTapInTooltip:(UIGestureRecognizer*)sender
|
||||||
|
{
|
||||||
|
// ignore incomplete tap gestures
|
||||||
|
if (sender.state != UIGestureRecognizerStateEnded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fade out the tooltip view right away
|
||||||
|
[self dismiss];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Drawing
|
||||||
|
|
||||||
|
CGMutablePathRef _fbsdkCreateUpPointingBubbleWithRect(CGRect rect, CGFloat arrowMidpoint, CGFloat arrowHeight, CGFloat radius)
|
||||||
|
{
|
||||||
|
CGMutablePathRef path = CGPathCreateMutable();
|
||||||
|
CGFloat arrowHalfWidth = arrowHeight;
|
||||||
|
// start with arrow
|
||||||
|
CGPathMoveToPoint(path, NULL, arrowMidpoint - arrowHalfWidth, CGRectGetMinY(rect));
|
||||||
|
CGPathAddLineToPoint(path, NULL, arrowMidpoint, CGRectGetMinY(rect) - arrowHeight);
|
||||||
|
CGPathAddLineToPoint(path, NULL, arrowMidpoint + arrowHalfWidth, CGRectGetMinY(rect));
|
||||||
|
|
||||||
|
// rest of curved rectangle
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMaxX(rect), CGRectGetMinY(rect), CGRectGetMaxX(rect), CGRectGetMaxY(rect), radius);
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMaxX(rect), CGRectGetMaxY(rect), CGRectGetMinX(rect), CGRectGetMaxY(rect), radius);
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMinX(rect), CGRectGetMaxY(rect), CGRectGetMinX(rect), CGRectGetMinY(rect), radius);
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMinX(rect), CGRectGetMinY(rect), CGRectGetMaxX(rect), CGRectGetMinY(rect), radius);
|
||||||
|
CGPathCloseSubpath(path);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGMutablePathRef _fbsdkCreateDownPointingBubbleWithRect(CGRect rect, CGFloat arrowMidpoint, CGFloat arrowHeight, CGFloat radius)
|
||||||
|
{
|
||||||
|
CGMutablePathRef path = CGPathCreateMutable();
|
||||||
|
CGFloat arrowHalfWidth = arrowHeight;
|
||||||
|
|
||||||
|
// start with arrow
|
||||||
|
CGPathMoveToPoint(path, NULL, arrowMidpoint + arrowHalfWidth, CGRectGetMaxY(rect));
|
||||||
|
CGPathAddLineToPoint(path, NULL, arrowMidpoint, CGRectGetMaxY(rect) + arrowHeight);
|
||||||
|
CGPathAddLineToPoint(path, NULL, arrowMidpoint - arrowHalfWidth, CGRectGetMaxY(rect));
|
||||||
|
|
||||||
|
// rest of curved rectangle
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMinX(rect), CGRectGetMaxY(rect), CGRectGetMinX(rect), CGRectGetMinY(rect), radius);
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMinX(rect), CGRectGetMinY(rect), CGRectGetMaxX(rect), CGRectGetMinY(rect), radius);
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMaxX(rect), CGRectGetMinY(rect), CGRectGetMaxX(rect), CGRectGetMaxY(rect), radius);
|
||||||
|
CGPathAddArcToPoint(path, NULL, CGRectGetMaxX(rect), CGRectGetMaxY(rect), CGRectGetMinX(rect), CGRectGetMaxY(rect), radius);
|
||||||
|
CGPathCloseSubpath(path);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CGMutablePathRef _createCloseCrossGlyphWithRect(CGRect rect)
|
||||||
|
{
|
||||||
|
CGFloat lineThickness = 0.20f * CGRectGetHeight(rect);
|
||||||
|
|
||||||
|
// One rectangle
|
||||||
|
CGMutablePathRef path1 = CGPathCreateMutable();
|
||||||
|
CGPathMoveToPoint(path1, NULL, CGRectGetMinX(rect), CGRectGetMinY(rect) + lineThickness);
|
||||||
|
CGPathAddLineToPoint(path1, NULL, CGRectGetMinX(rect) + lineThickness, CGRectGetMinY(rect));
|
||||||
|
CGPathAddLineToPoint(path1, NULL, CGRectGetMaxX(rect), CGRectGetMaxY(rect) - lineThickness);
|
||||||
|
CGPathAddLineToPoint(path1, NULL, CGRectGetMaxX(rect) - lineThickness, CGRectGetMaxY(rect));
|
||||||
|
CGPathCloseSubpath(path1);
|
||||||
|
|
||||||
|
// 2nd rectangle - mirrored horizontally
|
||||||
|
CGMutablePathRef path2 = CGPathCreateMutable();
|
||||||
|
CGPathMoveToPoint(path2, NULL, CGRectGetMinX(rect), CGRectGetMaxY(rect) - lineThickness);
|
||||||
|
CGPathAddLineToPoint(path2, NULL, CGRectGetMaxX(rect) - lineThickness, CGRectGetMinY(rect));
|
||||||
|
CGPathAddLineToPoint(path2, NULL, CGRectGetMaxX(rect), CGRectGetMinY(rect) + lineThickness);
|
||||||
|
CGPathAddLineToPoint(path2, NULL, CGRectGetMinX(rect) + lineThickness, CGRectGetMaxY(rect));
|
||||||
|
CGPathCloseSubpath(path2);
|
||||||
|
|
||||||
|
CGMutablePathRef groupedPath = CGPathCreateMutable();
|
||||||
|
CGPathAddPath(groupedPath, NULL, path1);
|
||||||
|
CGPathAddPath(groupedPath, NULL, path2);
|
||||||
|
CFRelease(path1);
|
||||||
|
CFRelease(path2);
|
||||||
|
|
||||||
|
return groupedPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawRect:(CGRect)rect
|
||||||
|
{
|
||||||
|
// Ignore dirty rect and just redraw the entire nux bubble
|
||||||
|
CGFloat arrowSideMargin = 1 + 0.5f * MAX(kNUXRectInset, _arrowHeight);
|
||||||
|
CGFloat arrowYMarginOffset = _pointingUp ? arrowSideMargin : kNUXRectInset;
|
||||||
|
CGFloat halfStroke = kNUXStrokeLineWidth / 2.0;
|
||||||
|
CGRect outerRect = CGRectMake(kNUXRectInset + halfStroke,
|
||||||
|
arrowYMarginOffset + halfStroke,
|
||||||
|
self.bounds.size.width - 2 * kNUXRectInset - kNUXStrokeLineWidth,
|
||||||
|
self.bounds.size.height - kNUXRectInset - arrowSideMargin - kNUXStrokeLineWidth);
|
||||||
|
outerRect = CGRectInset(outerRect, 5, 5);
|
||||||
|
CGRect innerRect = CGRectInset(outerRect, kNUXStrokeLineWidth, kNUXStrokeLineWidth);
|
||||||
|
CGRect fillRect = CGRectInset(innerRect, kNUXStrokeLineWidth/2.0, kNUXStrokeLineWidth/2.0);
|
||||||
|
CGFloat closeCrossGlyphPositionY = MIN(CGRectGetMinY(fillRect) + _textPadding + _verticalCrossOffset,
|
||||||
|
CGRectGetMidY(fillRect) - 0.5f * kNUXCrossGlyphSize);
|
||||||
|
CGRect closeCrossGlyphRect = CGRectMake(CGRectGetMaxX(fillRect) - 2 * kNUXFontSize, closeCrossGlyphPositionY,
|
||||||
|
kNUXCrossGlyphSize, kNUXCrossGlyphSize);
|
||||||
|
|
||||||
|
// setup and get paths
|
||||||
|
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||||
|
CGMutablePathRef outerPath;
|
||||||
|
CGMutablePathRef innerPath;
|
||||||
|
CGMutablePathRef fillPath;
|
||||||
|
CGMutablePathRef crossCloseGlyphPath = _createCloseCrossGlyphWithRect(closeCrossGlyphRect);
|
||||||
|
CGRect gradientRect = fillRect;
|
||||||
|
if (_pointingUp) {
|
||||||
|
outerPath = _fbsdkCreateUpPointingBubbleWithRect(outerRect,
|
||||||
|
_arrowMidpoint, _arrowHeight,
|
||||||
|
kNUXCornerRadius + kNUXStrokeLineWidth);
|
||||||
|
innerPath = _fbsdkCreateUpPointingBubbleWithRect(innerRect,
|
||||||
|
_arrowMidpoint, _arrowHeight,
|
||||||
|
kNUXCornerRadius);
|
||||||
|
fillPath = _fbsdkCreateUpPointingBubbleWithRect(fillRect,
|
||||||
|
_arrowMidpoint, _arrowHeight,
|
||||||
|
kNUXCornerRadius - kNUXStrokeLineWidth);
|
||||||
|
gradientRect.origin.y -= _arrowHeight;
|
||||||
|
gradientRect.size.height += _arrowHeight;
|
||||||
|
} else {
|
||||||
|
outerPath = _fbsdkCreateDownPointingBubbleWithRect(outerRect,
|
||||||
|
_arrowMidpoint, _arrowHeight,
|
||||||
|
kNUXCornerRadius + kNUXStrokeLineWidth);
|
||||||
|
innerPath = _fbsdkCreateDownPointingBubbleWithRect(innerRect,
|
||||||
|
_arrowMidpoint, _arrowHeight,
|
||||||
|
kNUXCornerRadius);
|
||||||
|
fillPath = _fbsdkCreateDownPointingBubbleWithRect(fillRect,
|
||||||
|
_arrowMidpoint, _arrowHeight,
|
||||||
|
kNUXCornerRadius - kNUXStrokeLineWidth);
|
||||||
|
gradientRect.size.height += _arrowHeight;
|
||||||
|
}
|
||||||
|
self.layer.shadowPath = outerPath;
|
||||||
|
|
||||||
|
// This tooltip has two borders, so draw two strokes and a fill.
|
||||||
|
CGColorRef strokeColor = _innerStrokeColor.CGColor;
|
||||||
|
CGContextSaveGState(context);
|
||||||
|
CGContextSetStrokeColorWithColor(context, strokeColor);
|
||||||
|
CGContextSetLineWidth(context, kNUXStrokeLineWidth);
|
||||||
|
CGContextAddPath(context, innerPath);
|
||||||
|
CGContextStrokePath(context);
|
||||||
|
CGContextAddPath(context, fillPath);
|
||||||
|
CGContextClip(context);
|
||||||
|
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
|
||||||
|
CGGradientRef gradient = CGGradientCreateWithColors(rgbColorspace, (CFArrayRef)_gradientColors, nil);
|
||||||
|
CGColorSpaceRelease(rgbColorspace);
|
||||||
|
CGPoint start = CGPointMake(gradientRect.origin.x, gradientRect.origin.y);
|
||||||
|
CGPoint end = CGPointMake(gradientRect.origin.x, CGRectGetMaxY(gradientRect));
|
||||||
|
CGContextDrawLinearGradient(context, gradient, start, end, 0);
|
||||||
|
CGContextAddPath(context, crossCloseGlyphPath);
|
||||||
|
CGContextSetFillColorWithColor(context, _crossCloseGlyphColor.CGColor);
|
||||||
|
CGContextFillPath(context);
|
||||||
|
CGGradientRelease(gradient);
|
||||||
|
CGContextRestoreGState(context);
|
||||||
|
CFRelease(outerPath);
|
||||||
|
CFRelease(innerPath);
|
||||||
|
CFRelease(fillPath);
|
||||||
|
CFRelease(crossCloseGlyphPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Layout
|
||||||
|
|
||||||
|
- (void)layoutSubviews
|
||||||
|
{
|
||||||
|
[super layoutSubviews];
|
||||||
|
|
||||||
|
// We won't set the frame in layoutSubviews to avoid potential infinite loops.
|
||||||
|
// Frame is set in -presentInView:withArrowPosition:direction: method.
|
||||||
|
[self layoutSubviewsAndDetermineFrame];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGRect)layoutSubviewsAndDetermineFrame
|
||||||
|
{
|
||||||
|
// Compute the positioning of the arrow.
|
||||||
|
CGRect screenBounds = [UIScreen mainScreen].bounds;
|
||||||
|
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||||
|
if (!UIInterfaceOrientationIsPortrait(orientation)) {
|
||||||
|
screenBounds = CGRectMake(0, 0, screenBounds.size.height, screenBounds.size.width);
|
||||||
|
}
|
||||||
|
CGFloat arrowHalfWidth = _arrowHeight;
|
||||||
|
CGFloat arrowXPos = _positionInView.x - arrowHalfWidth;
|
||||||
|
arrowXPos = MAX(arrowXPos, kNUXSideCap + kNUXBubbleMargin);
|
||||||
|
arrowXPos = MIN(arrowXPos, screenBounds.size.width - kNUXBubbleMargin - kNUXSideCap - 2 * arrowHalfWidth);
|
||||||
|
_positionInView = CGPointMake(arrowXPos + arrowHalfWidth, _positionInView.y);
|
||||||
|
|
||||||
|
CGFloat arrowYMarginOffset = _pointingUp ? MAX(kNUXRectInset, _arrowHeight) : kNUXRectInset;
|
||||||
|
|
||||||
|
// Set the lock image frame.
|
||||||
|
CGFloat xPos = kNUXRectInset + _textPadding + kNUXStrokeLineWidth;
|
||||||
|
CGFloat yPos = arrowYMarginOffset + kNUXStrokeLineWidth + _textPadding;
|
||||||
|
|
||||||
|
// Set the text label frame.
|
||||||
|
_textLabel.frame = CGRectMake(xPos,
|
||||||
|
yPos + _verticalTextOffset, // sizing function may not return desired height exactly
|
||||||
|
CGRectGetWidth(_textLabel.bounds),
|
||||||
|
CGRectGetHeight(_textLabel.bounds));
|
||||||
|
|
||||||
|
// Determine the size of the nux bubble.
|
||||||
|
CGFloat bubbleHeight = CGRectGetHeight(_textLabel.bounds) + _verticalTextOffset + _textPadding * 2;
|
||||||
|
CGFloat crossGlyphWidth = 2 * kNUXFontSize;
|
||||||
|
CGFloat bubbleWidth = CGRectGetWidth(_textLabel.bounds) + _textPadding * 2 + kNUXStrokeLineWidth * 2 + crossGlyphWidth;
|
||||||
|
|
||||||
|
// Compute the widths to the left and right of the arrow.
|
||||||
|
_leftWidth = roundf(0.5f * (bubbleWidth - 2 * arrowHalfWidth));
|
||||||
|
_rightWidth = _leftWidth;
|
||||||
|
CGFloat originX = arrowXPos - _leftWidth;
|
||||||
|
if (originX < kNUXBubbleMargin) {
|
||||||
|
CGFloat xShift = kNUXBubbleMargin - originX;
|
||||||
|
originX += xShift;
|
||||||
|
_leftWidth -= xShift;
|
||||||
|
_rightWidth += xShift;
|
||||||
|
} else if (originX + bubbleWidth > screenBounds.size.width - kNUXBubbleMargin) {
|
||||||
|
CGFloat xShift = originX + bubbleWidth - (screenBounds.size.width - kNUXBubbleMargin);
|
||||||
|
originX -= xShift;
|
||||||
|
_leftWidth += xShift;
|
||||||
|
_rightWidth -= xShift;
|
||||||
|
}
|
||||||
|
|
||||||
|
_arrowMidpoint = _positionInView.x - originX + kNUXRectInset;
|
||||||
|
|
||||||
|
// Set the frame for the view.
|
||||||
|
CGFloat nuxWidth = bubbleWidth + 2 * kNUXRectInset;
|
||||||
|
CGFloat nuxHeight = bubbleHeight + kNUXRectInset + MAX(kNUXRectInset, _arrowHeight) + 2 * kNUXStrokeLineWidth;
|
||||||
|
CGFloat yOrigin = 0;
|
||||||
|
if (_pointingUp) {
|
||||||
|
yOrigin = _positionInView.y + kNUXPointMargin - MAX(0, kNUXRectInset - _arrowHeight);
|
||||||
|
} else {
|
||||||
|
yOrigin = _positionInView.y - nuxHeight - kNUXPointMargin + MAX(0, kNUXRectInset - _arrowHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CGRectMake(originX - kNUXRectInset,
|
||||||
|
yOrigin,
|
||||||
|
nuxWidth,
|
||||||
|
nuxHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Message & Tagline
|
||||||
|
|
||||||
|
- (void)setMessage:(NSString *)message tagline:(NSString *)tagline
|
||||||
|
{
|
||||||
|
message = message ?: @"";
|
||||||
|
// Ensure tagline is empty string or ends with space
|
||||||
|
tagline = tagline ?: @"";
|
||||||
|
if (tagline.length && ![tagline hasSuffix:@" "])
|
||||||
|
tagline = [tagline stringByAppendingString:@" "];
|
||||||
|
|
||||||
|
// Concatenate tagline & main message
|
||||||
|
message = [tagline stringByAppendingString:message];
|
||||||
|
|
||||||
|
NSRange fullRange = NSMakeRange(0, message.length);
|
||||||
|
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString: message];
|
||||||
|
|
||||||
|
UIFont *font=[UIFont boldSystemFontOfSize:kNUXFontSize];
|
||||||
|
[attrString addAttribute:NSFontAttributeName value:font range:fullRange];
|
||||||
|
[attrString addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:fullRange];
|
||||||
|
if (tagline.length) {
|
||||||
|
[attrString addAttribute:NSForegroundColorAttributeName value: FBSDKUIColorWithRGB(0x6D, 0x87, 0xC7) range:NSMakeRange(0, tagline.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
_textLabel.attributedText = attrString;
|
||||||
|
|
||||||
|
CGSize textLabelSize = [_textLabel sizeThatFits:CGSizeMake(_maximumTextWidth, MAXFLOAT)];
|
||||||
|
_textLabel.bounds = CGRectMake(0, 0, textLabelSize.width, textLabelSize.height);
|
||||||
|
self.frame = [self layoutSubviewsAndDetermineFrame];
|
||||||
|
[self setNeedsDisplay];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Auto Dismiss Timeout
|
||||||
|
|
||||||
|
- (void)scheduleAutomaticFadeout
|
||||||
|
{
|
||||||
|
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(scheduleFadeoutRespectingMinimumDisplayDuration) object:nil];
|
||||||
|
|
||||||
|
if (_displayDuration > 0.0 && self.superview) {
|
||||||
|
CFTimeInterval intervalAlreadyDisplaying = CFAbsoluteTimeGetCurrent() - _displayTime;
|
||||||
|
CFTimeInterval timeRemainingBeforeAutomaticFadeout = _displayDuration - intervalAlreadyDisplaying;
|
||||||
|
if (timeRemainingBeforeAutomaticFadeout > 0.0) {
|
||||||
|
[self performSelector:@selector(scheduleFadeoutRespectingMinimumDisplayDuration) withObject:nil afterDelay:timeRemainingBeforeAutomaticFadeout];
|
||||||
|
} else {
|
||||||
|
[self scheduleFadeoutRespectingMinimumDisplayDuration];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)scheduleFadeoutRespectingMinimumDisplayDuration
|
||||||
|
{
|
||||||
|
CFTimeInterval intervalAlreadyDisplaying = CFAbsoluteTimeGetCurrent() - _displayTime;
|
||||||
|
CFTimeInterval remainingDisplayTime = _minimumDisplayDuration - intervalAlreadyDisplaying;
|
||||||
|
if (remainingDisplayTime > 0.0) {
|
||||||
|
[self performSelector:@selector(dismiss) withObject:nil afterDelay:remainingDisplayTime];
|
||||||
|
} else {
|
||||||
|
[self dismiss];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cancelAllScheduledFadeOutMethods
|
||||||
|
{
|
||||||
|
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(scheduleFadeoutRespectingMinimumDisplayDuration) object:nil];
|
||||||
|
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(dismiss) object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
43
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKDeviceLoginCodeInfo+Internal.h
generated
Normal file
43
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKDeviceLoginCodeInfo+Internal.h
generated
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import "FBSDKDeviceLoginCodeInfo.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface FBSDKDeviceLoginCodeInfo ()
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Initializes a new instance
|
||||||
|
@param identifier the unique id for this login flow instance.
|
||||||
|
@param loginCode the short "user_code".
|
||||||
|
@param verificationURL the verification URL.
|
||||||
|
@param expirationDate expiration date.
|
||||||
|
@param pollingInterval time between polling.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithIdentifier:(NSString *)identifier
|
||||||
|
loginCode:(NSString *)loginCode
|
||||||
|
verificationURL:(NSURL *)verificationURL
|
||||||
|
expirationDate:(NSDate *)expirationDate
|
||||||
|
pollingInterval:(NSUInteger)pollingInterval NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
||||||
|
|
||||||
|
#import "FBSDKDeviceLoginManagerResult.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface FBSDKDeviceLoginManagerResult ()
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@abstract Initializes a new instance
|
||||||
|
@param token The token
|
||||||
|
@param cancelled Indicates if the flow was cancelled.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithToken:(nullable FBSDKAccessToken *)token
|
||||||
|
isCancelled:(BOOL)cancelled NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
39
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion+Internal.h
generated
Normal file
39
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion+Internal.h
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginCompletion.h"
|
||||||
|
|
||||||
|
@interface FBSDKLoginCompletionParameters ()
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *accessTokenString;
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSSet *permissions;
|
||||||
|
@property (nonatomic, copy) NSSet *declinedPermissions;
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *appID;
|
||||||
|
@property (nonatomic, copy) NSString *userID;
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSError *error;
|
||||||
|
|
||||||
|
@property (nonatomic, assign, getter=isSystemAccount) BOOL systemAccount;
|
||||||
|
@property (nonatomic, copy) NSDate *expirationDate;
|
||||||
|
@property (nonatomic, copy) NSDate *dataAccessExpirationDate;
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *challenge;
|
||||||
|
|
||||||
|
@end
|
||||||
104
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.h
generated
Normal file
104
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.h
generated
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@class FBSDKLoginManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Structured interface for accessing the parameters used to complete a log in request.
|
||||||
|
If \c accessTokenString is non-<code>nil</code>, the authentication succeeded. If \c error is
|
||||||
|
non-<code>nil</code> the request failed. If both are \c nil, the request was cancelled.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginCompletionParameters : NSObject
|
||||||
|
|
||||||
|
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||||
|
- (instancetype)initWithError:(NSError *)error;
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSString *accessTokenString;
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSSet *permissions;
|
||||||
|
@property (nonatomic, copy, readonly) NSSet *declinedPermissions;
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSString *appID;
|
||||||
|
@property (nonatomic, copy, readonly) NSString *userID;
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSError *error;
|
||||||
|
|
||||||
|
@property (nonatomic, readonly, getter=isSystemAccount) BOOL systemAccount;
|
||||||
|
@property (nonatomic, copy, readonly) NSDate *expirationDate;
|
||||||
|
@property (nonatomic, copy, readonly) NSDate *dataAccessExpirationDate;
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSString *challenge;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol FBSDKLoginCompleting
|
||||||
|
|
||||||
|
/**
|
||||||
|
Invoke \p handler with the login parameters derived from the authentication result.
|
||||||
|
See the implementing class's documentation for whether it completes synchronously or asynchronously.
|
||||||
|
*/
|
||||||
|
- (void)completeLogIn:(FBSDKLoginManager *)loginManager withHandler:(void(^)(FBSDKLoginCompletionParameters *parameters))handler;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark - Completers
|
||||||
|
|
||||||
|
/**
|
||||||
|
Extracts the log in completion parameters from the \p parameters dictionary,
|
||||||
|
which must contain the parsed result of the return URL query string.
|
||||||
|
|
||||||
|
The \c user_id key is first used to derive the User ID. If that fails, \c signed_request
|
||||||
|
is used.
|
||||||
|
|
||||||
|
Completion occurs synchronously.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginURLCompleter : NSObject <FBSDKLoginCompleting>
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
- (instancetype)initWithURLParameters:(NSDictionary *)parameters appID:(NSString *)appID NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
Requests the User ID, granted permissions and declined permissions from the server
|
||||||
|
using the given access token, which must occur before authentication can be completed.
|
||||||
|
|
||||||
|
Completion occurs asynchronously.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginSystemAccountCompleter : NSObject <FBSDKLoginCompleting>
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
- (instancetype)initWithTokenString:(NSString *)tokenString appID:(NSString *)appID NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an Accounts framework error in to an error or cancellation result
|
||||||
|
|
||||||
|
Completion occurs synchronously.
|
||||||
|
*/
|
||||||
|
@interface FBSDKLoginSystemAccountErrorCompleter : NSObject <FBSDKLoginCompleting>
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
- (instancetype)initWithError:(NSError *)accountStoreError permissions:(NSSet *)permissions NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
@end
|
||||||
317
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.m
generated
Normal file
317
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginCompletion.m
generated
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginCompletion+Internal.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLoginConstants.h"
|
||||||
|
#import "FBSDKLoginError.h"
|
||||||
|
#import "FBSDKLoginManager+Internal.h"
|
||||||
|
#import "FBSDKLoginUtility.h"
|
||||||
|
|
||||||
|
static void FBSDKLoginRequestMeAndPermissions(FBSDKLoginCompletionParameters *parameters, void(^completionBlock)(void))
|
||||||
|
{
|
||||||
|
__block NSUInteger pendingCount = 1;
|
||||||
|
void(^didCompleteBlock)(void) = ^{
|
||||||
|
if (--pendingCount == 0) {
|
||||||
|
completionBlock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NSString *tokenString = parameters.accessTokenString;
|
||||||
|
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
|
||||||
|
|
||||||
|
pendingCount++;
|
||||||
|
FBSDKGraphRequest *userIDRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
|
||||||
|
parameters:@{ @"fields" : @"id" }
|
||||||
|
tokenString:tokenString
|
||||||
|
HTTPMethod:nil
|
||||||
|
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||||
|
|
||||||
|
[connection addRequest:userIDRequest completionHandler:^(FBSDKGraphRequestConnection *requestConnection,
|
||||||
|
id result,
|
||||||
|
NSError *error) {
|
||||||
|
parameters.userID = result[@"id"];
|
||||||
|
if (error) {
|
||||||
|
parameters.error = error;
|
||||||
|
}
|
||||||
|
didCompleteBlock();
|
||||||
|
}];
|
||||||
|
|
||||||
|
pendingCount++;
|
||||||
|
FBSDKGraphRequest *permissionsRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/permissions"
|
||||||
|
parameters:@{@"fields":@""}
|
||||||
|
tokenString:tokenString
|
||||||
|
HTTPMethod:nil
|
||||||
|
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||||
|
|
||||||
|
[connection addRequest:permissionsRequest completionHandler:^(FBSDKGraphRequestConnection *requestConnection,
|
||||||
|
id result,
|
||||||
|
NSError *error) {
|
||||||
|
NSMutableSet *grantedPermissions = [NSMutableSet set];
|
||||||
|
NSMutableSet *declinedPermissions = [NSMutableSet set];
|
||||||
|
|
||||||
|
[FBSDKInternalUtility extractPermissionsFromResponse:result
|
||||||
|
grantedPermissions:grantedPermissions
|
||||||
|
declinedPermissions:declinedPermissions];
|
||||||
|
|
||||||
|
parameters.permissions = [grantedPermissions copy];
|
||||||
|
parameters.declinedPermissions = [declinedPermissions copy];
|
||||||
|
if (error) {
|
||||||
|
parameters.error = error;
|
||||||
|
}
|
||||||
|
didCompleteBlock();
|
||||||
|
}];
|
||||||
|
|
||||||
|
[connection start];
|
||||||
|
didCompleteBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation FBSDKLoginCompletionParameters
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
return [super init];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
if ((self = [self init]) != nil) {
|
||||||
|
self.error = error;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma mark - Completers
|
||||||
|
|
||||||
|
@implementation FBSDKLoginURLCompleter
|
||||||
|
{
|
||||||
|
FBSDKLoginCompletionParameters *_parameters;
|
||||||
|
id<NSObject> _observer;
|
||||||
|
BOOL _performExplicitFallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithURLParameters:(NSDictionary *)parameters appID:(NSString *)appID
|
||||||
|
{
|
||||||
|
if ((self = [super init]) != nil) {
|
||||||
|
_parameters = [[FBSDKLoginCompletionParameters alloc] init];
|
||||||
|
|
||||||
|
_parameters.accessTokenString = parameters[@"access_token"];
|
||||||
|
|
||||||
|
if (_parameters.accessTokenString.length > 0) {
|
||||||
|
[self setParametersWithDictionary:parameters appID:appID];
|
||||||
|
} else {
|
||||||
|
_parameters.accessTokenString = nil;
|
||||||
|
[self setErrorWithDictionary:parameters];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)completeLogIn:(FBSDKLoginManager *)loginManager withHandler:(void(^)(FBSDKLoginCompletionParameters *parameters))handler
|
||||||
|
{
|
||||||
|
if (_performExplicitFallback && loginManager.loginBehavior == FBSDKLoginBehaviorNative) {
|
||||||
|
// UIKit and iOS don't like an application opening a URL during a URL open callback, so
|
||||||
|
// we need to wait until *at least* the next turn of the run loop to open the URL to
|
||||||
|
// perform the browser log in behavior. However we also need to wait for the application
|
||||||
|
// to become active so FBSDKApplicationDelegate doesn't erroneously call back the URL
|
||||||
|
// opener before the URL has been opened.
|
||||||
|
if ([FBSDKApplicationDelegate sharedInstance].isActive) {
|
||||||
|
// The application is active so there's no need to wait.
|
||||||
|
[loginManager logInWithBehavior:FBSDKLoginBehaviorBrowser];
|
||||||
|
} else {
|
||||||
|
// use the block version to guarantee there's a strong reference to self
|
||||||
|
_observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^ (NSNotification *notification) {
|
||||||
|
[self attemptBrowserLogIn:loginManager];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_parameters.accessTokenString && !_parameters.userID) {
|
||||||
|
void(^handlerCopy)(FBSDKLoginCompletionParameters *) = [handler copy];
|
||||||
|
FBSDKLoginRequestMeAndPermissions(_parameters, ^{
|
||||||
|
handlerCopy(self->_parameters);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
handler(_parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setParametersWithDictionary:(NSDictionary *)parameters appID:(NSString *)appID
|
||||||
|
{
|
||||||
|
NSString *grantedPermissionsString = parameters[@"granted_scopes"];
|
||||||
|
NSString *declinedPermissionsString = parameters[@"denied_scopes"];
|
||||||
|
|
||||||
|
NSString *signedRequest = parameters[@"signed_request"];
|
||||||
|
NSString *userID = parameters[@"user_id"];
|
||||||
|
|
||||||
|
// check the string length so that we assign an empty set rather than a set with an empty string
|
||||||
|
_parameters.permissions = (grantedPermissionsString.length > 0)
|
||||||
|
? [NSSet setWithArray:[grantedPermissionsString componentsSeparatedByString:@","]]
|
||||||
|
: [NSSet set];
|
||||||
|
_parameters.declinedPermissions = (declinedPermissionsString.length > 0)
|
||||||
|
? [NSSet setWithArray:[declinedPermissionsString componentsSeparatedByString:@","]]
|
||||||
|
: [NSSet set];
|
||||||
|
|
||||||
|
_parameters.appID = appID;
|
||||||
|
|
||||||
|
if (userID.length == 0 && signedRequest.length > 0) {
|
||||||
|
_parameters.userID = [FBSDKLoginUtility userIDFromSignedRequest:signedRequest];
|
||||||
|
} else {
|
||||||
|
_parameters.userID = userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *expirationDateString = parameters[@"expires"] ?: parameters[@"expires_at"];
|
||||||
|
NSDate *expirationDate = [NSDate distantFuture];
|
||||||
|
if (expirationDateString && expirationDateString.doubleValue > 0) {
|
||||||
|
expirationDate = [NSDate dateWithTimeIntervalSince1970:expirationDateString.doubleValue];
|
||||||
|
} else if (parameters[@"expires_in"] && [parameters[@"expires_in"] integerValue] > 0) {
|
||||||
|
expirationDate = [NSDate dateWithTimeIntervalSinceNow:[parameters[@"expires_in"] integerValue]];
|
||||||
|
}
|
||||||
|
_parameters.expirationDate = expirationDate;
|
||||||
|
|
||||||
|
NSDate *dataAccessExpirationDate = [NSDate distantFuture];
|
||||||
|
if (parameters[@"data_access_expiration_time"] && [parameters[@"data_access_expiration_time"] integerValue] > 0) {
|
||||||
|
dataAccessExpirationDate = [NSDate dateWithTimeIntervalSince1970:[parameters[@"data_access_expiration_time"] integerValue]];
|
||||||
|
}
|
||||||
|
_parameters.dataAccessExpirationDate = dataAccessExpirationDate;
|
||||||
|
|
||||||
|
NSError *error = nil;
|
||||||
|
NSDictionary *state = [FBSDKInternalUtility objectForJSONString:parameters[@"state"] error:&error];
|
||||||
|
_parameters.challenge = [FBSDKUtility URLDecode:state[@"challenge"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setErrorWithDictionary:(NSDictionary *)parameters
|
||||||
|
{
|
||||||
|
NSString *legacyErrorReason = parameters[@"error"];
|
||||||
|
|
||||||
|
if ([legacyErrorReason isEqualToString:@"service_disabled_use_browser"] ||
|
||||||
|
[legacyErrorReason isEqualToString:@"service_disabled"]) {
|
||||||
|
_performExplicitFallback = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if error is nil, then this should be processed as a cancellation unless
|
||||||
|
// _performExplicitFallback is set to YES and the log in behavior is Native.
|
||||||
|
_parameters.error = [NSError fbErrorFromReturnURLParameters:parameters];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)attemptBrowserLogIn:(FBSDKLoginManager *)loginManager {
|
||||||
|
if (_observer != nil) {
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:_observer];
|
||||||
|
_observer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([FBSDKApplicationDelegate sharedInstance].isActive) {
|
||||||
|
[loginManager logInWithBehavior:FBSDKLoginBehaviorBrowser];
|
||||||
|
} else {
|
||||||
|
// The application is active but due to notification ordering the FBSDKApplicationDelegate
|
||||||
|
// doesn't know it yet. Wait one more turn of the run loop.
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self attemptBrowserLogIn:loginManager];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginSystemAccountCompleter
|
||||||
|
{
|
||||||
|
FBSDKLoginCompletionParameters *_parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithTokenString:(NSString *)tokenString appID:(NSString *)appID
|
||||||
|
{
|
||||||
|
if ((self = [super init]) != nil) {
|
||||||
|
_parameters = [[FBSDKLoginCompletionParameters alloc] init];
|
||||||
|
|
||||||
|
_parameters.accessTokenString = tokenString;
|
||||||
|
_parameters.appID = appID;
|
||||||
|
|
||||||
|
_parameters.systemAccount = YES;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)completeLogIn:(FBSDKLoginManager *)loginManager withHandler:(void(^)(FBSDKLoginCompletionParameters *parameters))handler
|
||||||
|
{
|
||||||
|
void(^handlerCopy)(FBSDKLoginCompletionParameters *) = [handler copy];
|
||||||
|
FBSDKLoginRequestMeAndPermissions(_parameters, ^{
|
||||||
|
// Transform the FBSDKCoreKit error in to an FBSDKLoginKit error, if necessary. This specializes
|
||||||
|
// the graph errors in to User Checkpointed, Password Changed or Unconfirmed User.
|
||||||
|
//
|
||||||
|
// It's possible the graph error has a value set for NSRecoveryAttempterErrorKey but we don't
|
||||||
|
// have any login-specific attempter to provide since system auth succeeded and the error is a
|
||||||
|
// graph API error.
|
||||||
|
NSError *serverError = self->_parameters.error;
|
||||||
|
NSError *error = [NSError fbErrorFromServerError:serverError];
|
||||||
|
if (error != nil) {
|
||||||
|
// In the event the user's password changed the Accounts framework will still return
|
||||||
|
// an access token but API calls will fail. Clear the access token from the result
|
||||||
|
// and use the special-case System Password changed error, which has different text
|
||||||
|
// to display to the user.
|
||||||
|
if (error.code == FBSDKLoginErrorPasswordChanged) {
|
||||||
|
[FBSDKSystemAccountStoreAdapter sharedInstance].forceBlockingRenew = YES;
|
||||||
|
|
||||||
|
self->_parameters.accessTokenString = nil;
|
||||||
|
self->_parameters.appID = nil;
|
||||||
|
|
||||||
|
error = [NSError fbErrorForSystemPasswordChange:serverError];
|
||||||
|
}
|
||||||
|
|
||||||
|
self->_parameters.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
handlerCopy(self->_parameters);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKLoginSystemAccountErrorCompleter
|
||||||
|
{
|
||||||
|
FBSDKLoginCompletionParameters *_parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithError:(NSError *)accountStoreError permissions:(NSSet *)permissions
|
||||||
|
{
|
||||||
|
if ((self = [super init]) != nil) {
|
||||||
|
_parameters = [[FBSDKLoginCompletionParameters alloc] init];
|
||||||
|
|
||||||
|
NSError *error = [NSError fbErrorForSystemAccountStoreError:accountStoreError];
|
||||||
|
if (error != nil) {
|
||||||
|
_parameters.error = error;
|
||||||
|
} else {
|
||||||
|
// The lack of an error indicates the user declined permissions
|
||||||
|
_parameters.declinedPermissions = permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
_parameters.systemAccount = YES;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)completeLogIn:(FBSDKLoginManager *)loginManager withHandler:(void(^)(FBSDKLoginCompletionParameters *parameters))handler
|
||||||
|
{
|
||||||
|
handler(_parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
36
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginError.h
generated
Normal file
36
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginError.h
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginConstants.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface NSError (FBSDKLoginError)
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorForFailedLoginWithCode:(FBSDKLoginError)code;
|
||||||
|
+ (NSError *)fbErrorForSystemAccountStoreError:(NSError *)accountStoreError;
|
||||||
|
+ (NSError *)fbErrorForSystemPasswordChange:(NSError *)innerError;
|
||||||
|
|
||||||
|
+ (nullable NSError *)fbErrorFromReturnURLParameters:(NSDictionary<NSString *, id> *)parameters;
|
||||||
|
+ (nullable NSError *)fbErrorFromServerError:(NSError *)serverError;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
248
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginError.m
generated
Normal file
248
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginError.m
generated
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginError.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
#ifndef NS_ERROR_ENUM
|
||||||
|
#define NS_ERROR_ENUM(_domain, _name) \
|
||||||
|
enum _name: NSInteger _name; \
|
||||||
|
enum __attribute__((ns_error_domain(_domain))) _name: NSInteger
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef NS_ERROR_ENUM(FBSDKLoginErrorDomain, FBSDKLoginErrorSubcode)
|
||||||
|
{
|
||||||
|
FBSDKLoginErrorSubcodeUserCheckpointed = 459,
|
||||||
|
FBSDKLoginErrorSubcodePasswordChanged = 460,
|
||||||
|
FBSDKLoginErrorSubcodeUnconfirmedUser = 464,
|
||||||
|
};
|
||||||
|
|
||||||
|
@implementation NSError (FBSDKLoginError)
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorForFailedLoginWithCode:(FBSDKLoginError)code
|
||||||
|
{
|
||||||
|
return [self fbErrorForFailedLoginWithCode:code innerError:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorForFailedLoginWithCode:(FBSDKLoginError)code
|
||||||
|
innerError:(NSError *)innerError
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, id> *userInfo = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:innerError forKey:NSUnderlyingErrorKey];
|
||||||
|
|
||||||
|
NSString *errorDomain = FBSDKLoginErrorDomain;
|
||||||
|
NSString *localizedDescription = nil;
|
||||||
|
|
||||||
|
switch ((NSInteger)code) {
|
||||||
|
case FBSDKErrorNetwork:
|
||||||
|
errorDomain = FBSDKErrorDomain;
|
||||||
|
localizedDescription =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginError.SystemAccount.Network", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Unable to connect to Facebook. Check your network connection and try again.",
|
||||||
|
@"The user facing error message when the Accounts framework encounters a network error.");
|
||||||
|
break;
|
||||||
|
case FBSDKLoginErrorUserCheckpointed:
|
||||||
|
localizedDescription =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginError.SystemAccount.UserCheckpointed", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"You cannot log in to apps at this time. Please log in to www.facebook.com and follow the instructions given.",
|
||||||
|
@"The user facing error message when the Facebook account signed in to the Accounts framework has been checkpointed.");
|
||||||
|
break;
|
||||||
|
case FBSDKLoginErrorUnconfirmedUser:
|
||||||
|
localizedDescription =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginError.SystemAccount.UnconfirmedUser", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Your account is not confirmed. Please log in to www.facebook.com and follow the instructions given.",
|
||||||
|
@"The user facing error message when the Facebook account signed in to the Accounts framework becomes unconfirmed.");
|
||||||
|
break;
|
||||||
|
case FBSDKLoginErrorSystemAccountAppDisabled:
|
||||||
|
localizedDescription =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginError.SystemAccount.Disabled", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Access has not been granted to the Facebook account. Verify device settings.",
|
||||||
|
@"The user facing error message when the app slider has been disabled and login fails.");
|
||||||
|
break;
|
||||||
|
case FBSDKLoginErrorSystemAccountUnavailable:
|
||||||
|
localizedDescription =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginError.SystemAccount.Unavailable", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"The Facebook account has not been configured on the device.",
|
||||||
|
@"The user facing error message when the device Facebook account is unavailable and login fails.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:localizedDescription forKey:NSLocalizedDescriptionKey];
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:localizedDescription forKey:FBSDKErrorLocalizedDescriptionKey];
|
||||||
|
|
||||||
|
return [NSError errorWithDomain:errorDomain
|
||||||
|
code:code
|
||||||
|
userInfo:userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorForSystemAccountStoreError:(NSError *)accountStoreError
|
||||||
|
{
|
||||||
|
NSError *err = nil;
|
||||||
|
BOOL cancellation = NO;
|
||||||
|
|
||||||
|
if ([accountStoreError.domain isEqualToString:FBSDKLoginErrorDomain] ||
|
||||||
|
[accountStoreError.domain isEqualToString:FBSDKErrorDomain]) {
|
||||||
|
// If the requestAccess call results in a Facebook error, surface it as a top-level
|
||||||
|
// error. This implies it is not the typical user "disallows" case.
|
||||||
|
err = accountStoreError;
|
||||||
|
} else if ([accountStoreError.domain isEqualToString:@"com.apple.accounts"] && accountStoreError.code == 7) {
|
||||||
|
err = [self fbErrorWithSystemAccountStoreDeniedError:accountStoreError isCancellation:&cancellation];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err == nil && !cancellation) {
|
||||||
|
// create an error object with additional info regarding failed login
|
||||||
|
NSInteger errorCode = FBSDKLoginErrorSystemAccountUnavailable;
|
||||||
|
|
||||||
|
NSString *errorDomain = accountStoreError.domain;
|
||||||
|
if ([errorDomain isEqualToString:NSURLErrorDomain] ||
|
||||||
|
[errorDomain isEqualToString:@"kCFErrorDomainCFNetwork"]) {
|
||||||
|
errorCode = FBSDKErrorNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = [self fbErrorForFailedLoginWithCode:errorCode
|
||||||
|
innerError:accountStoreError];
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorForSystemPasswordChange:(NSError *)innerError
|
||||||
|
{
|
||||||
|
NSString *failureReasonAndDescription =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LoginError.SystemAccount.PasswordChange", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Your Facebook password has changed. To confirm your password, open Settings > Facebook and tap your name.",
|
||||||
|
@"The user facing error message when the device Facebook account password is incorrect and login fails.");
|
||||||
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
failureReasonAndDescription, FBSDKErrorLocalizedDescriptionKey,
|
||||||
|
failureReasonAndDescription, NSLocalizedDescriptionKey,
|
||||||
|
nil];
|
||||||
|
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:innerError forKey:NSUnderlyingErrorKey];
|
||||||
|
|
||||||
|
return [NSError errorWithDomain:FBSDKLoginErrorDomain
|
||||||
|
code:FBSDKLoginErrorPasswordChanged
|
||||||
|
userInfo:userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorFromReturnURLParameters:(NSDictionary *)parameters
|
||||||
|
{
|
||||||
|
NSError *error = nil;
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *userInfo = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:parameters[@"error_message"] forKey:FBSDKErrorDeveloperMessageKey];
|
||||||
|
|
||||||
|
if (userInfo.count > 0) {
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:parameters[@"error"] forKey:FBSDKErrorDeveloperMessageKey];
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:parameters[@"error_code"] forKey:FBSDKGraphRequestErrorGraphErrorCodeKey];
|
||||||
|
|
||||||
|
if (!userInfo[FBSDKErrorDeveloperMessageKey]) {
|
||||||
|
[FBSDKInternalUtility dictionary:userInfo setObject:parameters[@"error_reason"] forKey:FBSDKErrorDeveloperMessageKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
userInfo[FBSDKGraphRequestErrorKey] = @(FBSDKGraphRequestErrorOther);
|
||||||
|
|
||||||
|
error = [NSError errorWithDomain:FBSDKErrorDomain
|
||||||
|
code:FBSDKErrorGraphRequestGraphAPI
|
||||||
|
userInfo:userInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorFromServerError:(NSError *)serverError
|
||||||
|
{
|
||||||
|
NSError *loginError = nil;
|
||||||
|
|
||||||
|
if ([serverError.domain isEqualToString:FBSDKErrorDomain]) {
|
||||||
|
NSDictionary *response = [FBSDKTypeUtility dictionaryValue:serverError.userInfo[FBSDKGraphRequestErrorParsedJSONResponseKey]];
|
||||||
|
NSDictionary *body = [FBSDKTypeUtility dictionaryValue:response[@"body"]];
|
||||||
|
NSDictionary *error = [FBSDKTypeUtility dictionaryValue:body[@"error"]];
|
||||||
|
NSInteger subcode = [FBSDKTypeUtility integerValue:error[@"error_subcode"]];
|
||||||
|
|
||||||
|
switch (subcode) {
|
||||||
|
case FBSDKLoginErrorSubcodeUserCheckpointed:
|
||||||
|
loginError = [self fbErrorForFailedLoginWithCode:FBSDKLoginErrorUserCheckpointed
|
||||||
|
innerError:serverError];
|
||||||
|
break;
|
||||||
|
case FBSDKLoginErrorSubcodePasswordChanged:
|
||||||
|
loginError = [self fbErrorForFailedLoginWithCode:FBSDKLoginErrorPasswordChanged
|
||||||
|
innerError:serverError];
|
||||||
|
break;
|
||||||
|
case FBSDKLoginErrorSubcodeUnconfirmedUser:
|
||||||
|
loginError = [self fbErrorForFailedLoginWithCode:FBSDKLoginErrorUnconfirmedUser
|
||||||
|
innerError:serverError];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return loginError;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSError *)fbErrorWithSystemAccountStoreDeniedError:(NSError *)accountStoreError
|
||||||
|
isCancellation:(BOOL *)cancellation
|
||||||
|
{
|
||||||
|
// The Accounts framework returns an ACErrorPermissionDenied error for both user denied errors,
|
||||||
|
// Facebook denied errors, and other things. Unfortunately examining the contents of the
|
||||||
|
// description is the only means available to determine the reason for the error.
|
||||||
|
NSString *description = accountStoreError.userInfo[NSLocalizedDescriptionKey];
|
||||||
|
NSError *err = nil;
|
||||||
|
|
||||||
|
if (description) {
|
||||||
|
// If a parenthetical error code exists, map it ot a Facebook server error
|
||||||
|
FBSDKLoginError errorCode = FBSDKLoginErrorReserved;
|
||||||
|
if ([description rangeOfString:@"(459)"].location != NSNotFound) {
|
||||||
|
// The Facebook server could not fulfill this access request: Error validating access token:
|
||||||
|
// You cannot access the app till you log in to www.facebook.com and follow the instructions given. (459)
|
||||||
|
|
||||||
|
// The OAuth endpoint directs people to www.facebook.com when an account has been
|
||||||
|
// checkpointed. If the web address is present, assume it's due to a checkpoint.
|
||||||
|
errorCode = FBSDKLoginErrorUserCheckpointed;
|
||||||
|
} else if ([description rangeOfString:@"(452)"].location != NSNotFound ||
|
||||||
|
[description rangeOfString:@"(460)"].location != NSNotFound) {
|
||||||
|
// The Facebook server could not fulfill this access request: Error validating access token:
|
||||||
|
// Session does not match current stored session. This may be because the user changed the password since
|
||||||
|
// the time the session was created or Facebook has changed the session for security reasons. (452)or(460)
|
||||||
|
|
||||||
|
// If the login failed due to the session changing, maybe it's due to the password
|
||||||
|
// changing. Direct the user to update the password in the Settings > Facebook.
|
||||||
|
err = [self fbErrorForSystemPasswordChange:accountStoreError];
|
||||||
|
} else if ([description rangeOfString:@"(464)"].location != NSNotFound) {
|
||||||
|
// The Facebook server could not fulfill this access request: Error validating access token:
|
||||||
|
// Sessions for the user are not allowed because the user is not a confirmed user. (464)
|
||||||
|
errorCode = FBSDKLoginErrorUnconfirmedUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCode != FBSDKLoginErrorReserved) {
|
||||||
|
err = [self fbErrorForFailedLoginWithCode:errorCode];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If there is no description, assume this is a user cancellation. No error object is
|
||||||
|
// returned for a cancellation.
|
||||||
|
if (cancellation != NULL) {
|
||||||
|
*cancellation = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
24
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginKit+Internal.h
generated
Normal file
24
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginKit+Internal.h
generated
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginKit.h>
|
||||||
|
|
||||||
|
#import "FBSDKLoginCompletion+Internal.h"
|
||||||
|
#import "FBSDKLoginError.h"
|
||||||
|
#import "FBSDKLoginManager+Internal.h"
|
||||||
|
#import "FBSDKLoginUtility.h"
|
||||||
81
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManager+Internal.h
generated
Normal file
81
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManager+Internal.h
generated
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginManager.h>
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
@class FBSDKAccessToken;
|
||||||
|
@class FBSDKLoginCompletionParameters;
|
||||||
|
|
||||||
|
@interface FBSDKLoginManagerSystemAccountState : NSObject
|
||||||
|
@property (nonatomic, assign) BOOL didShowDialog;
|
||||||
|
@property (nonatomic, getter=isReauthorize) BOOL reauthorize;
|
||||||
|
@property (nonatomic, getter=isUnTOSedDevice) BOOL unTOSedDevice;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface FBSDKLoginManager ()
|
||||||
|
@property (nonatomic, weak) UIViewController *fromViewController;
|
||||||
|
@property (nonatomic, readonly) NSSet *requestedPermissions;
|
||||||
|
|
||||||
|
- (void)completeAuthentication:(FBSDKLoginCompletionParameters *)parameters expectChallenge:(BOOL)expectChallenge;
|
||||||
|
|
||||||
|
// available to internal types to trigger login without checking read/publish mixtures.
|
||||||
|
- (void)logInWithPermissions:(NSSet *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler;
|
||||||
|
- (void)logInWithBehavior:(FBSDKLoginBehavior)loginBehavior;
|
||||||
|
|
||||||
|
// made available for testing only
|
||||||
|
- (NSDictionary *)logInParametersWithPermissions:(NSSet *)permissions serverConfiguration:(FBSDKServerConfiguration *)serverConfiguration;
|
||||||
|
// made available for testing only
|
||||||
|
- (void)validateReauthentication:(FBSDKAccessToken *)currentToken withResult:(FBSDKLoginManagerLoginResult *)loginResult;
|
||||||
|
|
||||||
|
// for testing only
|
||||||
|
- (void)setHandler:(FBSDKLoginManagerRequestTokenHandler)handler;
|
||||||
|
// for testing only
|
||||||
|
- (void)setRequestedPermissions:(NSSet *)requestedPermissions;
|
||||||
|
// for testing only
|
||||||
|
- (NSString *)loadExpectedChallenge;
|
||||||
|
@end
|
||||||
|
|
||||||
|
// the category is made available for testing only
|
||||||
|
@interface FBSDKLoginManager (Native) <FBSDKURLOpening>
|
||||||
|
|
||||||
|
- (void)performNativeLogInWithParameters:(NSDictionary *)loginParams handler:(void(^)(BOOL, NSError*))handler;
|
||||||
|
- (void)performBrowserLogInWithParameters:(NSDictionary *)loginParams handler:(void(^)(BOOL, NSString *,NSError*))handler;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
// the category is made available for testing only
|
||||||
|
@interface FBSDKLoginManager (Accounts)
|
||||||
|
|
||||||
|
- (void)beginSystemLogIn;
|
||||||
|
- (void)performSystemLogIn;
|
||||||
|
- (void)continueSystemLogInWithTokenString:(NSString *)oauthToken error:(NSError *)accountStoreError state:(FBSDKLoginManagerSystemAccountState *)state;
|
||||||
|
|
||||||
|
- (void)fallbackToNativeBehavior;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
// the category is made available for testing only
|
||||||
|
@interface FBSDKLoginManager (WebDialog) <FBSDKWebDialogDelegate>
|
||||||
|
|
||||||
|
- (void)performWebLogInWithParameters:(NSDictionary *)loginParams handler:(void(^)(BOOL, NSError*))handler;
|
||||||
|
|
||||||
|
@end
|
||||||
48
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.h
generated
Normal file
48
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.h
generated
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginManager+Internal.h"
|
||||||
|
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKLoginManagerLoggerAuthMethod_Native;
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKLoginManagerLoggerAuthMethod_Browser;
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKLoginManagerLoggerAuthMethod_System;
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKLoginManagerLoggerAuthMethod_Webview;
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKLoginManagerLoggerAuthMethod_SFVC;
|
||||||
|
|
||||||
|
|
||||||
|
@interface FBSDKLoginManagerLogger : NSObject
|
||||||
|
+ (FBSDKLoginManagerLogger *)loggerFromParameters:(NSDictionary *)parameters;
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
- (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
- (instancetype)initWithLoggingToken:(NSString *)loggingToken;
|
||||||
|
|
||||||
|
// this must not retain loginManager - only used to conveniently grab various properties to log.
|
||||||
|
- (void)startSessionForLoginManager:(FBSDKLoginManager *)loginManager;
|
||||||
|
- (void)endSession;
|
||||||
|
|
||||||
|
- (void)startAuthMethod:(NSString *)authMethod;
|
||||||
|
- (void)endLoginWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error;
|
||||||
|
|
||||||
|
- (NSDictionary *)parametersWithTimeStampAndClientState:(NSDictionary *)loginParams forAuthMethod:(NSString *)authMethod;
|
||||||
|
- (void)willAttemptAppSwitchingBehavior;
|
||||||
|
- (void)systemAuthDidShowDialog:(BOOL)didShowDialog isUnTOSedDevice:(BOOL)isUnTOSedDevice;
|
||||||
|
|
||||||
|
- (void)logNativeAppDialogResult:(BOOL)result dialogDuration:(NSTimeInterval)dialogDuration;
|
||||||
|
@end
|
||||||
309
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.m
generated
Normal file
309
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginManagerLogger.m
generated
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginManagerLogger.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLoginError.h"
|
||||||
|
#import "FBSDKLoginManagerLoginResult+Internal.h"
|
||||||
|
#import "FBSDKLoginUtility.h"
|
||||||
|
|
||||||
|
NSString *const FBSDKLoginManagerLoggerAuthMethod_Native = @"fb_application_web_auth";
|
||||||
|
NSString *const FBSDKLoginManagerLoggerAuthMethod_Browser = @"browser_auth";
|
||||||
|
NSString *const FBSDKLoginManagerLoggerAuthMethod_System = @"integrated_auth";
|
||||||
|
NSString *const FBSDKLoginManagerLoggerAuthMethod_Webview = @"fallback_auth";
|
||||||
|
NSString *const FBSDKLoginManagerLoggerAuthMethod_SFVC = @"sfvc_auth";
|
||||||
|
|
||||||
|
static NSString *const FBSDKLoginManagerLoggingClientStateKey = @"state";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggingClientStateIsClientState = @"com.facebook.sdk_client_state";
|
||||||
|
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamIdentifierKey = @"0_auth_logger_id";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamTimestampKey = @"1_timestamp_ms";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamResultKey = @"2_result";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamAuthMethodKey = @"3_method";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamErrorCodeKey = @"4_error_code";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamErrorMessageKey = @"5_error_message";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamExtrasKey = @"6_extras";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerParamLoggingTokenKey = @"7_logging_token";
|
||||||
|
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerValueEmpty = @"";
|
||||||
|
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerResultSuccessString = @"success";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerResultCancelString = @"cancelled";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerResultErrorString = @"error";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerResultSkippedString = @"skipped";
|
||||||
|
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerTryNative = @"tryFBAppAuth";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerTryBrowser = @"trySafariAuth";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerTrySystemAccount = @"tryIntegratedAuth";
|
||||||
|
static NSString *const FBSDKLoginManagerLoggerTryWebView = @"tryFallback";
|
||||||
|
|
||||||
|
@implementation FBSDKLoginManagerLogger
|
||||||
|
{
|
||||||
|
@private
|
||||||
|
NSString *_identifier;
|
||||||
|
NSMutableDictionary *_extras;
|
||||||
|
|
||||||
|
NSString *_lastResult;
|
||||||
|
NSError *_lastError;
|
||||||
|
|
||||||
|
NSString *_authMethod;
|
||||||
|
NSString *_loggingToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (FBSDKLoginManagerLogger *)loggerFromParameters:(NSDictionary *)parameters
|
||||||
|
{
|
||||||
|
NSDictionary *clientState = [FBSDKInternalUtility objectForJSONString:parameters[FBSDKLoginManagerLoggingClientStateKey] error:NULL];
|
||||||
|
|
||||||
|
id isClientState = clientState[FBSDKLoginManagerLoggingClientStateIsClientState];
|
||||||
|
if ([isClientState isKindOfClass:[NSNumber class]] && [isClientState boolValue]) {
|
||||||
|
FBSDKLoginManagerLogger *logger = [[self alloc] initWithLoggingToken:nil];
|
||||||
|
if (logger != nil) {
|
||||||
|
logger->_identifier = clientState[FBSDKLoginManagerLoggerParamIdentifierKey];
|
||||||
|
logger->_authMethod = clientState[FBSDKLoginManagerLoggerParamAuthMethodKey];
|
||||||
|
logger->_loggingToken = clientState[FBSDKLoginManagerLoggerParamLoggingTokenKey];
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithLoggingToken:(NSString *)loggingToken
|
||||||
|
{
|
||||||
|
if ((self = [super init]) != nil) {
|
||||||
|
_identifier = [NSUUID UUID].UUIDString;
|
||||||
|
_extras = [NSMutableDictionary dictionary];
|
||||||
|
_loggingToken = [loggingToken copy];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startSessionForLoginManager:(FBSDKLoginManager *)loginManager
|
||||||
|
{
|
||||||
|
BOOL isReauthorize = ([FBSDKAccessToken currentAccessToken] != nil);
|
||||||
|
BOOL willTryNative = NO;
|
||||||
|
BOOL willTryBrowser = NO;
|
||||||
|
BOOL willTrySystemAccount = NO;
|
||||||
|
BOOL willTryWebView = NO;
|
||||||
|
NSString *behaviorString = nil;
|
||||||
|
|
||||||
|
switch (loginManager.loginBehavior) {
|
||||||
|
case FBSDKLoginBehaviorNative:
|
||||||
|
willTryNative = YES;
|
||||||
|
willTryBrowser = YES;
|
||||||
|
behaviorString = @"FBSDKLoginBehaviorNative";
|
||||||
|
break;
|
||||||
|
case FBSDKLoginBehaviorBrowser:
|
||||||
|
willTryBrowser = YES;
|
||||||
|
behaviorString = @"FBSDKLoginBehaviorBrowser";
|
||||||
|
break;
|
||||||
|
case FBSDKLoginBehaviorSystemAccount:
|
||||||
|
willTryNative = YES;
|
||||||
|
willTryBrowser = YES;
|
||||||
|
willTrySystemAccount = YES;
|
||||||
|
behaviorString = @"FBSDKLoginBehaviorSystemAccount";
|
||||||
|
break;
|
||||||
|
case FBSDKLoginBehaviorWeb:
|
||||||
|
willTryWebView = YES;
|
||||||
|
behaviorString = @"FBSDKLoginBehaviorWeb";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_extras addEntriesFromDictionary:@{
|
||||||
|
FBSDKLoginManagerLoggerTryNative : @(willTryNative),
|
||||||
|
FBSDKLoginManagerLoggerTryBrowser : @(willTryBrowser),
|
||||||
|
FBSDKLoginManagerLoggerTrySystemAccount : @(willTrySystemAccount),
|
||||||
|
FBSDKLoginManagerLoggerTryWebView : @(willTryWebView),
|
||||||
|
@"isReauthorize" : @(isReauthorize),
|
||||||
|
@"login_behavior" : behaviorString,
|
||||||
|
@"default_audience" : [FBSDKLoginUtility stringForAudience:loginManager.defaultAudience],
|
||||||
|
@"permissions" : [loginManager.requestedPermissions.allObjects componentsJoinedByString:@","] ?: @""
|
||||||
|
}];
|
||||||
|
|
||||||
|
[self logEvent:FBSDKAppEventNameFBSessionAuthStart params:[self _parametersForNewEvent]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)endSession
|
||||||
|
{
|
||||||
|
[self logEvent:FBSDKAppEventNameFBSessionAuthEnd result:_lastResult error:_lastError];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startAuthMethod:(NSString *)authMethod
|
||||||
|
{
|
||||||
|
_authMethod = [authMethod copy];
|
||||||
|
[self logEvent:FBSDKAppEventNameFBSessionAuthMethodStart params:[self _parametersForNewEvent]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)endLoginWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
|
||||||
|
{
|
||||||
|
NSString *resultString = @"";
|
||||||
|
|
||||||
|
if (error != nil) {
|
||||||
|
resultString = FBSDKLoginManagerLoggerResultErrorString;
|
||||||
|
} else if (result.isCancelled) {
|
||||||
|
resultString = FBSDKLoginManagerLoggerResultCancelString;
|
||||||
|
} else if (result.isSkipped) {
|
||||||
|
resultString = FBSDKLoginManagerLoggerResultSkippedString;
|
||||||
|
} else if (result.token) {
|
||||||
|
resultString = FBSDKLoginManagerLoggerResultSuccessString;
|
||||||
|
if (result.declinedPermissions.count) {
|
||||||
|
_extras[@"declined_permissions"] = [result.declinedPermissions.allObjects componentsJoinedByString:@","];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastResult = resultString;
|
||||||
|
_lastError = error;
|
||||||
|
[_extras addEntriesFromDictionary:result.loggingExtras];
|
||||||
|
|
||||||
|
[self logEvent:FBSDKAppEventNameFBSessionAuthMethodEnd result:resultString error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)parametersWithTimeStampAndClientState:(NSDictionary *)loginParams forAuthMethod:(NSString *)authMethod
|
||||||
|
{
|
||||||
|
NSMutableDictionary *params = [loginParams mutableCopy];
|
||||||
|
|
||||||
|
NSTimeInterval timeValue = (NSTimeInterval)FBSDKMonotonicTimeGetCurrentSeconds();
|
||||||
|
NSString *e2eTimestampString = [FBSDKInternalUtility JSONStringForObject:@{ @"init" : @(timeValue) }
|
||||||
|
error:NULL
|
||||||
|
invalidObjectHandler:NULL];
|
||||||
|
params[@"e2e"] = e2eTimestampString;
|
||||||
|
|
||||||
|
NSDictionary *existingState = [FBSDKInternalUtility objectForJSONString:params[FBSDKLoginManagerLoggingClientStateKey] error:NULL];
|
||||||
|
params[FBSDKLoginManagerLoggingClientStateKey] = [self clientStateForAuthMethod:authMethod andExistingState:existingState];
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)willAttemptAppSwitchingBehavior
|
||||||
|
{
|
||||||
|
NSString *defaultUrlScheme = [NSString stringWithFormat:@"fb%@%@", [FBSDKSettings appID], [FBSDKSettings appURLSchemeSuffix] ?: @""];
|
||||||
|
BOOL isURLSchemeRegistered = [FBSDKInternalUtility isRegisteredURLScheme:defaultUrlScheme];
|
||||||
|
|
||||||
|
BOOL isFacebookAppCanOpenURLSchemeRegistered = [FBSDKInternalUtility isRegisteredCanOpenURLScheme:FBSDK_CANOPENURL_FACEBOOK];
|
||||||
|
BOOL isMessengerAppCanOpenURLSchemeRegistered = [FBSDKInternalUtility isRegisteredCanOpenURLScheme:FBSDK_CANOPENURL_MESSENGER];
|
||||||
|
|
||||||
|
[_extras addEntriesFromDictionary:@{
|
||||||
|
@"isURLSchemeRegistered" : @(isURLSchemeRegistered),
|
||||||
|
@"isFacebookAppCanOpenURLSchemeRegistered" : @(isFacebookAppCanOpenURLSchemeRegistered),
|
||||||
|
@"isMessengerAppCanOpenURLSchemeRegistered" : @(isMessengerAppCanOpenURLSchemeRegistered),
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)systemAuthDidShowDialog:(BOOL)didShowDialog isUnTOSedDevice:(BOOL)isUnTOSedDevice
|
||||||
|
{
|
||||||
|
[_extras addEntriesFromDictionary:@{
|
||||||
|
@"isUntosedDevice" : @(isUnTOSedDevice),
|
||||||
|
@"dialogShown" : @(didShowDialog),
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logNativeAppDialogResult:(BOOL)result dialogDuration:(NSTimeInterval)dialogDuration
|
||||||
|
{
|
||||||
|
NSOperatingSystemVersion iOS10Version = { .majorVersion = 10, .minorVersion = 0, .patchVersion = 0 };
|
||||||
|
if ([FBSDKInternalUtility isOSRunTimeVersionAtLeast:iOS10Version]) {
|
||||||
|
_extras[@"native_app_login_dialog_duration"] = @(dialogDuration);
|
||||||
|
_extras[@"native_app_login_dialog_result"] = @(result);
|
||||||
|
[self logEvent:FBSDKAppEventNameFBSessionFASLoginDialogResult params:[self _parametersForNewEvent]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
- (NSString *)clientStateForAuthMethod:(NSString *)authMethod andExistingState:(NSDictionary *)existingState
|
||||||
|
{
|
||||||
|
NSDictionary *clientState = @{
|
||||||
|
FBSDKLoginManagerLoggerParamAuthMethodKey: authMethod ?: @"",
|
||||||
|
FBSDKLoginManagerLoggerParamIdentifierKey: _identifier,
|
||||||
|
FBSDKLoginManagerLoggingClientStateIsClientState: @YES,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (existingState) {
|
||||||
|
NSMutableDictionary *mutableState = [clientState mutableCopy];
|
||||||
|
[mutableState addEntriesFromDictionary:existingState];
|
||||||
|
clientState = mutableState;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [FBSDKInternalUtility JSONStringForObject:clientState error:NULL invalidObjectHandler:NULL];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableDictionary *)_parametersForNewEvent
|
||||||
|
{
|
||||||
|
NSMutableDictionary *eventParameters = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
// NOTE: We ALWAYS add all params to each event, to ensure predictable mapping on the backend.
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamIdentifierKey] = _identifier ?: FBSDKLoginManagerLoggerValueEmpty;
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamTimestampKey] = @(round(1000 * [NSDate date].timeIntervalSince1970));
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamResultKey] = FBSDKLoginManagerLoggerValueEmpty;
|
||||||
|
[FBSDKInternalUtility dictionary:eventParameters setObject:_authMethod forKey:FBSDKLoginManagerLoggerParamAuthMethodKey];
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamErrorCodeKey] = FBSDKLoginManagerLoggerValueEmpty;
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamErrorMessageKey] = FBSDKLoginManagerLoggerValueEmpty;
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamExtrasKey] = FBSDKLoginManagerLoggerValueEmpty;
|
||||||
|
eventParameters[FBSDKLoginManagerLoggerParamLoggingTokenKey] = _loggingToken ?: FBSDKLoginManagerLoggerValueEmpty;
|
||||||
|
|
||||||
|
return eventParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logEvent:(NSString *)eventName params:(NSMutableDictionary *)params
|
||||||
|
{
|
||||||
|
if (_identifier) {
|
||||||
|
NSString *extrasJSONString = [FBSDKInternalUtility JSONStringForObject:_extras
|
||||||
|
error:NULL
|
||||||
|
invalidObjectHandler:NULL];
|
||||||
|
if (extrasJSONString) {
|
||||||
|
params[FBSDKLoginManagerLoggerParamExtrasKey] = extrasJSONString;
|
||||||
|
}
|
||||||
|
[_extras removeAllObjects];
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:eventName valueToSum:nil parameters:params accessToken:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)logEvent:(NSString *)eventName result:(NSString *)result error:(NSError *)error
|
||||||
|
{
|
||||||
|
NSMutableDictionary *params = [self _parametersForNewEvent];
|
||||||
|
|
||||||
|
params[FBSDKLoginManagerLoggerParamResultKey] = result;
|
||||||
|
|
||||||
|
if ([error.domain isEqualToString:FBSDKErrorDomain] || [error.domain isEqualToString:FBSDKLoginErrorDomain]) {
|
||||||
|
// tease apart the structure.
|
||||||
|
|
||||||
|
// first see if there is an explicit message in the error's userInfo. If not, default to the reason,
|
||||||
|
// which is less useful.
|
||||||
|
NSString *value = error.userInfo[@"error_message"] ?: error.userInfo[FBSDKErrorLocalizedDescriptionKey];
|
||||||
|
[FBSDKInternalUtility dictionary:params setObject:value forKey:FBSDKLoginManagerLoggerParamErrorMessageKey];
|
||||||
|
|
||||||
|
value = error.userInfo[FBSDKGraphRequestErrorGraphErrorCodeKey] ?: [NSString stringWithFormat:@"%ld", (long)error.code];
|
||||||
|
[FBSDKInternalUtility dictionary:params setObject:value forKey:FBSDKLoginManagerLoggerParamErrorCodeKey];
|
||||||
|
|
||||||
|
NSError *innerError = error.userInfo[NSUnderlyingErrorKey];
|
||||||
|
if (innerError != nil) {
|
||||||
|
value = innerError.userInfo[@"error_message"] ?: innerError.userInfo[NSLocalizedDescriptionKey];
|
||||||
|
[FBSDKInternalUtility dictionary:_extras setObject:value forKey:@"inner_error_message"];
|
||||||
|
|
||||||
|
value = innerError.userInfo[FBSDKGraphRequestErrorGraphErrorCodeKey] ?: [NSString stringWithFormat:@"%ld", (long)innerError.code];
|
||||||
|
[FBSDKInternalUtility dictionary:_extras setObject:value forKey:@"inner_error_code"];
|
||||||
|
}
|
||||||
|
} else if (error) {
|
||||||
|
params[FBSDKLoginManagerLoggerParamErrorCodeKey] = @(error.code);
|
||||||
|
params[FBSDKLoginManagerLoggerParamErrorMessageKey] = error.localizedDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
[self logEvent:eventName params:params];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginManagerLoginResult.h>
|
||||||
|
|
||||||
|
@interface FBSDKLoginManagerLoginResult()
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) NSDictionary *loggingExtras;
|
||||||
|
|
||||||
|
// legacy flag indicating this is an intermediary result only for logging purposes.
|
||||||
|
@property (nonatomic, assign) BOOL isSkipped;
|
||||||
|
|
||||||
|
// adds additional logging entry to extras - only sent as part of `endLoginWithResult:`
|
||||||
|
-(void)addLoggingExtra:(id)object forKey:(id<NSCopying>)key;
|
||||||
|
@end
|
||||||
33
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginUtility.h
generated
Normal file
33
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginUtility.h
generated
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKLoginKit/FBSDKLoginManager.h>
|
||||||
|
|
||||||
|
@interface FBSDKLoginUtility : NSObject
|
||||||
|
|
||||||
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
|
|
||||||
|
+ (NSString *)stringForAudience:(FBSDKDefaultAudience)audience;
|
||||||
|
+ (NSDictionary *)queryParamsFromLoginURL:(NSURL *)url;
|
||||||
|
|
||||||
|
+ (NSString *)userIDFromSignedRequest:(NSString *)signedRequest;
|
||||||
|
|
||||||
|
@end
|
||||||
80
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginUtility.m
generated
Normal file
80
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/FBSDKLoginUtility.m
generated
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLoginUtility.h"
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKConstants.h>
|
||||||
|
#import <FBSDKCoreKit/FBSDKSettings.h>
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLoginConstants.h"
|
||||||
|
|
||||||
|
@implementation FBSDKLoginUtility
|
||||||
|
|
||||||
|
+ (NSString *)stringForAudience:(FBSDKDefaultAudience)audience
|
||||||
|
{
|
||||||
|
switch (audience) {
|
||||||
|
case FBSDKDefaultAudienceOnlyMe:
|
||||||
|
return @"only_me";
|
||||||
|
case FBSDKDefaultAudienceFriends:
|
||||||
|
return @"friends";
|
||||||
|
case FBSDKDefaultAudienceEveryone:
|
||||||
|
return @"everyone";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSDictionary *)queryParamsFromLoginURL:(NSURL *)url
|
||||||
|
{
|
||||||
|
NSString *expectedUrlPrefix = [FBSDKInternalUtility appURLWithHost:@"authorize" path:nil queryParameters:nil error:NULL].absoluteString;
|
||||||
|
if (![url.absoluteString hasPrefix:expectedUrlPrefix]) {
|
||||||
|
// Don't have an App ID, just verify path.
|
||||||
|
NSString *host = url.host;
|
||||||
|
if (![host isEqualToString:@"authorize"]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[FBSDKInternalUtility dictionaryFromFBURL:url]];
|
||||||
|
|
||||||
|
NSString *userID = [[self class] userIDFromSignedRequest:params[@"signed_request"]];
|
||||||
|
if (userID) {
|
||||||
|
params[@"user_id"] = userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString *)userIDFromSignedRequest:(NSString *)signedRequest
|
||||||
|
{
|
||||||
|
if (!signedRequest) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray *signatureAndPayload = [signedRequest componentsSeparatedByString:@"."];
|
||||||
|
NSString *userID = nil;
|
||||||
|
|
||||||
|
if (signatureAndPayload.count == 2) {
|
||||||
|
NSData *data = [FBSDKBase64 decodeAsData:signatureAndPayload[1]];
|
||||||
|
if (data) {
|
||||||
|
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
||||||
|
userID = dictionary[@"user_id"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
23
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/_FBSDKLoginRecoveryAttempter.h
generated
Normal file
23
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/_FBSDKLoginRecoveryAttempter.h
generated
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
@interface _FBSDKLoginRecoveryAttempter : FBSDKErrorRecoveryAttempter
|
||||||
|
|
||||||
|
@end
|
||||||
47
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/_FBSDKLoginRecoveryAttempter.m
generated
Normal file
47
Example/Pods/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginKit/Internal/_FBSDKLoginRecoveryAttempter.m
generated
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "_FBSDKLoginRecoveryAttempter.h"
|
||||||
|
|
||||||
|
#import "FBSDKLoginKit+Internal.h"
|
||||||
|
|
||||||
|
@implementation _FBSDKLoginRecoveryAttempter
|
||||||
|
|
||||||
|
- (void)attemptRecoveryFromError:(NSError *)error
|
||||||
|
optionIndex:(NSUInteger)recoveryOptionIndex
|
||||||
|
delegate:(id)delegate
|
||||||
|
didRecoverSelector:(SEL)didRecoverSelector
|
||||||
|
contextInfo:(void *)contextInfo {
|
||||||
|
|
||||||
|
void(^handler)(BOOL) = ^(BOOL didRecover) {
|
||||||
|
[super completeRecovery:didRecover delegate:delegate didRecoverSelector:didRecoverSelector contextInfo:contextInfo];
|
||||||
|
};
|
||||||
|
NSSet *currentPermissions = [FBSDKAccessToken currentAccessToken].permissions;
|
||||||
|
if (recoveryOptionIndex == 0 && currentPermissions.count > 0) {
|
||||||
|
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
|
||||||
|
[login logInWithPermissions:currentPermissions handler:^(FBSDKLoginManagerLoginResult *result, NSError *loginError) {
|
||||||
|
// we can only consider a recovery successful if there are no declines
|
||||||
|
// (note this could still set an updated currentAccessToken).
|
||||||
|
handler(!loginError && !result.isCancelled && result.declinedPermissions.count == 0);
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
handler(NO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
43
Example/Pods/FBSDKLoginKit/README.md
generated
Normal file
43
Example/Pods/FBSDKLoginKit/README.md
generated
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Facebook SDK for iOS
|
||||||
|
|
||||||
|
[](https://travis-ci.org/facebook/facebook-objc-sdk)
|
||||||
|
|
||||||
|
This open-source library allows you to integrate Facebook into your iOS app.
|
||||||
|
|
||||||
|
Learn more about the provided samples, documentation, integrating the SDK into your app, accessing source code, and more at https://developers.facebook.com/docs/ios
|
||||||
|
|
||||||
|
NOTE: By default, the Facebook SDK for iOS is installed in ~/Documents/FacebookSDK
|
||||||
|
|
||||||
|
## TRY IT OUT
|
||||||
|
|
||||||
|
1. Download the SDK at <https://developers.facebook.com/docs/ios> or via CocoaPods by adding the 'FBSDKCoreKit', 'FBSDKLoginKit', and 'FBSDKShareKit' pods.
|
||||||
|
2. Test your install: build and run the project at `~/Documents/FacebookSDK/Samples/Scrumptious/Scrumptious.xcodeproj`
|
||||||
|
3. Check-out the tutorials available online at: <https://developers.facebook.com/docs/ios/getting-started>
|
||||||
|
4. Start coding! Visit <https://developers.facebook.com/docs/ios> for tutorials and reference documentation.
|
||||||
|
|
||||||
|
## FEATURES
|
||||||
|
|
||||||
|
- Login - <https://developers.facebook.com/docs/facebook-login>
|
||||||
|
- Sharing - <https://developers.facebook.com/docs/sharing>
|
||||||
|
- App Links - <https://developers.facebook.com/docs/applinks>
|
||||||
|
- Graph API - <https://developers.facebook.com/docs/ios/graph>
|
||||||
|
- Analytics - <https://developers.facebook.com/docs/analytics>
|
||||||
|
|
||||||
|
## GIVE FEEDBACK
|
||||||
|
|
||||||
|
Please report bugs or issues to <https://developers.facebook.com/bugs/>
|
||||||
|
|
||||||
|
You can also join the [Facebook Developers Group on Facebook](https://www.facebook.com/groups/fbdevelopers/) or ask questions on [Stack Overflow](http://facebook.stackoverflow.com)
|
||||||
|
|
||||||
|
## LICENSE
|
||||||
|
|
||||||
|
See the [LICENSE](LICENSE) file.
|
||||||
|
|
||||||
|
## DEVELOPER TERMS
|
||||||
|
|
||||||
|
- By enabling Facebook integrations, including through this SDK, you can share information with Facebook, including information about people’s use of your app. Facebook will use information received in accordance with our [Data Use Policy](https://www.facebook.com/about/privacy/), including to provide you with insights about the effectiveness of your ads and the use of your app. These integrations also enable us and our partners to serve ads on and off Facebook.
|
||||||
|
- You may limit your sharing of information with us by updating the Insights control in the developer tool `https://developers.facebook.com/apps/{app_id}/settings/advanced`.
|
||||||
|
- If you use a Facebook integration, including to share information with us, you agree and confirm that you have provided appropriate and sufficiently prominent notice to and obtained the appropriate consent from your users regarding such collection, use, and disclosure (including, at a minimum, through your privacy policy). You further agree that you will not share information with us about children under the age of 13.
|
||||||
|
- You agree to comply with all applicable laws and regulations and also agree to our Terms <https://www.facebook.com/policies/>, including our Platform Policies <https://developers.facebook.com/policy/>.and Advertising Guidelines, as applicable <https://www.facebook.com/ad_guidelines.php>.
|
||||||
|
|
||||||
|
By using the Facebook SDK for iOS you agree to these terms.
|
||||||
100
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupAddDialog.h
generated
Normal file
100
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupAddDialog.h
generated
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKAppGroupContent.h>
|
||||||
|
|
||||||
|
@protocol FBSDKAppGroupAddDialogDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("App and game groups are being deprecated")
|
||||||
|
@interface FBSDKAppGroupAddDialog : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
+ (instancetype)showWithContent:(FBSDKAppGroupContent *)content
|
||||||
|
delegate:(id<FBSDKAppGroupAddDialogDelegate>)delegate
|
||||||
|
DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) id<FBSDKAppGroupAddDialogDelegate> delegate
|
||||||
|
DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) FBSDKAppGroupContent *content
|
||||||
|
DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (BOOL)canShow DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (BOOL)show DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("App and game groups are being deprecated")
|
||||||
|
@protocol FBSDKAppGroupAddDialogDelegate <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (void)appGroupAddDialog:(FBSDKAppGroupAddDialog *)appGroupAddDialog didCompleteWithResults:(NSDictionary *)results DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (void)appGroupAddDialog:(FBSDKAppGroupAddDialog *)appGroupAddDialog didFailWithError:(NSError *)error DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (void)appGroupAddDialogDidCancel:(FBSDKAppGroupAddDialog *)appGroupAddDialog DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
@end
|
||||||
191
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupAddDialog.m
generated
Normal file
191
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupAddDialog.m
generated
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKAppGroupAddDialog.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
@interface FBSDKAppGroupAddDialog () <FBSDKWebDialogDelegate>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKAppGroupAddDialog
|
||||||
|
{
|
||||||
|
FBSDKWebDialog *_webDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FBSDK_APP_GROUP_CREATE_METHOD_NAME @"game_group_create"
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (instancetype)showWithContent:(FBSDKAppGroupContent *)content
|
||||||
|
delegate:(id<FBSDKAppGroupAddDialogDelegate>)delegate
|
||||||
|
{
|
||||||
|
FBSDKAppGroupAddDialog *dialog = [[self alloc] init];
|
||||||
|
dialog.content = content;
|
||||||
|
dialog.delegate = delegate;
|
||||||
|
[dialog show];
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_webDialog = [[FBSDKWebDialog alloc] init];
|
||||||
|
_webDialog.delegate = self;
|
||||||
|
_webDialog.name = FBSDK_APP_GROUP_CREATE_METHOD_NAME;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
_webDialog.delegate = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (BOOL)canShow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)show
|
||||||
|
{
|
||||||
|
NSError *error;
|
||||||
|
if (![self canShow]) {
|
||||||
|
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorDialogNotAvailable
|
||||||
|
message:@"App group create dialog is not available."];
|
||||||
|
[_delegate appGroupAddDialog:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self validateWithError:&error]) {
|
||||||
|
[_delegate appGroupAddDialog:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FBSDKAppGroupContent *content = self.content;
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.name forKey:@"name"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.groupDescription forKey:@"description"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters
|
||||||
|
setObject:NSStringFromFBSDKAppGroupPrivacy(content.privacy)
|
||||||
|
forKey:@"privacy"];
|
||||||
|
|
||||||
|
_webDialog.parameters = parameters;
|
||||||
|
[_webDialog show];
|
||||||
|
[FBSDKInternalUtility registerTransientObject:self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
FBSDKAppGroupContent *content = self.content;
|
||||||
|
if (!content) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"content"
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (!content.name.length) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"name"
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (!content.groupDescription.length) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"groupDescription"
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = nil;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKWebDialogDelegate
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didCompleteWithResults:(NSDictionary *)results
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSError *error = [NSError fbErrorWithCode:[FBSDKTypeUtility unsignedIntegerValue:results[@"error_code"]]
|
||||||
|
message:[FBSDKTypeUtility stringValue:results[@"error_message"]]];
|
||||||
|
[self _handleCompletionWithDialogResults:results error:error];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self _handleCompletionWithDialogResults:nil error:error];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialogDidCancel:(FBSDKWebDialog *)webDialog
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[_delegate appGroupAddDialogDidCancel:self];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_handleCompletionWithDialogResults:(NSDictionary *)results error:(NSError *)error
|
||||||
|
{
|
||||||
|
if (!_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (error.code) {
|
||||||
|
case 0:{
|
||||||
|
[_delegate appGroupAddDialog:self didCompleteWithResults:results];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4201:{
|
||||||
|
[_delegate appGroupAddDialogDidCancel:self];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
[_delegate appGroupAddDialog:self didFailWithError:error];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
67
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupContent.h
generated
Normal file
67
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupContent.h
generated
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKAppGroupPrivacy)
|
||||||
|
Specifies the privacy of a group.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKAppGroupPrivacy)
|
||||||
|
{
|
||||||
|
/** Anyone can see the group, who's in it and what members post. */
|
||||||
|
FBSDKAppGroupPrivacyOpen = 0,
|
||||||
|
/** Anyone can see the group and who's in it, but only members can see posts. */
|
||||||
|
FBSDKAppGroupPrivacyClosed,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an FBSDKAppGroupPrivacy to an NSString.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *NSStringFromFBSDKAppGroupPrivacy(FBSDKAppGroupPrivacy privacy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for creating an app group.
|
||||||
|
*/
|
||||||
|
@interface FBSDKAppGroupContent : NSObject <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The description of the group.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *groupDescription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The name of the group.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The privacy for the group.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKAppGroupPrivacy privacy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another app group content.
|
||||||
|
@param content The other content
|
||||||
|
@return YES if the receiver's values are equal to the other content's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToAppGroupContent:(FBSDKAppGroupContent *)content;
|
||||||
|
|
||||||
|
@end
|
||||||
109
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupContent.m
generated
Normal file
109
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupContent.m
generated
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKAppGroupContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
#define FBSDK_APP_GROUP_CONTENT_GROUP_DESCRIPTION_KEY @"groupDescription"
|
||||||
|
#define FBSDK_APP_GROUP_CONTENT_NAME_KEY @"name"
|
||||||
|
#define FBSDK_APP_GROUP_CONTENT_PRIVACY_KEY @"privacy"
|
||||||
|
|
||||||
|
NSString *NSStringFromFBSDKAppGroupPrivacy(FBSDKAppGroupPrivacy privacy)
|
||||||
|
{
|
||||||
|
switch (privacy) {
|
||||||
|
case FBSDKAppGroupPrivacyClosed:{
|
||||||
|
return @"closed";
|
||||||
|
}
|
||||||
|
case FBSDKAppGroupPrivacyOpen:{
|
||||||
|
return @"open";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation FBSDKAppGroupContent
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
NSUInteger subhashes[] = {
|
||||||
|
_groupDescription.hash,
|
||||||
|
_name.hash,
|
||||||
|
_privacy,
|
||||||
|
};
|
||||||
|
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKAppGroupContent class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToAppGroupContent:(FBSDKAppGroupContent *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToAppGroupContent:(FBSDKAppGroupContent *)content
|
||||||
|
{
|
||||||
|
return (content &&
|
||||||
|
(_privacy == content.privacy) &&
|
||||||
|
[FBSDKInternalUtility object:_name isEqualToObject:content.name] &&
|
||||||
|
[FBSDKInternalUtility object:_groupDescription isEqualToObject:content.groupDescription]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_groupDescription = [decoder decodeObjectOfClass:[NSString class]
|
||||||
|
forKey:FBSDK_APP_GROUP_CONTENT_GROUP_DESCRIPTION_KEY];
|
||||||
|
_name = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_APP_GROUP_CONTENT_PRIVACY_KEY];
|
||||||
|
_privacy = [decoder decodeIntegerForKey:FBSDK_APP_GROUP_CONTENT_PRIVACY_KEY];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_groupDescription forKey:FBSDK_APP_GROUP_CONTENT_GROUP_DESCRIPTION_KEY];
|
||||||
|
[encoder encodeObject:_name forKey:FBSDK_APP_GROUP_CONTENT_NAME_KEY];
|
||||||
|
[encoder encodeInteger:_privacy forKey:FBSDK_APP_GROUP_CONTENT_PRIVACY_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKAppGroupContent *copy = [[FBSDKAppGroupContent alloc] init];
|
||||||
|
copy->_groupDescription = [_groupDescription copy];
|
||||||
|
copy->_name = [_name copy];
|
||||||
|
copy->_privacy = _privacy;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
92
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupJoinDialog.h
generated
Normal file
92
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupJoinDialog.h
generated
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@protocol FBSDKAppGroupJoinDialogDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("App and game groups are being deprecated")
|
||||||
|
@interface FBSDKAppGroupJoinDialog : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
+ (instancetype)showWithGroupID:(NSString *)groupID
|
||||||
|
delegate:(id<FBSDKAppGroupJoinDialogDelegate>)delegate DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information. */
|
||||||
|
@property (nonatomic, weak) id<FBSDKAppGroupJoinDialogDelegate> delegate DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information. */
|
||||||
|
@property (nonatomic, copy) NSString *groupID DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (BOOL)canShow DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (BOOL)show DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("App and game groups are being deprecated")
|
||||||
|
@protocol FBSDKAppGroupJoinDialogDelegate <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (void)appGroupJoinDialog:(FBSDKAppGroupJoinDialog *)appGroupJoinDialog didCompleteWithResults:(NSDictionary *)results DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (void)appGroupJoinDialog:(FBSDKAppGroupJoinDialog *)appGroupJoinDialog didFailWithError:(NSError *)error DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning App and game groups are being deprecated. See https://developers.facebook.com/docs/games/services/game-groups for more information.
|
||||||
|
*/
|
||||||
|
- (void)appGroupJoinDialogDidCancel:(FBSDKAppGroupJoinDialog *)appGroupJoinDialog DEPRECATED_ATTRIBUTE;
|
||||||
|
|
||||||
|
@end
|
||||||
169
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupJoinDialog.m
generated
Normal file
169
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppGroupJoinDialog.m
generated
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKAppGroupJoinDialog.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
@interface FBSDKAppGroupJoinDialog () <FBSDKWebDialogDelegate>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKAppGroupJoinDialog
|
||||||
|
{
|
||||||
|
FBSDKWebDialog *_webDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FBSDK_APP_GROUP_JOIN_METHOD_NAME @"game_group_join"
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (instancetype)showWithGroupID:(NSString *)groupID
|
||||||
|
delegate:(id<FBSDKAppGroupJoinDialogDelegate>)delegate
|
||||||
|
{
|
||||||
|
FBSDKAppGroupJoinDialog *dialog = [[self alloc] init];
|
||||||
|
dialog.groupID = groupID;
|
||||||
|
dialog.delegate = delegate;
|
||||||
|
[dialog show];
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_webDialog = [[FBSDKWebDialog alloc] init];
|
||||||
|
_webDialog.delegate = self;
|
||||||
|
_webDialog.name = FBSDK_APP_GROUP_JOIN_METHOD_NAME;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
_webDialog.delegate = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (BOOL)canShow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)show
|
||||||
|
{
|
||||||
|
NSError *error;
|
||||||
|
if (![self canShow]) {
|
||||||
|
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorDialogNotAvailable
|
||||||
|
message:@"App group join dialog is not available."];
|
||||||
|
[_delegate appGroupJoinDialog:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self validateWithError:&error]) {
|
||||||
|
[_delegate appGroupJoinDialog:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:self.groupID forKey:@"id"];
|
||||||
|
|
||||||
|
_webDialog.parameters = parameters;
|
||||||
|
[_webDialog show];
|
||||||
|
[FBSDKInternalUtility registerTransientObject:self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (!self.groupID.length) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"groupID"
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = nil;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKWebDialogDelegate
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didCompleteWithResults:(NSDictionary *)results
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSError *error = [NSError fbErrorWithCode:[FBSDKTypeUtility unsignedIntegerValue:results[@"error_code"]]
|
||||||
|
message:[FBSDKTypeUtility stringValue:results[@"error_message"]]];
|
||||||
|
[self _handleCompletionWithDialogResults:results error:error];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self _handleCompletionWithDialogResults:nil error:error];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialogDidCancel:(FBSDKWebDialog *)webDialog
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[_delegate appGroupJoinDialogDidCancel:self];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_handleCompletionWithDialogResults:(NSDictionary *)results error:(NSError *)error
|
||||||
|
{
|
||||||
|
if (!_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (error.code) {
|
||||||
|
case 0:{
|
||||||
|
[_delegate appGroupJoinDialog:self didCompleteWithResults:results];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4201:{
|
||||||
|
[_delegate appGroupJoinDialogDidCancel:self];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
[_delegate appGroupJoinDialog:self didFailWithError:error];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
97
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteContent.h
generated
Normal file
97
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteContent.h
generated
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingValidation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKAppInviteDestination)
|
||||||
|
Specifies the privacy of a group.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKAppInviteDestination)
|
||||||
|
{
|
||||||
|
/** Deliver to Facebook. */
|
||||||
|
FBSDKAppInviteDestinationFacebook = 0,
|
||||||
|
/** Deliver to Messenger. */
|
||||||
|
FBSDKAppInviteDestinationMessenger,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for app invite.
|
||||||
|
*/
|
||||||
|
@interface FBSDKAppInviteContent : NSObject <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A URL to a preview image that will be displayed with the app invite
|
||||||
|
|
||||||
|
|
||||||
|
This is optional. If you don't include it a fallback image will be used.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *appInvitePreviewImageURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
An app link target that will be used as a target when the user accept the invite.
|
||||||
|
|
||||||
|
|
||||||
|
This is a requirement.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *appLinkURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning Use `appInvitePreviewImageURL` instead.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *previewImageURL
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("use appInvitePreviewImageURL instead");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Promotional code to be displayed while sending and receiving the invite.
|
||||||
|
|
||||||
|
|
||||||
|
This is optional. This can be between 0 and 10 characters long and can contain
|
||||||
|
alphanumeric characters only. To set a promo code, you need to set promo text.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *promotionCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Promotional text to be displayed while sending and receiving the invite.
|
||||||
|
|
||||||
|
|
||||||
|
This is optional. This can be between 0 and 80 characters long and can contain
|
||||||
|
alphanumeric and spaces only.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *promotionText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destination for the app invite.
|
||||||
|
|
||||||
|
|
||||||
|
This is optional and for declaring destination of the invite.
|
||||||
|
*/
|
||||||
|
@property FBSDKAppInviteDestination destination;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another app invite content.
|
||||||
|
@param content The other content
|
||||||
|
@return YES if the receiver's values are equal to the other content's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToAppInviteContent:(FBSDKAppInviteContent *)content;
|
||||||
|
|
||||||
|
@end
|
||||||
177
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteContent.m
generated
Normal file
177
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteContent.m
generated
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKAppInviteContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
#define FBSDK_APP_INVITE_CONTENT_APP_LINK_URL_KEY @"appLinkURL"
|
||||||
|
#define FBSDK_APP_INVITE_CONTENT_PREVIEW_IMAGE_KEY @"previewImage"
|
||||||
|
#define FBSDK_APP_INVITE_CONTENT_PROMO_CODE_KEY @"promoCode"
|
||||||
|
#define FBSDK_APP_INVITE_CONTENT_PROMO_TEXT_KEY @"promoText"
|
||||||
|
#define FBSDK_APP_INVITE_CONTENT_DESTINATION_KEY @"destination"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation FBSDKAppInviteContent
|
||||||
|
|
||||||
|
- (NSURL *)previewImageURL
|
||||||
|
{
|
||||||
|
return self.appInvitePreviewImageURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPreviewImageURL:(NSURL *)previewImageURL
|
||||||
|
{
|
||||||
|
self.appInvitePreviewImageURL = previewImageURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
return ([FBSDKShareUtility validateRequiredValue:_appLinkURL name:@"appLinkURL" error:errorRef] &&
|
||||||
|
[FBSDKShareUtility validateNetworkURL:_appLinkURL name:@"appLinkURL" error:errorRef] &&
|
||||||
|
[FBSDKShareUtility validateNetworkURL:_appInvitePreviewImageURL name:@"appInvitePreviewImageURL" error:errorRef] &&
|
||||||
|
[self _validatePromoCodeWithError:errorRef]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_validatePromoCodeWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (_promotionText.length > 0 || _promotionCode.length > 0) {
|
||||||
|
NSMutableCharacterSet *alphanumericWithSpaces = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||||
|
[alphanumericWithSpaces formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||||
|
|
||||||
|
// Check for validity of promo text and promo code.
|
||||||
|
if (!(_promotionText.length > 0 && _promotionText.length <= 80)) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithName:@"promotionText" value:_promotionText message:@"Invalid value for promotionText, promotionText has to be between 1 and 80 characters long."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(_promotionCode.length <= 10)) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithName:@"promotionCode" value:_promotionCode message:@"Invalid value for promotionCode, promotionCode has to be between 0 and 10 characters long and is required when promoCode is set."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([_promotionText rangeOfCharacterFromSet:alphanumericWithSpaces.invertedSet].location != NSNotFound) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithName:@"promotionText" value:_promotionText message:@"Invalid value for promotionText, promotionText can contain only alphanumeric characters and spaces."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_promotionCode.length > 0 && [_promotionCode rangeOfCharacterFromSet:alphanumericWithSpaces.invertedSet].location != NSNotFound) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithName:@"promotionCode" value:_promotionCode message:@"Invalid value for promotionCode, promotionCode can contain only alphanumeric characters and spaces."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
NSUInteger subhashes[] = {
|
||||||
|
_appLinkURL.hash,
|
||||||
|
_appInvitePreviewImageURL.hash,
|
||||||
|
_promotionCode.hash,
|
||||||
|
_promotionText.hash,
|
||||||
|
};
|
||||||
|
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKAppInviteContent class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToAppInviteContent:(FBSDKAppInviteContent *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToAppInviteContent:(FBSDKAppInviteContent *)content
|
||||||
|
{
|
||||||
|
return (content &&
|
||||||
|
[FBSDKInternalUtility object:_appLinkURL isEqualToObject:content.appLinkURL] &&
|
||||||
|
[FBSDKInternalUtility object:_appInvitePreviewImageURL isEqualToObject:content.appInvitePreviewImageURL] &&
|
||||||
|
[FBSDKInternalUtility object:_promotionText isEqualToObject:content.promotionText] &&
|
||||||
|
[FBSDKInternalUtility object:_promotionCode isEqualToObject:content.promotionText] &&
|
||||||
|
_destination == content.destination
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_appLinkURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_APP_INVITE_CONTENT_APP_LINK_URL_KEY];
|
||||||
|
_appInvitePreviewImageURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_APP_INVITE_CONTENT_PREVIEW_IMAGE_KEY];
|
||||||
|
_promotionCode = [decoder decodeObjectOfClass:[NSString class] forKey:
|
||||||
|
FBSDK_APP_INVITE_CONTENT_PROMO_CODE_KEY];
|
||||||
|
_promotionText = [decoder decodeObjectOfClass:[NSString class] forKey:
|
||||||
|
FBSDK_APP_INVITE_CONTENT_PROMO_TEXT_KEY];
|
||||||
|
_destination = [decoder decodeIntegerForKey:
|
||||||
|
FBSDK_APP_INVITE_CONTENT_DESTINATION_KEY];
|
||||||
|
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_appLinkURL forKey:FBSDK_APP_INVITE_CONTENT_APP_LINK_URL_KEY];
|
||||||
|
[encoder encodeObject:_appInvitePreviewImageURL forKey:FBSDK_APP_INVITE_CONTENT_PREVIEW_IMAGE_KEY];
|
||||||
|
[encoder encodeObject:_promotionCode forKey:FBSDK_APP_INVITE_CONTENT_PROMO_CODE_KEY];
|
||||||
|
[encoder encodeObject:_promotionText forKey:FBSDK_APP_INVITE_CONTENT_PROMO_TEXT_KEY];
|
||||||
|
[encoder encodeInt:_destination forKey:FBSDK_APP_INVITE_CONTENT_DESTINATION_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKAppInviteContent *copy = [[FBSDKAppInviteContent alloc] init];
|
||||||
|
copy->_appLinkURL = [_appLinkURL copy];
|
||||||
|
copy->_appInvitePreviewImageURL = [_appInvitePreviewImageURL copy];
|
||||||
|
copy->_promotionText = [_promotionText copy];
|
||||||
|
copy->_promotionCode = [_promotionCode copy];
|
||||||
|
copy->_destination = _destination;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
118
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteDialog.h
generated
Normal file
118
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteDialog.h
generated
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKAppInviteContent.h>
|
||||||
|
|
||||||
|
@protocol FBSDKAppInviteDialogDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A dialog for sending App Invites.
|
||||||
|
*/
|
||||||
|
@interface FBSDKAppInviteDialog : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to show a FBSDKAppInviteDialog
|
||||||
|
@param viewController A UIViewController to present the dialog from.
|
||||||
|
@param content The content for the app invite.
|
||||||
|
@param delegate The receiver's delegate.
|
||||||
|
@warning This method is deprecated.
|
||||||
|
*/
|
||||||
|
+ (instancetype)showFromViewController:(UIViewController *)viewController
|
||||||
|
withContent:(FBSDKAppInviteContent *)content
|
||||||
|
delegate:(id<FBSDKAppInviteDialogDelegate>)delegate
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("App Invites no longer supported");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning use showFromViewController:withContent:delegate: instead
|
||||||
|
*/
|
||||||
|
+ (instancetype)showWithContent:(FBSDKAppInviteContent *)content delegate:(id<FBSDKAppInviteDialogDelegate>)delegate
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("use showFromViewController:withContent:delegate: instead");
|
||||||
|
|
||||||
|
/**
|
||||||
|
A UIViewController to present the dialog from.
|
||||||
|
|
||||||
|
If not specified, the top most view controller will be automatically determined as best as possible.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) UIViewController *fromViewController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The receiver's delegate or nil if it doesn't have a delegate.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) id<FBSDKAppInviteDialogDelegate> delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The content for app invite.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) FBSDKAppInviteContent *content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A Boolean value that indicates whether the receiver can initiate an app invite.
|
||||||
|
|
||||||
|
May return NO if the appropriate Facebook app is not installed and is required or an access token is
|
||||||
|
required but not available. This method does not validate the content on the receiver, so this can be checked before
|
||||||
|
building up the content.
|
||||||
|
|
||||||
|
@see validateWithError:
|
||||||
|
@return YES if the receiver can show the dialog, otherwise NO.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) BOOL canShow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Begins the app invite from the receiver.
|
||||||
|
@return YES if the receiver was able to show the dialog, otherwise NO.
|
||||||
|
*/
|
||||||
|
- (BOOL)show;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Validates the content on the receiver.
|
||||||
|
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||||
|
@return YES if the content is valid, otherwise NO.
|
||||||
|
*/
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
A delegate for FBSDKAppInviteDialog.
|
||||||
|
|
||||||
|
The delegate is notified with the results of the app invite as long as the application has permissions to
|
||||||
|
receive the information. For example, if the person is not signed into the containing app, the shower may not be able
|
||||||
|
to distinguish between completion of an app invite and cancellation.
|
||||||
|
*/
|
||||||
|
@protocol FBSDKAppInviteDialogDelegate <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the app invite completes without error.
|
||||||
|
@param appInviteDialog The FBSDKAppInviteDialog that completed.
|
||||||
|
@param results The results from the dialog. This may be nil or empty.
|
||||||
|
*/
|
||||||
|
- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the app invite encounters an error.
|
||||||
|
@param appInviteDialog The FBSDKAppInviteDialog that completed.
|
||||||
|
@param error The error.
|
||||||
|
*/
|
||||||
|
- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error;
|
||||||
|
|
||||||
|
@end
|
||||||
85
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteDialog.m
generated
Normal file
85
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKAppInviteDialog.m
generated
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKAppInviteDialog.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareDefines.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
@implementation FBSDKAppInviteDialog
|
||||||
|
|
||||||
|
#define FBSDK_APP_INVITE_METHOD_MIN_VERSION @"20140410"
|
||||||
|
#define FBSDK_APP_INVITE_METHOD_NAME @"appinvites"
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if ([FBSDKAppInviteDialog class] == self) {
|
||||||
|
[FBSDKInternalUtility checkRegisteredCanOpenURLScheme:FBSDK_CANOPENURL_FACEBOOK];
|
||||||
|
// ensure that we have updated the dialog configs if we haven't already
|
||||||
|
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:NULL];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
|
||||||
|
+ (instancetype)showWithContent:(FBSDKAppInviteContent *)content delegate:(id<FBSDKAppInviteDialogDelegate>)delegate
|
||||||
|
{
|
||||||
|
return [self showFromViewController:nil withContent:content delegate:delegate];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+ (instancetype)showFromViewController:(UIViewController *)viewController
|
||||||
|
withContent:(FBSDKAppInviteContent *)content
|
||||||
|
delegate:(id<FBSDKAppInviteDialogDelegate>)delegate;
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (BOOL)canShow
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)show
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (![FBSDKShareUtility validateRequiredValue:self.content name:@"content" error:errorRef]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if ([self.content respondsToSelector:@selector(validateWithError:)]) {
|
||||||
|
return [self.content validateWithOptions:FBSDKShareBridgeOptionsDefault error:errorRef];
|
||||||
|
}
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"content"
|
||||||
|
value:self.content
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
57
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectArguments.h
generated
Normal file
57
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectArguments.h
generated
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container of arguments for a camera effect.
|
||||||
|
* An argument is a NSString identified by a NSString key.
|
||||||
|
*/
|
||||||
|
@interface FBSDKCameraEffectArguments : NSObject <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a string argument in the container.
|
||||||
|
@param string The argument
|
||||||
|
@param key The key for the argument
|
||||||
|
*/
|
||||||
|
- (void)setString:(NSString *)string forKey:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets a string argument from the container.
|
||||||
|
@param key The key for the argument
|
||||||
|
@return The string value or nil
|
||||||
|
*/
|
||||||
|
- (NSString *)stringForKey:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets a string array argument in the container.
|
||||||
|
@param array The array argument
|
||||||
|
@param key The key for the argument
|
||||||
|
*/
|
||||||
|
- (void)setArray:(NSArray<NSString *> *)array forKey:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets an array argument from the container.
|
||||||
|
@param key The key for the argument
|
||||||
|
@return The array argument
|
||||||
|
*/
|
||||||
|
- (NSArray *)arrayForKey:(NSString *)key;
|
||||||
|
|
||||||
|
@end
|
||||||
177
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectArguments.m
generated
Normal file
177
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectArguments.m
generated
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKCameraEffectArguments.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
static NSString *const FBSDKCameraEffectArgumentsArgumentsKey = @"arguments";
|
||||||
|
|
||||||
|
@implementation FBSDKCameraEffectArguments
|
||||||
|
{
|
||||||
|
NSMutableDictionary *_arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_arguments = [NSMutableDictionary new];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setString:(NSString *)string forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
[self _setValue:[string copy] forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)stringForKey:(NSString *)key
|
||||||
|
{
|
||||||
|
return [self _valueOfClass:[NSString class] forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setArray:(NSArray<NSString *> *)array forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
[self _setValue:[array copy] forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)arrayForKey:(NSString *)key
|
||||||
|
{
|
||||||
|
return [self _valueOfClass:[NSArray class] forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)allArguments
|
||||||
|
{
|
||||||
|
return _arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
return _arguments.hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKCameraEffectArguments class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToCameraEffectArguments:(FBSDKCameraEffectArguments *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToCameraEffectArguments:(FBSDKCameraEffectArguments *)object
|
||||||
|
{
|
||||||
|
return [FBSDKInternalUtility object:_arguments isEqualToObject:[object allArguments]];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_arguments = [decoder decodeObjectOfClass:[NSMutableDictionary class]
|
||||||
|
forKey:FBSDKCameraEffectArgumentsArgumentsKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_arguments forKey:FBSDKCameraEffectArgumentsArgumentsKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKCameraEffectArguments *copy = [FBSDKCameraEffectArguments new];
|
||||||
|
copy->_arguments = [_arguments copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_setValue:(id)value forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
[FBSDKCameraEffectArguments assertKey:key];
|
||||||
|
if (value) {
|
||||||
|
[FBSDKCameraEffectArguments assertValue:value];
|
||||||
|
_arguments[key] = value;
|
||||||
|
} else {
|
||||||
|
[_arguments removeObjectForKey:key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)_valueForKey:(NSString *)key
|
||||||
|
{
|
||||||
|
key = [FBSDKTypeUtility stringValue:key];
|
||||||
|
return (key ? [FBSDKTypeUtility objectValue:_arguments[key]] : nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)_valueOfClass:(__unsafe_unretained Class)cls forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
id value = [self _valueForKey:key];
|
||||||
|
return ([value isKindOfClass:cls] ? value : nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)assertKey:(id)key
|
||||||
|
{
|
||||||
|
if ([key isKindOfClass:[NSString class]]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSString *reason = [NSString stringWithFormat:@"Invalid key found in CameraEffectArguments: %@", key];
|
||||||
|
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)assertValue:(id)value
|
||||||
|
{
|
||||||
|
BOOL isInvalid = NO;
|
||||||
|
if ([value isKindOfClass:[NSString class]]) {
|
||||||
|
// Strings are always valid.
|
||||||
|
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||||
|
// Allow only string arrays.
|
||||||
|
for (id subValue in (NSArray *)value) {
|
||||||
|
if (![subValue isKindOfClass:[NSString class]]) {
|
||||||
|
isInvalid = YES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isInvalid = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInvalid) {
|
||||||
|
NSString *reason = [NSString stringWithFormat:@"Invalid value found in CameraEffectArguments: %@", value];
|
||||||
|
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
43
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectTextures.h
generated
Normal file
43
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectTextures.h
generated
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container of textures for a camera effect.
|
||||||
|
* A texture for a camera effect is an UIImages identified by a NSString key.
|
||||||
|
*/
|
||||||
|
@interface FBSDKCameraEffectTextures : NSObject <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the image for a texture key.
|
||||||
|
@param image The UIImage for the texture
|
||||||
|
@param key The key for the texture
|
||||||
|
*/
|
||||||
|
- (void)setImage:(UIImage *)image forKey:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the image for a texture key.
|
||||||
|
@param key The key for the texture
|
||||||
|
@return The texture UIImage or nil
|
||||||
|
*/
|
||||||
|
- (UIImage *)imageForKey:(NSString *)key;
|
||||||
|
|
||||||
|
@end
|
||||||
132
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectTextures.m
generated
Normal file
132
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKCameraEffectTextures.m
generated
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKCameraEffectTextures.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
static NSString *const FBSDKCameraEffectTexturesTexturesKey = @"textures";
|
||||||
|
|
||||||
|
@implementation FBSDKCameraEffectTextures
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, UIImage *> *_textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_textures = [NSMutableDictionary new];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setImage:(UIImage *)image forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
[self _setValue:image forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIImage *)imageForKey:(NSString *)key
|
||||||
|
{
|
||||||
|
return [self _valueOfClass:[UIImage class] forKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, UIImage *> *)allTextures
|
||||||
|
{
|
||||||
|
return _textures;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
return _textures.hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKCameraEffectTextures class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToCameraEffectTextures:(FBSDKCameraEffectTextures *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToCameraEffectTextures:(FBSDKCameraEffectTextures *)object
|
||||||
|
{
|
||||||
|
return [FBSDKInternalUtility object:_textures isEqualToObject:[object allTextures]];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_textures = [decoder decodeObjectOfClass:[NSMutableDictionary class]
|
||||||
|
forKey:FBSDKCameraEffectTexturesTexturesKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_textures forKey:FBSDKCameraEffectTexturesTexturesKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKCameraEffectTextures *copy = [FBSDKCameraEffectTextures new];
|
||||||
|
copy->_textures = [_textures copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_setValue:(id)value forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
if (value) {
|
||||||
|
_textures[key] = value;
|
||||||
|
} else {
|
||||||
|
[_textures removeObjectForKey:key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)_valueForKey:(NSString *)key
|
||||||
|
{
|
||||||
|
key = [FBSDKTypeUtility stringValue:key];
|
||||||
|
return (key ? [FBSDKTypeUtility objectValue:_textures[key]] : nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)_valueOfClass:(__unsafe_unretained Class)cls forKey:(NSString *)key
|
||||||
|
{
|
||||||
|
id value = [self _valueForKey:key];
|
||||||
|
return ([value isKindOfClass:cls] ? value : nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
142
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestContent.h
generated
Normal file
142
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestContent.h
generated
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingValidation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKGameRequestActionType)
|
||||||
|
Additional context about the nature of the request.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKGameRequestActionType)
|
||||||
|
{
|
||||||
|
/** No action type */
|
||||||
|
FBSDKGameRequestActionTypeNone = 0,
|
||||||
|
/** Send action type: The user is sending an object to the friends. */
|
||||||
|
FBSDKGameRequestActionTypeSend,
|
||||||
|
/** Ask For action type: The user is asking for an object from friends. */
|
||||||
|
FBSDKGameRequestActionTypeAskFor,
|
||||||
|
/** Turn action type: It is the turn of the friends to play against the user in a match. (no object) */
|
||||||
|
FBSDKGameRequestActionTypeTurn,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKGameRequestFilters)
|
||||||
|
Filter for who can be displayed in the multi-friend selector.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKGameRequestFilter)
|
||||||
|
{
|
||||||
|
/** No filter, all friends can be displayed. */
|
||||||
|
FBSDKGameRequestFilterNone = 0,
|
||||||
|
/** Friends using the app can be displayed. */
|
||||||
|
FBSDKGameRequestFilterAppUsers,
|
||||||
|
/** Friends not using the app can be displayed. */
|
||||||
|
FBSDKGameRequestFilterAppNonUsers,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for a game request.
|
||||||
|
*/
|
||||||
|
@interface FBSDKGameRequestContent : NSObject <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Used when defining additional context about the nature of the request.
|
||||||
|
|
||||||
|
The parameter 'objectID' is required if the action type is either
|
||||||
|
'FBSDKGameRequestSendActionType' or 'FBSDKGameRequestAskForActionType'.
|
||||||
|
|
||||||
|
- SeeAlso:objectID
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKGameRequestActionType actionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another game request content.
|
||||||
|
@param content The other content
|
||||||
|
@return YES if the receiver's values are equal to the other content's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToGameRequestContent:(FBSDKGameRequestContent *)content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Additional freeform data you may pass for tracking. This will be stored as part of
|
||||||
|
the request objects created. The maximum length is 255 characters.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This controls the set of friends someone sees if a multi-friend selector is shown.
|
||||||
|
It is FBSDKGameRequestNoFilter by default, meaning that all friends can be shown.
|
||||||
|
If specify as FBSDKGameRequestAppUsersFilter, only friends who use the app will be shown.
|
||||||
|
On the other hands, use FBSDKGameRequestAppNonUsersFilter to filter only friends who do not use the app.
|
||||||
|
|
||||||
|
The parameter name is preserved to be consistent with the counter part on desktop.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKGameRequestFilter filters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A plain-text message to be sent as part of the request. This text will surface in the App Center view
|
||||||
|
of the request, but not on the notification jewel. Required parameter.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The Open Graph object ID of the object being sent.
|
||||||
|
|
||||||
|
- SeeAlso:actionType
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *objectID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
An array of user IDs, usernames or invite tokens (NSString) of people to send request.
|
||||||
|
|
||||||
|
These may or may not be a friend of the sender. If this is specified by the app,
|
||||||
|
the sender will not have a choice of recipients. If not, the sender will see a multi-friend selector
|
||||||
|
|
||||||
|
This is equivalent to the "to" parameter when using the web game request dialog.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSArray *recipients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
An array of user IDs that will be included in the dialog as the first suggested friends.
|
||||||
|
Cannot be used together with filters.
|
||||||
|
|
||||||
|
This is equivalent to the "suggestions" parameter when using the web game request dialog.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSArray *recipientSuggestions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning Use `recipientSuggestions` instead.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSArray *suggestions
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("use recipientSuggestions instead");
|
||||||
|
|
||||||
|
/**
|
||||||
|
The title for the dialog.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
@warning Use `recipients` instead.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSArray *to
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("use recipients instead");
|
||||||
|
|
||||||
|
@end
|
||||||
249
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestContent.m
generated
Normal file
249
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestContent.m
generated
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKGameRequestContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_TO_KEY @"to"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_MESSAGE_KEY @"message"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_ACTION_TYPE_KEY @"actionType"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_OBJECT_ID_KEY @"objectID"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_FILTERS_KEY @"filters"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_SUGGESTIONS_KEY @"suggestions"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_DATA_KEY @"data"
|
||||||
|
#define FBSDK_APP_REQUEST_CONTENT_TITLE_KEY @"title"
|
||||||
|
|
||||||
|
@implementation FBSDKGameRequestContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
-(void)setRecipients:(NSArray *)recipients
|
||||||
|
{
|
||||||
|
[FBSDKShareUtility assertCollection:recipients ofClass:[NSString class] name:@"recipients"];
|
||||||
|
if (![_recipients isEqual:recipients]) {
|
||||||
|
_recipients = [recipients copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setRecipientSuggestions:(NSArray *)recipientSuggestions
|
||||||
|
{
|
||||||
|
[FBSDKShareUtility assertCollection:recipientSuggestions ofClass:[NSString class] name:@"recipientSuggestions"];
|
||||||
|
if (![_recipientSuggestions isEqual:recipientSuggestions]) {
|
||||||
|
_recipientSuggestions = [recipientSuggestions copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)suggestions
|
||||||
|
{
|
||||||
|
return self.recipientSuggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setSuggestions:(NSArray *)suggestions
|
||||||
|
{
|
||||||
|
self.recipientSuggestions = suggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)to
|
||||||
|
{
|
||||||
|
return self.recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTo:(NSArray *)to
|
||||||
|
{
|
||||||
|
self.recipients = to;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (![FBSDKShareUtility validateRequiredValue:_message name:@"message" error:errorRef]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
BOOL mustHaveobjectID = _actionType == FBSDKGameRequestActionTypeSend
|
||||||
|
|| _actionType == FBSDKGameRequestActionTypeAskFor;
|
||||||
|
BOOL hasobjectID = _objectID.length > 0;
|
||||||
|
if (mustHaveobjectID ^ hasobjectID) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
NSString *message = @"The objectID is required when the actionType is either send or askfor.";
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"objectID"
|
||||||
|
message:message];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
BOOL hasTo = _recipients.count > 0;
|
||||||
|
BOOL hasFilters = _filters != FBSDKGameRequestFilterNone;
|
||||||
|
BOOL hasSuggestions = _recipientSuggestions.count > 0;
|
||||||
|
if (hasTo && hasFilters) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
NSString *message = @"Cannot specify to and filters at the same time.";
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"recipients"
|
||||||
|
value:_recipients
|
||||||
|
message:message];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (hasTo && hasSuggestions) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
NSString *message = @"Cannot specify to and suggestions at the same time.";
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"recipients"
|
||||||
|
value:_recipients
|
||||||
|
message:message];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasFilters && hasSuggestions) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
NSString *message = @"Cannot specify filters and suggestions at the same time.";
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"recipientSuggestions"
|
||||||
|
value:_recipientSuggestions
|
||||||
|
message:message];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_data.length > 255) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
NSString *message = @"The data cannot be longer than 255 characters";
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"data"
|
||||||
|
value:_data
|
||||||
|
message:message];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [FBSDKShareUtility validateArgumentWithName:@"actionType"
|
||||||
|
value:_actionType
|
||||||
|
isIn:@[@(FBSDKGameRequestActionTypeNone),
|
||||||
|
@(FBSDKGameRequestActionTypeSend),
|
||||||
|
@(FBSDKGameRequestActionTypeAskFor),
|
||||||
|
@(FBSDKGameRequestActionTypeTurn)]
|
||||||
|
error:errorRef]
|
||||||
|
&& [FBSDKShareUtility validateArgumentWithName:@"filters"
|
||||||
|
value:_filters
|
||||||
|
isIn:@[@(FBSDKGameRequestFilterNone),
|
||||||
|
@(FBSDKGameRequestFilterAppUsers),
|
||||||
|
@(FBSDKGameRequestFilterAppNonUsers)]
|
||||||
|
error:errorRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
NSUInteger subhashes[] = {
|
||||||
|
[FBSDKMath hashWithInteger:_actionType],
|
||||||
|
_data.hash,
|
||||||
|
[FBSDKMath hashWithInteger:_filters],
|
||||||
|
_message.hash,
|
||||||
|
_objectID.hash,
|
||||||
|
_recipientSuggestions.hash,
|
||||||
|
_title.hash,
|
||||||
|
_recipients.hash,
|
||||||
|
};
|
||||||
|
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKGameRequestContent class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToGameRequestContent:(FBSDKGameRequestContent *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToGameRequestContent:(FBSDKGameRequestContent *)content
|
||||||
|
{
|
||||||
|
return (content &&
|
||||||
|
_actionType == content.actionType &&
|
||||||
|
_filters == content.filters &&
|
||||||
|
[FBSDKInternalUtility object:_data isEqualToObject:content.data] &&
|
||||||
|
[FBSDKInternalUtility object:_message isEqualToObject:content.message] &&
|
||||||
|
[FBSDKInternalUtility object:_objectID isEqualToObject:content.objectID] &&
|
||||||
|
[FBSDKInternalUtility object:_recipientSuggestions isEqualToObject:content.recipientSuggestions] &&
|
||||||
|
[FBSDKInternalUtility object:_title isEqualToObject:content.title] &&
|
||||||
|
[FBSDKInternalUtility object:_recipients isEqualToObject:content.recipients]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_actionType = [decoder decodeIntegerForKey:FBSDK_APP_REQUEST_CONTENT_ACTION_TYPE_KEY];
|
||||||
|
_data = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_APP_REQUEST_CONTENT_DATA_KEY];
|
||||||
|
_filters = [decoder decodeIntegerForKey:FBSDK_APP_REQUEST_CONTENT_FILTERS_KEY];
|
||||||
|
_message = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_APP_REQUEST_CONTENT_MESSAGE_KEY];
|
||||||
|
_objectID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_APP_REQUEST_CONTENT_OBJECT_ID_KEY];
|
||||||
|
_recipientSuggestions = [decoder decodeObjectOfClass:[NSArray class] forKey:FBSDK_APP_REQUEST_CONTENT_SUGGESTIONS_KEY];
|
||||||
|
_title = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_APP_REQUEST_CONTENT_TITLE_KEY];
|
||||||
|
_recipients = [decoder decodeObjectOfClass:[NSArray class] forKey:FBSDK_APP_REQUEST_CONTENT_TO_KEY];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeInteger:_actionType forKey:FBSDK_APP_REQUEST_CONTENT_ACTION_TYPE_KEY];
|
||||||
|
[encoder encodeObject:_data forKey:FBSDK_APP_REQUEST_CONTENT_DATA_KEY];
|
||||||
|
[encoder encodeInteger:_filters forKey:FBSDK_APP_REQUEST_CONTENT_FILTERS_KEY];
|
||||||
|
[encoder encodeObject:_message forKey:FBSDK_APP_REQUEST_CONTENT_MESSAGE_KEY];
|
||||||
|
[encoder encodeObject:_objectID forKey:FBSDK_APP_REQUEST_CONTENT_OBJECT_ID_KEY];
|
||||||
|
[encoder encodeObject:_recipientSuggestions forKey:FBSDK_APP_REQUEST_CONTENT_SUGGESTIONS_KEY];
|
||||||
|
[encoder encodeObject:_title forKey:FBSDK_APP_REQUEST_CONTENT_TITLE_KEY];
|
||||||
|
[encoder encodeObject:_recipients forKey:FBSDK_APP_REQUEST_CONTENT_TO_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKGameRequestContent *copy = [[FBSDKGameRequestContent alloc] init];
|
||||||
|
copy->_actionType = _actionType;
|
||||||
|
copy->_data = [_data copy];
|
||||||
|
copy->_filters = _filters;
|
||||||
|
copy->_message = [_message copy];
|
||||||
|
copy->_objectID = [_objectID copy];
|
||||||
|
copy->_recipientSuggestions = [_recipientSuggestions copy];
|
||||||
|
copy->_title = [_title copy];
|
||||||
|
copy->_recipients = [_recipients copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
108
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestDialog.h
generated
Normal file
108
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestDialog.h
generated
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKGameRequestContent.h>
|
||||||
|
|
||||||
|
@protocol FBSDKGameRequestDialogDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A dialog for sending game requests.
|
||||||
|
*/
|
||||||
|
@interface FBSDKGameRequestDialog : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to build up a game request with content and a delegate.
|
||||||
|
@param content The content for the game request.
|
||||||
|
@param delegate The receiver's delegate.
|
||||||
|
*/
|
||||||
|
+ (instancetype)showWithContent:(FBSDKGameRequestContent *)content delegate:(id<FBSDKGameRequestDialogDelegate>)delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The receiver's delegate or nil if it doesn't have a delegate.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) id<FBSDKGameRequestDialogDelegate> delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The content for game request.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) FBSDKGameRequestContent *content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Specifies whether frictionless requests are enabled.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL frictionlessRequestsEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A Boolean value that indicates whether the receiver can initiate a game request.
|
||||||
|
|
||||||
|
May return NO if the appropriate Facebook app is not installed and is required or an access token is
|
||||||
|
required but not available. This method does not validate the content on the receiver, so this can be checked before
|
||||||
|
building up the content.
|
||||||
|
|
||||||
|
@see validateWithError:
|
||||||
|
@return YES if the receiver can share, otherwise NO.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) BOOL canShow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Begins the game request from the receiver.
|
||||||
|
@return YES if the receiver was able to show the dialog, otherwise NO.
|
||||||
|
*/
|
||||||
|
- (BOOL)show;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Validates the content on the receiver.
|
||||||
|
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||||
|
@return YES if the content is valid, otherwise NO.
|
||||||
|
*/
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
A delegate for FBSDKGameRequestDialog.
|
||||||
|
|
||||||
|
The delegate is notified with the results of the game request as long as the application has permissions to
|
||||||
|
receive the information. For example, if the person is not signed into the containing app, the shower may not be able
|
||||||
|
to distinguish between completion of a game request and cancellation.
|
||||||
|
*/
|
||||||
|
@protocol FBSDKGameRequestDialogDelegate <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the game request completes without error.
|
||||||
|
@param gameRequestDialog The FBSDKGameRequestDialog that completed.
|
||||||
|
@param results The results from the dialog. This may be nil or empty.
|
||||||
|
*/
|
||||||
|
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didCompleteWithResults:(NSDictionary *)results;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the game request encounters an error.
|
||||||
|
@param gameRequestDialog The FBSDKGameRequestDialog that completed.
|
||||||
|
@param error The error.
|
||||||
|
*/
|
||||||
|
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didFailWithError:(NSError *)error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sent to the delegate when the game request dialog is cancelled.
|
||||||
|
@param gameRequestDialog The FBSDKGameRequestDialog that completed.
|
||||||
|
*/
|
||||||
|
- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog;
|
||||||
|
|
||||||
|
@end
|
||||||
277
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestDialog.m
generated
Normal file
277
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKGameRequestDialog.m
generated
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKGameRequestDialog.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKGameRequestFrictionlessRecipientCache.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
@interface FBSDKGameRequestDialog () <FBSDKWebDialogDelegate>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKGameRequestDialog
|
||||||
|
{
|
||||||
|
BOOL _dialogIsFrictionless;
|
||||||
|
FBSDKWebDialog *_webDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FBSDK_APP_REQUEST_METHOD_NAME @"apprequests"
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
static FBSDKGameRequestFrictionlessRecipientCache *_recipientCache = nil;
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if (self == [FBSDKGameRequestDialog class]) {
|
||||||
|
_recipientCache = [[FBSDKGameRequestFrictionlessRecipientCache alloc] init];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)showWithContent:(FBSDKGameRequestContent *)content delegate:(id<FBSDKGameRequestDialogDelegate>)delegate
|
||||||
|
{
|
||||||
|
FBSDKGameRequestDialog *dialog = [[self alloc] init];
|
||||||
|
dialog.content = content;
|
||||||
|
dialog.delegate = delegate;
|
||||||
|
[dialog show];
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_webDialog = [[FBSDKWebDialog alloc] init];
|
||||||
|
_webDialog.delegate = self;
|
||||||
|
_webDialog.name = FBSDK_APP_REQUEST_METHOD_NAME;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
_webDialog.delegate = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (BOOL)canShow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)show
|
||||||
|
{
|
||||||
|
NSError *error;
|
||||||
|
if (!self.canShow) {
|
||||||
|
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorDialogNotAvailable
|
||||||
|
message:@"Game request dialog is not available."];
|
||||||
|
[_delegate gameRequestDialog:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self validateWithError:&error]) {
|
||||||
|
[_delegate gameRequestDialog:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FBSDKGameRequestContent *content = self.content;
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:[content.recipients componentsJoinedByString:@","] forKey:@"to"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.message forKey:@"message"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:[self _actionTypeNameForActionType:content.actionType] forKey:@"action_type"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.objectID forKey:@"object_id"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:[self _filtersNameForFilters:content.filters] forKey:@"filters"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:[content.recipientSuggestions componentsJoinedByString:@","] forKey:@"suggestions"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.data forKey:@"data"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.title forKey:@"title"];
|
||||||
|
|
||||||
|
// check if we are sending to a specific set of recipients. if we are and they are all frictionless recipients, we
|
||||||
|
// can perform this action without displaying the web dialog
|
||||||
|
_webDialog.deferVisibility = NO;
|
||||||
|
NSArray *recipients = content.recipients;
|
||||||
|
if (_frictionlessRequestsEnabled && recipients) {
|
||||||
|
// specify these parameters to get the frictionless recipients from the dialog when it is presented
|
||||||
|
parameters[@"frictionless"] = @YES;
|
||||||
|
parameters[@"get_frictionless_recipients"] = @YES;
|
||||||
|
|
||||||
|
_dialogIsFrictionless = YES;
|
||||||
|
if ([_recipientCache recipientsAreFrictionless:recipients]) {
|
||||||
|
_webDialog.deferVisibility = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_webDialog.parameters = parameters;
|
||||||
|
[_webDialog show];
|
||||||
|
[FBSDKInternalUtility registerTransientObject:self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (![FBSDKShareUtility validateRequiredValue:self.content name:@"content" error:errorRef]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if ([self.content respondsToSelector:@selector(validateWithOptions:error:)]) {
|
||||||
|
return [self.content validateWithOptions:FBSDKShareBridgeOptionsDefault error:errorRef];
|
||||||
|
}
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"content"
|
||||||
|
value:self.content
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKWebDialogDelegate
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didCompleteWithResults:(NSDictionary *)results
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_dialogIsFrictionless && results) {
|
||||||
|
[_recipientCache updateWithResults:results];
|
||||||
|
}
|
||||||
|
[self _cleanUp];
|
||||||
|
|
||||||
|
NSError *error = [NSError fbErrorWithCode:[FBSDKTypeUtility unsignedIntegerValue:results[@"error_code"]]
|
||||||
|
message:[FBSDKTypeUtility stringValue:results[@"error_message"]]];
|
||||||
|
if (!error.code) {
|
||||||
|
// reformat "to[x]" keys into an array.
|
||||||
|
int counter = 0;
|
||||||
|
NSMutableArray *toArray = [NSMutableArray array];
|
||||||
|
while (true) {
|
||||||
|
NSString *key = [NSString stringWithFormat:@"to[%d]", counter++];
|
||||||
|
if (results[key]) {
|
||||||
|
[toArray addObject:results[key]];
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (toArray.count) {
|
||||||
|
NSMutableDictionary *mutableResults = [results mutableCopy];
|
||||||
|
mutableResults[@"to"] = toArray;
|
||||||
|
results = mutableResults;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[self _handleCompletionWithDialogResults:results error:error];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialog:(FBSDKWebDialog *)webDialog didFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self _cleanUp];
|
||||||
|
[self _handleCompletionWithDialogResults:nil error:error];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webDialogDidCancel:(FBSDKWebDialog *)webDialog
|
||||||
|
{
|
||||||
|
if (_webDialog != webDialog) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self _cleanUp];
|
||||||
|
[_delegate gameRequestDialogDidCancel:self];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_cleanUp
|
||||||
|
{
|
||||||
|
_dialogIsFrictionless = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_handleCompletionWithDialogResults:(NSDictionary *)results error:(NSError *)error
|
||||||
|
{
|
||||||
|
if (!_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (error.code) {
|
||||||
|
case 0:{
|
||||||
|
[_delegate gameRequestDialog:self didCompleteWithResults:results];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4201:{
|
||||||
|
[_delegate gameRequestDialogDidCancel:self];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
[_delegate gameRequestDialog:self didFailWithError:error];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_actionTypeNameForActionType:(FBSDKGameRequestActionType)actionType
|
||||||
|
{
|
||||||
|
switch (actionType) {
|
||||||
|
case FBSDKGameRequestActionTypeNone:{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
case FBSDKGameRequestActionTypeSend:{
|
||||||
|
return @"send";
|
||||||
|
}
|
||||||
|
case FBSDKGameRequestActionTypeAskFor:{
|
||||||
|
return @"askfor";
|
||||||
|
}
|
||||||
|
case FBSDKGameRequestActionTypeTurn:{
|
||||||
|
return @"turn";
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_filtersNameForFilters:(FBSDKGameRequestFilter)filters
|
||||||
|
{
|
||||||
|
switch (filters) {
|
||||||
|
case FBSDKGameRequestFilterNone:{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
case FBSDKGameRequestFilterAppUsers:{
|
||||||
|
return @"app_users";
|
||||||
|
}
|
||||||
|
case FBSDKGameRequestFilterAppNonUsers:{
|
||||||
|
return @"app_non_users";
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
61
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKHashtag.h
generated
Normal file
61
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKHashtag.h
generated
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Represents a single hashtag that can be used with the share dialog.
|
||||||
|
*/
|
||||||
|
@interface FBSDKHashtag : NSObject <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to build a new hashtag with a string identifier. Equivalent to setting the
|
||||||
|
`stringRepresentation` property.
|
||||||
|
@param hashtagString The hashtag string.
|
||||||
|
*/
|
||||||
|
+ (instancetype)hashtagWithString:(NSString *)hashtagString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The hashtag string.
|
||||||
|
|
||||||
|
You are responsible for making sure that `stringRepresentation` is a valid hashtag (a single '#' followed
|
||||||
|
by one or more word characters). Invalid hashtags are ignored when sharing content. You can check validity with the
|
||||||
|
`valid` property.
|
||||||
|
@return The hashtag string.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *stringRepresentation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Tests if a hashtag is valid.
|
||||||
|
|
||||||
|
A valid hashtag matches the regular expression "#\w+": A single '#' followed by one or more
|
||||||
|
word characters.
|
||||||
|
@return YES if the hashtag is valid, NO otherwise.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly, assign, getter=isValid) BOOL valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another hashtag.
|
||||||
|
@param hashtag The other hashtag
|
||||||
|
@return YES if the receiver is equal to the other hashtag; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToHashtag:(FBSDKHashtag *)hashtag;
|
||||||
|
|
||||||
|
@end
|
||||||
123
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKHashtag.m
generated
Normal file
123
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKHashtag.m
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKHashtag.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
#define FBSDK_HASHTAG_STRING_KEY @"hashtag"
|
||||||
|
|
||||||
|
static NSRegularExpression *HashtagRegularExpression()
|
||||||
|
{
|
||||||
|
static NSRegularExpression *hashtagRegularExpression = nil;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
hashtagRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"^#\\w+$" options:0 error:NULL];
|
||||||
|
});
|
||||||
|
return hashtagRegularExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation FBSDKHashtag
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (instancetype)hashtagWithString:(NSString *)hashtagString
|
||||||
|
{
|
||||||
|
FBSDKHashtag *hashtag = [[self alloc] init];
|
||||||
|
hashtag.stringRepresentation = hashtagString;
|
||||||
|
return hashtag;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
- (NSString *)description
|
||||||
|
{
|
||||||
|
if (self.valid) {
|
||||||
|
return _stringRepresentation;
|
||||||
|
} else {
|
||||||
|
return [NSString stringWithFormat:@"Invalid hashtag '%@'", _stringRepresentation];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isValid
|
||||||
|
{
|
||||||
|
if (_stringRepresentation == nil) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
NSRange fullString = NSMakeRange(0, _stringRepresentation.length);
|
||||||
|
NSRegularExpression *hashtagRegularExpression = HashtagRegularExpression();
|
||||||
|
NSUInteger numberOfMatches = [hashtagRegularExpression numberOfMatchesInString:_stringRepresentation
|
||||||
|
options:0
|
||||||
|
range:fullString];
|
||||||
|
return numberOfMatches > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
return _stringRepresentation.hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKHashtag class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToHashtag:(FBSDKHashtag *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToHashtag:(FBSDKHashtag *)hashtag
|
||||||
|
{
|
||||||
|
return (hashtag &&
|
||||||
|
[FBSDKInternalUtility object:_stringRepresentation isEqualToObject:hashtag.stringRepresentation]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)aDecoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_stringRepresentation = [aDecoder decodeObjectOfClass:[NSString class] forKey:FBSDK_HASHTAG_STRING_KEY];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)aCoder
|
||||||
|
{
|
||||||
|
[aCoder encodeObject:_stringRepresentation forKey:FBSDK_HASHTAG_STRING_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKHashtag *copy = [[FBSDKHashtag alloc] init];
|
||||||
|
copy.stringRepresentation = [_stringRepresentation copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
45
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeButton.h
generated
Normal file
45
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeButton.h
generated
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKButton.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKLikeObjectType.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKLiking.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Warning: This class is deprecated.
|
||||||
|
A button to like an object.
|
||||||
|
|
||||||
|
Tapping the receiver will invoke an API call to the Facebook app through a fast-app-switch that allows
|
||||||
|
the object to be liked. Upon return to the calling app, the view will update with the new state. If the
|
||||||
|
currentAccessToken has "publish_actions" permission and the object is an Open Graph object, then the like can happen
|
||||||
|
seamlessly without the fast-app-switch.
|
||||||
|
*/
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("This is no longer available")
|
||||||
|
@interface FBSDKLikeButton : FBSDKButton <FBSDKLiking>
|
||||||
|
|
||||||
|
/**
|
||||||
|
If YES, a sound is played when the receiver is toggled.
|
||||||
|
|
||||||
|
@default YES
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign, getter = isSoundEnabled) BOOL soundEnabled;
|
||||||
|
|
||||||
|
@end
|
||||||
294
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeButton.m
generated
Normal file
294
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeButton.m
generated
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLikeButton.h"
|
||||||
|
#import "FBSDKLikeButton+Internal.h"
|
||||||
|
|
||||||
|
#import "FBSDKCheckmarkIcon.h"
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLikeActionController.h"
|
||||||
|
#import "FBSDKLikeControl+Internal.h"
|
||||||
|
|
||||||
|
#define FBSDK_LIKE_BUTTON_ANIMATION_DURATION 0.2
|
||||||
|
#define FBSDK_LIKE_BUTTON_ANIMATION_SPRING_DAMPING 0.3
|
||||||
|
#define FBSDK_LIKE_BUTTON_ANIMATION_SPRING_VELOCITY 0.2
|
||||||
|
|
||||||
|
@implementation FBSDKLikeButton
|
||||||
|
{
|
||||||
|
BOOL _isExplicitlyDisabled;
|
||||||
|
FBSDKLikeActionController *_likeActionController;
|
||||||
|
NSString *_objectID;
|
||||||
|
FBSDKLikeObjectType _objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if ([FBSDKLikeButton class] == self) {
|
||||||
|
// ensure that we have updated the dialog configs if we haven't already
|
||||||
|
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:NULL];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
[_likeActionController endContentAccess];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
- (FBSDKLikeActionController *)likeActionController
|
||||||
|
{
|
||||||
|
[self _ensureLikeActionController:NO];
|
||||||
|
return _likeActionController;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setLikeActionController:(FBSDKLikeActionController *)likeActionController
|
||||||
|
{
|
||||||
|
[self _setLikeActionController:likeActionController];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)objectID
|
||||||
|
{
|
||||||
|
return _objectID;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setObjectID:(NSString *)objectID
|
||||||
|
{
|
||||||
|
if (![_objectID isEqualToString:objectID]) {
|
||||||
|
_objectID = objectID;
|
||||||
|
[self checkImplicitlyDisabled];
|
||||||
|
[self _resetLikeActionController];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (FBSDKLikeObjectType)objectType
|
||||||
|
{
|
||||||
|
return _objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setObjectType:(FBSDKLikeObjectType)objectType
|
||||||
|
{
|
||||||
|
if (_objectType != objectType) {
|
||||||
|
_objectType = objectType;
|
||||||
|
[self _resetLikeActionController];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Layout
|
||||||
|
|
||||||
|
- (void)layoutSubviews
|
||||||
|
{
|
||||||
|
[self _ensureLikeActionController:YES];
|
||||||
|
[super layoutSubviews];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButtonImpressionTracking
|
||||||
|
|
||||||
|
- (NSDictionary *)analyticsParameters
|
||||||
|
{
|
||||||
|
UIView *superview = self.superview;
|
||||||
|
while (superview && ![superview isKindOfClass:[FBSDKLikeControl class]]) {
|
||||||
|
superview = superview.superview;
|
||||||
|
}
|
||||||
|
if ([superview isKindOfClass:[FBSDKLikeControl class]]) {
|
||||||
|
return ((FBSDKLikeControl *)superview).analyticsParameters;
|
||||||
|
}
|
||||||
|
return @{
|
||||||
|
@"object_id": (self.objectID ?: [NSNull null]),
|
||||||
|
@"object_type": (NSStringFromFBSDKLikeObjectType(self.objectType) ?: [NSNull null]),
|
||||||
|
@"sound_enabled": @(self.soundEnabled),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingEventName
|
||||||
|
{
|
||||||
|
return FBSDKAppEventNameFBSDKLikeButtonImpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingIdentifier
|
||||||
|
{
|
||||||
|
return self.objectID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButton
|
||||||
|
|
||||||
|
- (void)configureButton
|
||||||
|
{
|
||||||
|
self.soundEnabled = YES;
|
||||||
|
|
||||||
|
NSString *title =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LikeButton.Like", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Like",
|
||||||
|
@"The label for the FBSDKLikeButton when the object is not currently liked.");
|
||||||
|
NSString *selectedTitle =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"LikeButton.Liked", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Liked",
|
||||||
|
@"The label for the FBSDKLikeButton when the object is currently liked.");
|
||||||
|
|
||||||
|
UIColor *backgroundColor = [self defaultBackgroundColor];
|
||||||
|
UIColor *highlightedColor = [self defaultHighlightedColor];
|
||||||
|
UIColor *selectedColor = [self defaultSelectedColor];
|
||||||
|
UIColor *selectedHighlightedColor = [UIColor colorWithRed:99.0/255.0 green:119.0/255.0 blue:178.0/255.0 alpha:1.0];
|
||||||
|
|
||||||
|
[self configureWithIcon:nil
|
||||||
|
title:title
|
||||||
|
backgroundColor:backgroundColor
|
||||||
|
highlightedColor:highlightedColor
|
||||||
|
selectedTitle:selectedTitle
|
||||||
|
selectedIcon:[[FBSDKCheckmarkIcon alloc] init]
|
||||||
|
selectedColor:selectedColor
|
||||||
|
selectedHighlightedColor:selectedHighlightedColor];
|
||||||
|
|
||||||
|
[self addTarget:self action:@selector(_handleTap:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
[nc addObserver:self
|
||||||
|
selector:@selector(_likeActionControllerDidDisableNotification:)
|
||||||
|
name:FBSDKLikeActionControllerDidDisableNotification
|
||||||
|
object:nil];
|
||||||
|
[nc addObserver:self
|
||||||
|
selector:@selector(_likeActionControllerDidResetNotification:)
|
||||||
|
name:FBSDKLikeActionControllerDidResetNotification
|
||||||
|
object:nil];
|
||||||
|
[nc addObserver:self
|
||||||
|
selector:@selector(_likeActionControllerDidUpdateNotification:)
|
||||||
|
name:FBSDKLikeActionControllerDidUpdateNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isImplicitlyDisabled
|
||||||
|
{
|
||||||
|
return !self.objectID || [FBSDKLikeActionController isDisabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_ensureLikeActionController:(BOOL)notifyKVO
|
||||||
|
{
|
||||||
|
if (!_likeActionController) {
|
||||||
|
FBSDKLikeActionController *likeActionController = [FBSDKLikeActionController likeActionControllerForObjectID:_objectID
|
||||||
|
objectType:_objectType];
|
||||||
|
if (notifyKVO) {
|
||||||
|
self.likeActionController = likeActionController;
|
||||||
|
} else {
|
||||||
|
[self _setLikeActionController:likeActionController];
|
||||||
|
}
|
||||||
|
[likeActionController endContentAccess];
|
||||||
|
self.selected = _likeActionController.objectIsLiked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_handleTap:(FBSDKLikeButton *)likeButton
|
||||||
|
{
|
||||||
|
[self logTapEventWithEventName:FBSDKAppEventNameFBSDKLikeButtonDidTap parameters:self.analyticsParameters];
|
||||||
|
[self _ensureLikeActionController:YES];
|
||||||
|
[_likeActionController toggleLikeWithSoundEnabled:self.soundEnabled
|
||||||
|
analyticsParameters:self.analyticsParameters
|
||||||
|
fromViewController:[FBSDKInternalUtility viewControllerForView:self]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_like:(id)sender
|
||||||
|
{
|
||||||
|
[_likeActionController toggleLikeWithSoundEnabled:_soundEnabled
|
||||||
|
analyticsParameters:self.analyticsParameters
|
||||||
|
fromViewController:[FBSDKInternalUtility viewControllerForView:self]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_likeActionControllerDidDisableNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[self checkImplicitlyDisabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_likeActionControllerDidResetNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[self _resetLikeActionController];
|
||||||
|
[self _ensureLikeActionController:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_likeActionControllerDidUpdateNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[self _ensureLikeActionController:YES];
|
||||||
|
FBSDKLikeActionController *likeActionController = (FBSDKLikeActionController *)notification.object;
|
||||||
|
NSString *objectID = likeActionController.objectID;
|
||||||
|
if ([self.objectID isEqualToString:objectID]) {
|
||||||
|
BOOL animated = [notification.userInfo[FBSDKLikeActionControllerAnimatedKey] boolValue];
|
||||||
|
[self _setSelected:likeActionController.objectIsLiked animated:animated];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_resetLikeActionController
|
||||||
|
{
|
||||||
|
self.likeActionController = nil;
|
||||||
|
[self setNeedsLayout];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_setLikeActionController:(FBSDKLikeActionController *)likeActionController
|
||||||
|
{
|
||||||
|
if (_likeActionController != likeActionController) {
|
||||||
|
[_likeActionController endContentAccess];
|
||||||
|
_likeActionController = likeActionController;
|
||||||
|
[_likeActionController beginContentAccess];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_setSelected:(BOOL)selected animated:(BOOL)animated
|
||||||
|
{
|
||||||
|
if (self.selected != selected) {
|
||||||
|
if (animated) {
|
||||||
|
CFTimeInterval duration = FBSDK_LIKE_BUTTON_ANIMATION_DURATION;
|
||||||
|
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState;
|
||||||
|
UIImageView *imageView = self.imageView;
|
||||||
|
imageView.frame = [self imageRectForContentRect:UIEdgeInsetsInsetRect(self.bounds, self.contentEdgeInsets)];
|
||||||
|
[UIView animateWithDuration:duration delay:0.0 options:options animations:^{
|
||||||
|
CGPoint iconImageViewCenter = imageView.center;
|
||||||
|
imageView.frame = CGRectMake(iconImageViewCenter.x, iconImageViewCenter.y, 0.0, 0.0);
|
||||||
|
} completion:^(BOOL animateOutFinished) {
|
||||||
|
self.selected = selected;
|
||||||
|
CGPoint iconImageViewCenter = imageView.center;
|
||||||
|
imageView.frame = CGRectMake(iconImageViewCenter.x, iconImageViewCenter.y, 0.0, 0.0);
|
||||||
|
|
||||||
|
void(^animations)(void) = ^{
|
||||||
|
imageView.frame = [self imageRectForContentRect:UIEdgeInsetsInsetRect(self.bounds, self.contentEdgeInsets)];
|
||||||
|
};
|
||||||
|
if ([UIView respondsToSelector:@selector(animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)]) {
|
||||||
|
[UIView animateWithDuration:(duration * 2)
|
||||||
|
delay:0.0
|
||||||
|
usingSpringWithDamping:FBSDK_LIKE_BUTTON_ANIMATION_SPRING_DAMPING
|
||||||
|
initialSpringVelocity:FBSDK_LIKE_BUTTON_ANIMATION_SPRING_VELOCITY
|
||||||
|
options:options
|
||||||
|
animations:animations
|
||||||
|
completion:NULL];
|
||||||
|
} else {
|
||||||
|
[UIView animateWithDuration:(duration * 2)
|
||||||
|
delay:0.0
|
||||||
|
options:options
|
||||||
|
animations:animations
|
||||||
|
completion:NULL];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
self.selected = selected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
142
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeControl.h
generated
Normal file
142
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeControl.h
generated
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKLikeObjectType.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKLiking.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM (NSUInteger, FBSDKLikeControlAuxiliaryPosition)
|
||||||
|
|
||||||
|
Specifies the position of the auxiliary view relative to the like button.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKLikeControlAuxiliaryPosition)
|
||||||
|
{
|
||||||
|
/** The auxiliary view is inline with the like button. */
|
||||||
|
FBSDKLikeControlAuxiliaryPositionInline,
|
||||||
|
/** The auxiliary view is above the like button. */
|
||||||
|
FBSDKLikeControlAuxiliaryPositionTop,
|
||||||
|
/** The auxiliary view is below the like button. */
|
||||||
|
FBSDKLikeControlAuxiliaryPositionBottom,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an FBSDKLikeControlAuxiliaryPosition to an NSString.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *NSStringFromFBSDKLikeControlAuxiliaryPosition(FBSDKLikeControlAuxiliaryPosition auxiliaryPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKLikeControlHorizontalAlignment)
|
||||||
|
|
||||||
|
Specifies the horizontal alignment for FBSDKLikeControlStyleStandard with
|
||||||
|
FBSDKLikeControlAuxiliaryPositionTop or FBSDKLikeControlAuxiliaryPositionBottom.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKLikeControlHorizontalAlignment)
|
||||||
|
{
|
||||||
|
/** The subviews are left aligned. */
|
||||||
|
FBSDKLikeControlHorizontalAlignmentLeft,
|
||||||
|
/** The subviews are center aligned. */
|
||||||
|
FBSDKLikeControlHorizontalAlignmentCenter,
|
||||||
|
/** The subviews are right aligned. */
|
||||||
|
FBSDKLikeControlHorizontalAlignmentRight,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an FBSDKLikeControlHorizontalAlignment to an NSString.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *NSStringFromFBSDKLikeControlHorizontalAlignment(FBSDKLikeControlHorizontalAlignment horizontalAlignment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM (NSUInteger, FBSDKLikeControlStyle)
|
||||||
|
|
||||||
|
Specifies the style of a like control.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKLikeControlStyle)
|
||||||
|
{
|
||||||
|
/** Displays the button and the social sentence. */
|
||||||
|
FBSDKLikeControlStyleStandard = 0,
|
||||||
|
/** Displays the button and a box that contains the like count. */
|
||||||
|
FBSDKLikeControlStyleBoxCount,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an FBSDKLikeControlStyle to an NSString.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *NSStringFromFBSDKLikeControlStyle(FBSDKLikeControlStyle style);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Warning: This class is deprecated.
|
||||||
|
UI control to like an object in the Facebook graph.
|
||||||
|
|
||||||
|
|
||||||
|
Taps on the like button within this control will invoke an API call to the Facebook app through a
|
||||||
|
fast-app-switch that allows the user to like the object. Upon return to the calling app, the view will update
|
||||||
|
with the new state and send actions for the UIControlEventValueChanged event.
|
||||||
|
*/
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("This is no longer available")
|
||||||
|
@interface FBSDKLikeControl : UIControl <FBSDKLiking>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The foreground color to use for the content of the receiver.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) UIColor *foregroundColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The position for the auxiliary view for the receiver.
|
||||||
|
|
||||||
|
|
||||||
|
@see FBSDKLikeControlAuxiliaryPosition
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKLikeControlAuxiliaryPosition likeControlAuxiliaryPosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The text alignment of the social sentence.
|
||||||
|
|
||||||
|
|
||||||
|
This value is only valid for FBSDKLikeControlStyleStandard with
|
||||||
|
FBSDKLikeControlAuxiliaryPositionTop|Bottom.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKLikeControlHorizontalAlignment likeControlHorizontalAlignment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The style to use for the receiver.
|
||||||
|
|
||||||
|
|
||||||
|
@see FBSDKLikeControlStyle
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKLikeControlStyle likeControlStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The preferred maximum width (in points) for autolayout.
|
||||||
|
|
||||||
|
|
||||||
|
This property affects the size of the receiver when layout constraints are applied to it. During layout,
|
||||||
|
if the text extends beyond the width specified by this property, the additional text is flowed to one or more new
|
||||||
|
lines, thereby increasing the height of the receiver.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) CGFloat preferredMaxLayoutWidth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
If YES, a sound is played when the receiver is toggled.
|
||||||
|
|
||||||
|
@default YES
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign, getter = isSoundEnabled) BOOL soundEnabled;
|
||||||
|
|
||||||
|
@end
|
||||||
664
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeControl.m
generated
Normal file
664
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeControl.m
generated
Normal file
@ -0,0 +1,664 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLikeControl.h"
|
||||||
|
#import "FBSDKLikeControl+Internal.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKLikeActionController.h"
|
||||||
|
#import "FBSDKLikeBoxView.h"
|
||||||
|
#import "FBSDKLikeButton+Internal.h"
|
||||||
|
#import "FBSDKLikeButton.h"
|
||||||
|
|
||||||
|
#define kFBLikeControlAnimationDuration 0.2
|
||||||
|
#define kFBLikeControlSocialSentenceAnimationOffset 10.0
|
||||||
|
|
||||||
|
static void *FBSDKLikeControlKVOLikeActionControllerContext = &FBSDKLikeControlKVOLikeActionControllerContext;
|
||||||
|
|
||||||
|
NSString *NSStringFromFBSDKLikeControlAuxiliaryPosition(FBSDKLikeControlAuxiliaryPosition auxiliaryPosition)
|
||||||
|
{
|
||||||
|
switch (auxiliaryPosition) {
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionBottom:
|
||||||
|
return @"bottom";
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionInline:
|
||||||
|
return @"inline";
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionTop:
|
||||||
|
return @"top";
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *NSStringFromFBSDKLikeControlHorizontalAlignment(FBSDKLikeControlHorizontalAlignment horizontalAlignment)
|
||||||
|
{
|
||||||
|
switch (horizontalAlignment) {
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentCenter:
|
||||||
|
return @"center";
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentLeft:
|
||||||
|
return @"left";
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentRight:
|
||||||
|
return @"right";
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *NSStringFromFBSDKLikeControlStyle(FBSDKLikeControlStyle style)
|
||||||
|
{
|
||||||
|
switch (style) {
|
||||||
|
case FBSDKLikeControlStyleBoxCount:
|
||||||
|
return @"box_count";
|
||||||
|
case FBSDKLikeControlStyleStandard:
|
||||||
|
return @"standard";
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct FBSDKLikeControlLayout
|
||||||
|
{
|
||||||
|
CGSize contentSize;
|
||||||
|
CGRect likeButtonFrame;
|
||||||
|
CGRect auxiliaryViewFrame;
|
||||||
|
} FBSDKLikeControlLayout;
|
||||||
|
|
||||||
|
typedef CGSize (^fbsdk_like_control_sizing_block_t)(UIView *subview, CGSize constrainedSize);
|
||||||
|
|
||||||
|
@implementation FBSDKLikeControl
|
||||||
|
{
|
||||||
|
BOOL _isExplicitlyDisabled;
|
||||||
|
FBSDKLikeBoxView *_likeBoxView;
|
||||||
|
FBSDKLikeButton *_likeButton;
|
||||||
|
UIView *_likeButtonContainer;
|
||||||
|
UILabel *_socialSentenceLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if ([FBSDKLikeControl class] == self) {
|
||||||
|
// ensure that we have updated the dialog configs if we haven't already
|
||||||
|
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:NULL];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
- (instancetype)initWithFrame:(CGRect)frame
|
||||||
|
{
|
||||||
|
if ((self = [super initWithFrame:frame])) {
|
||||||
|
[self _initializeContent];
|
||||||
|
if (CGRectEqualToRect(frame, CGRectZero)) {
|
||||||
|
[self sizeToFit];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [super initWithCoder:decoder])) {
|
||||||
|
[self _initializeContent];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
[_likeButton removeObserver:self forKeyPath:@"likeActionController"];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||||
|
{
|
||||||
|
super.backgroundColor = backgroundColor;
|
||||||
|
_likeButtonContainer.backgroundColor = backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setForegroundColor:(UIColor *)foregroundColor
|
||||||
|
{
|
||||||
|
if (![_foregroundColor isEqual:foregroundColor]) {
|
||||||
|
_foregroundColor = foregroundColor;
|
||||||
|
[_likeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||||
|
_socialSentenceLabel.textColor = foregroundColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setEnabled:(BOOL)enabled
|
||||||
|
{
|
||||||
|
_isExplicitlyDisabled = !enabled;
|
||||||
|
[self _updateEnabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setLikeControlAuxiliaryPosition:(FBSDKLikeControlAuxiliaryPosition)likeControlAuxiliaryPosition
|
||||||
|
{
|
||||||
|
if (_likeControlAuxiliaryPosition != likeControlAuxiliaryPosition) {
|
||||||
|
_likeControlAuxiliaryPosition = likeControlAuxiliaryPosition;
|
||||||
|
[self _updateLikeBoxCaretPosition];
|
||||||
|
[self setNeedsLayout];
|
||||||
|
[self setNeedsUpdateConstraints];
|
||||||
|
[self invalidateIntrinsicContentSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setLikeControlHorizontalAlignment:(FBSDKLikeControlHorizontalAlignment)likeControlHorizontalAlignment
|
||||||
|
{
|
||||||
|
if (_likeControlHorizontalAlignment != likeControlHorizontalAlignment) {
|
||||||
|
_likeControlHorizontalAlignment = likeControlHorizontalAlignment;
|
||||||
|
[self _updateLikeBoxCaretPosition];
|
||||||
|
[self setNeedsLayout];
|
||||||
|
[self setNeedsUpdateConstraints];
|
||||||
|
[self invalidateIntrinsicContentSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setLikeControlStyle:(FBSDKLikeControlStyle)likeControlStyle
|
||||||
|
{
|
||||||
|
if (_likeControlStyle != likeControlStyle) {
|
||||||
|
_likeControlStyle = likeControlStyle;
|
||||||
|
[self _updateLikeBoxCaretPosition];
|
||||||
|
[self setNeedsLayout];
|
||||||
|
[self setNeedsUpdateConstraints];
|
||||||
|
[self invalidateIntrinsicContentSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)objectID
|
||||||
|
{
|
||||||
|
return _likeButton.objectID;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setObjectID:(NSString *)objectID
|
||||||
|
{
|
||||||
|
if (![_likeButton.objectID isEqualToString:objectID]) {
|
||||||
|
_likeButton.objectID = objectID;
|
||||||
|
[self _updateEnabled];
|
||||||
|
[self setNeedsLayout];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (FBSDKLikeObjectType)objectType
|
||||||
|
{
|
||||||
|
return _likeButton.objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setObjectType:(FBSDKLikeObjectType)objectType
|
||||||
|
{
|
||||||
|
if (_likeButton.objectType != objectType) {
|
||||||
|
_likeButton.objectType = objectType;
|
||||||
|
[self setNeedsLayout];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setOpaque:(BOOL)opaque
|
||||||
|
{
|
||||||
|
super.opaque = opaque;
|
||||||
|
_likeButtonContainer.opaque = opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isSoundEnabled
|
||||||
|
{
|
||||||
|
return _likeButton.soundEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setSoundEnabled:(BOOL)soundEnabled
|
||||||
|
{
|
||||||
|
_likeButton.soundEnabled = soundEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Layout
|
||||||
|
|
||||||
|
- (CGSize)intrinsicContentSize
|
||||||
|
{
|
||||||
|
CGFloat width = self.preferredMaxLayoutWidth;
|
||||||
|
if (width == 0) {
|
||||||
|
width = CGFLOAT_MAX;
|
||||||
|
}
|
||||||
|
CGRect bounds = CGRectMake(0.0, 0.0, width, CGFLOAT_MAX);
|
||||||
|
return [self _layoutWithBounds:bounds subviewSizingBlock:^CGSize(UIView *subview, CGSize constrainedSize) {
|
||||||
|
if ([subview respondsToSelector:@selector(setPreferredMaxLayoutWidth:)]) {
|
||||||
|
[(id)subview setPreferredMaxLayoutWidth:constrainedSize.width];
|
||||||
|
}
|
||||||
|
return subview.intrinsicContentSize;
|
||||||
|
}].contentSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)layoutSubviews
|
||||||
|
{
|
||||||
|
[super layoutSubviews];
|
||||||
|
|
||||||
|
NSString *objectID = self.objectID;
|
||||||
|
if (objectID) {
|
||||||
|
FBSDKViewImpressionTracker *impressionTracker =
|
||||||
|
[FBSDKViewImpressionTracker impressionTrackerWithEventName:FBSDKAppEventNameFBSDKLikeControlImpression];
|
||||||
|
[impressionTracker logImpressionWithIdentifier:objectID parameters:[self analyticsParameters]];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self _ensureLikeActionController];
|
||||||
|
|
||||||
|
CGRect bounds = self.bounds;
|
||||||
|
CGSize(^sizingBlock)(UIView *, CGSize) = ^CGSize(UIView *subview, CGSize constrainedSize) {
|
||||||
|
return [subview sizeThatFits:constrainedSize];
|
||||||
|
};
|
||||||
|
FBSDKLikeControlLayout layout = [self _layoutWithBounds:bounds subviewSizingBlock:sizingBlock];
|
||||||
|
|
||||||
|
UIView *auxiliaryView = [self _auxiliaryView];
|
||||||
|
_likeBoxView.hidden = (_likeBoxView != auxiliaryView);
|
||||||
|
_socialSentenceLabel.hidden = (_socialSentenceLabel != auxiliaryView);
|
||||||
|
|
||||||
|
_likeButtonContainer.frame = layout.likeButtonFrame;
|
||||||
|
_likeButton.frame = _likeButtonContainer.bounds;
|
||||||
|
auxiliaryView.frame = layout.auxiliaryViewFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGSize)sizeThatFits:(CGSize)size
|
||||||
|
{
|
||||||
|
switch (self.likeControlAuxiliaryPosition) {
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionInline:{
|
||||||
|
size.height = MAX(size.height, CGRectGetHeight(self.bounds));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionTop:
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionBottom:{
|
||||||
|
size.width = MAX(size.width, CGRectGetWidth(self.bounds));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CGRect bounds = CGRectMake(0.0, 0.0, size.width, size.height);
|
||||||
|
return [self _layoutWithBounds:bounds subviewSizingBlock:^CGSize(UIView *subview, CGSize constrainedSize) {
|
||||||
|
return [subview sizeThatFits:constrainedSize];
|
||||||
|
}].contentSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Internal Methods
|
||||||
|
|
||||||
|
- (NSDictionary *)analyticsParameters
|
||||||
|
{
|
||||||
|
return @{
|
||||||
|
@"auxiliary_position": NSStringFromFBSDKLikeControlAuxiliaryPosition(self.likeControlAuxiliaryPosition),
|
||||||
|
@"horizontal_alignment": NSStringFromFBSDKLikeControlHorizontalAlignment(self.likeControlHorizontalAlignment),
|
||||||
|
@"object_id": (self.objectID ?: [NSNull null]),
|
||||||
|
@"object_type": (NSStringFromFBSDKLikeObjectType(self.objectType) ?: [NSNull null]),
|
||||||
|
@"sound_enabled": @(self.soundEnabled),
|
||||||
|
@"style": NSStringFromFBSDKLikeControlStyle(self.likeControlStyle),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (UIView *)_auxiliaryView
|
||||||
|
{
|
||||||
|
[self _ensureLikeActionController];
|
||||||
|
switch (_likeControlStyle) {
|
||||||
|
case FBSDKLikeControlStyleStandard:{
|
||||||
|
return (_socialSentenceLabel.text.length == 0 ? nil : _socialSentenceLabel);
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlStyleBoxCount:{
|
||||||
|
return (_likeButton.likeActionController.likeCountString == nil ? nil : _likeBoxView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGFloat)_auxiliaryViewPadding
|
||||||
|
{
|
||||||
|
switch (_likeControlStyle) {
|
||||||
|
case FBSDKLikeControlStyleStandard:{
|
||||||
|
return 8.0;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlStyleBoxCount:{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_ensureLikeActionController
|
||||||
|
{
|
||||||
|
FBSDKLikeActionController *likeActionController = _likeButton.likeActionController;
|
||||||
|
if (likeActionController) {
|
||||||
|
_socialSentenceLabel.text = likeActionController.socialSentence;
|
||||||
|
_likeBoxView.text = likeActionController.likeCountString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_handleLikeButtonTap:(FBSDKLikeButton *)likeButton
|
||||||
|
{
|
||||||
|
[self _ensureLikeActionController];
|
||||||
|
[self sendActionsForControlEvents:UIControlEventTouchUpInside];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_initializeContent
|
||||||
|
{
|
||||||
|
self.backgroundColor = [UIColor clearColor];
|
||||||
|
_foregroundColor = [UIColor blackColor];
|
||||||
|
|
||||||
|
_likeButtonContainer = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
_likeButtonContainer.backgroundColor = self.backgroundColor;
|
||||||
|
_likeButtonContainer.opaque = self.opaque;
|
||||||
|
[self addSubview:_likeButtonContainer];
|
||||||
|
|
||||||
|
_likeButton = [[FBSDKLikeButton alloc] initWithFrame:CGRectZero];
|
||||||
|
[_likeButton addTarget:self action:@selector(_handleLikeButtonTap:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
[_likeButtonContainer addSubview:_likeButton];
|
||||||
|
|
||||||
|
_socialSentenceLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||||
|
_socialSentenceLabel.font = [UIFont systemFontOfSize:11.0];
|
||||||
|
_socialSentenceLabel.numberOfLines = 2;
|
||||||
|
[self addSubview:_socialSentenceLabel];
|
||||||
|
|
||||||
|
_likeBoxView = [[FBSDKLikeBoxView alloc] initWithFrame:CGRectZero];
|
||||||
|
[self addSubview:_likeBoxView];
|
||||||
|
|
||||||
|
// use KVO to monitor changes to the likeActionController instance on FBSDKButton in order to avoid race conditions
|
||||||
|
// between notification observers
|
||||||
|
[_likeButton addObserver:self
|
||||||
|
forKeyPath:@"likeActionController"
|
||||||
|
options:NSKeyValueObservingOptionInitial
|
||||||
|
context:FBSDKLikeControlKVOLikeActionControllerContext];
|
||||||
|
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
[nc addObserver:self
|
||||||
|
selector:@selector(_likeActionControllerDidDisableNotification:)
|
||||||
|
name:FBSDKLikeActionControllerDidDisableNotification
|
||||||
|
object:nil];
|
||||||
|
[nc addObserver:self
|
||||||
|
selector:@selector(_likeActionControllerDidUpdateNotification:)
|
||||||
|
name:FBSDKLikeActionControllerDidUpdateNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||||
|
ofObject:(id)object
|
||||||
|
change:(NSDictionary *)change
|
||||||
|
context:(void *)context
|
||||||
|
{
|
||||||
|
if (context == FBSDKLikeControlKVOLikeActionControllerContext) {
|
||||||
|
[self _likeActionControllerDidUpdateWithAnimated:NO];
|
||||||
|
} else {
|
||||||
|
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FBSDKLikeControlApplyHorizontalAlignment(CGRect *frameRef,
|
||||||
|
CGRect bounds,
|
||||||
|
FBSDKLikeControlHorizontalAlignment alignment)
|
||||||
|
{
|
||||||
|
if (frameRef == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGRect frame = *frameRef;
|
||||||
|
switch (alignment) {
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentLeft:{
|
||||||
|
frame.origin.x = CGRectGetMinX(bounds);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentCenter:{
|
||||||
|
frame.origin.x = CGRectGetMinX(bounds) + floorf((CGRectGetWidth(bounds) - CGRectGetWidth(frame)) / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentRight:{
|
||||||
|
frame.origin.x = CGRectGetMinX(bounds) + CGRectGetWidth(bounds) - CGRectGetWidth(frame);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*frameRef = frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CGFloat FBSDKLikeControlPaddedDistance(CGFloat distance, CGFloat padding, BOOL includeDistance)
|
||||||
|
{
|
||||||
|
return (distance == 0.0 ? 0.0 : (includeDistance ? distance : 0.0) + padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CGSize FBSDKLikeControlCalculateContentSize(FBSDKLikeControlLayout layout)
|
||||||
|
{
|
||||||
|
return CGSizeMake(MAX(CGRectGetMaxX(layout.likeButtonFrame), CGRectGetMaxX(layout.auxiliaryViewFrame)),
|
||||||
|
MAX(CGRectGetMaxY(layout.likeButtonFrame), CGRectGetMaxY(layout.auxiliaryViewFrame)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (FBSDKLikeControlLayout)_layoutWithBounds:(CGRect)bounds
|
||||||
|
subviewSizingBlock:(fbsdk_like_control_sizing_block_t)subviewSizingBlock
|
||||||
|
{
|
||||||
|
FBSDKLikeControlLayout layout;
|
||||||
|
|
||||||
|
CGSize likeButtonSize = subviewSizingBlock(_likeButton, bounds.size);
|
||||||
|
layout.likeButtonFrame = CGRectMake(CGRectGetMinX(bounds),
|
||||||
|
CGRectGetMinY(bounds),
|
||||||
|
likeButtonSize.width,
|
||||||
|
likeButtonSize.height);
|
||||||
|
layout.auxiliaryViewFrame = CGRectZero;
|
||||||
|
|
||||||
|
UIView *auxiliaryView = [self _auxiliaryView];
|
||||||
|
CGFloat auxiliaryViewPadding = [self _auxiliaryViewPadding];
|
||||||
|
CGSize auxiliaryViewSize = CGSizeZero;
|
||||||
|
switch (self.likeControlAuxiliaryPosition) {
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionInline:{
|
||||||
|
if (auxiliaryView) {
|
||||||
|
auxiliaryViewSize = CGSizeMake((CGRectGetWidth(bounds) -
|
||||||
|
auxiliaryViewPadding -
|
||||||
|
CGRectGetWidth(layout.likeButtonFrame)),
|
||||||
|
CGRectGetHeight(bounds));
|
||||||
|
auxiliaryViewSize = subviewSizingBlock(auxiliaryView, auxiliaryViewSize);
|
||||||
|
|
||||||
|
layout.auxiliaryViewFrame = CGRectMake(CGRectGetMinX(bounds),
|
||||||
|
CGRectGetMinY(bounds),
|
||||||
|
auxiliaryViewSize.width,
|
||||||
|
MAX(auxiliaryViewSize.height,
|
||||||
|
CGRectGetHeight(layout.likeButtonFrame)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// align the views next to each other for sizing
|
||||||
|
FBSDKLikeControlApplyHorizontalAlignment(&layout.likeButtonFrame,
|
||||||
|
bounds,
|
||||||
|
FBSDKLikeControlHorizontalAlignmentLeft);
|
||||||
|
if (auxiliaryView) {
|
||||||
|
layout.auxiliaryViewFrame.origin.x = CGRectGetMaxX(layout.likeButtonFrame) + auxiliaryViewPadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the size before offsetting the horizontal alignment, using the total calculated width
|
||||||
|
layout.contentSize = FBSDKLikeControlCalculateContentSize(layout);
|
||||||
|
|
||||||
|
// layout the subviews next to each other
|
||||||
|
switch (self.likeControlHorizontalAlignment) {
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentLeft:{
|
||||||
|
// already done
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentCenter:{
|
||||||
|
layout.likeButtonFrame.origin.x = floorf((CGRectGetWidth(bounds) - layout.contentSize.width) / 2);
|
||||||
|
if (auxiliaryView) {
|
||||||
|
layout.auxiliaryViewFrame.origin.x = (CGRectGetMaxX(layout.likeButtonFrame) +
|
||||||
|
auxiliaryViewPadding);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentRight:{
|
||||||
|
layout.likeButtonFrame.origin.x = CGRectGetMaxX(bounds) - CGRectGetWidth(layout.likeButtonFrame);
|
||||||
|
if (auxiliaryView) {
|
||||||
|
layout.auxiliaryViewFrame.origin.x = (CGRectGetMinX(layout.likeButtonFrame) -
|
||||||
|
auxiliaryViewPadding -
|
||||||
|
CGRectGetWidth(layout.auxiliaryViewFrame));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionTop:{
|
||||||
|
if (auxiliaryView) {
|
||||||
|
auxiliaryViewSize = CGSizeMake(CGRectGetWidth(bounds),
|
||||||
|
(CGRectGetHeight(bounds) -
|
||||||
|
auxiliaryViewPadding -
|
||||||
|
CGRectGetHeight(layout.likeButtonFrame)));
|
||||||
|
auxiliaryViewSize = subviewSizingBlock(auxiliaryView, auxiliaryViewSize);
|
||||||
|
|
||||||
|
layout.auxiliaryViewFrame = CGRectMake(CGRectGetMinX(bounds),
|
||||||
|
CGRectGetMinY(bounds),
|
||||||
|
MAX(auxiliaryViewSize.width,
|
||||||
|
CGRectGetWidth(layout.likeButtonFrame)),
|
||||||
|
auxiliaryViewSize.height);
|
||||||
|
}
|
||||||
|
layout.likeButtonFrame.origin.y = FBSDKLikeControlPaddedDistance(CGRectGetMaxY(layout.auxiliaryViewFrame),
|
||||||
|
auxiliaryViewPadding,
|
||||||
|
YES);
|
||||||
|
|
||||||
|
// calculate the size before offsetting the horizontal alignment, using the total calculated width
|
||||||
|
layout.contentSize = FBSDKLikeControlCalculateContentSize(layout);
|
||||||
|
|
||||||
|
FBSDKLikeControlApplyHorizontalAlignment(&layout.likeButtonFrame, bounds, self.likeControlHorizontalAlignment);
|
||||||
|
FBSDKLikeControlApplyHorizontalAlignment(&layout.auxiliaryViewFrame,
|
||||||
|
bounds,
|
||||||
|
self.likeControlHorizontalAlignment);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionBottom:{
|
||||||
|
if (auxiliaryView) {
|
||||||
|
auxiliaryViewSize = CGSizeMake(CGRectGetWidth(bounds),
|
||||||
|
(CGRectGetHeight(bounds) -
|
||||||
|
auxiliaryViewPadding -
|
||||||
|
CGRectGetHeight(layout.likeButtonFrame)));
|
||||||
|
auxiliaryViewSize = subviewSizingBlock(auxiliaryView, auxiliaryViewSize);
|
||||||
|
|
||||||
|
layout.auxiliaryViewFrame = CGRectMake(CGRectGetMinX(bounds),
|
||||||
|
CGRectGetMaxY(layout.likeButtonFrame) + auxiliaryViewPadding,
|
||||||
|
MAX(auxiliaryViewSize.width,
|
||||||
|
CGRectGetWidth(layout.likeButtonFrame)),
|
||||||
|
auxiliaryViewSize.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the size before offsetting the horizontal alignment, using the total calculated width
|
||||||
|
layout.contentSize = FBSDKLikeControlCalculateContentSize(layout);
|
||||||
|
|
||||||
|
FBSDKLikeControlApplyHorizontalAlignment(&layout.likeButtonFrame, bounds, self.likeControlHorizontalAlignment);
|
||||||
|
FBSDKLikeControlApplyHorizontalAlignment(&layout.auxiliaryViewFrame,
|
||||||
|
bounds,
|
||||||
|
self.likeControlHorizontalAlignment);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_likeActionControllerDidDisableNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[self _updateEnabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_likeActionControllerDidUpdateNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
[self _ensureLikeActionController];
|
||||||
|
FBSDKLikeActionController *likeActionController = (FBSDKLikeActionController *)notification.object;
|
||||||
|
NSString *objectID = likeActionController.objectID;
|
||||||
|
if ([self.objectID isEqualToString:objectID]) {
|
||||||
|
BOOL animated = [notification.userInfo[FBSDKLikeActionControllerAnimatedKey] boolValue];
|
||||||
|
[self _likeActionControllerDidUpdateWithAnimated:animated];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_likeActionControllerDidUpdateWithAnimated:(BOOL)animated
|
||||||
|
{
|
||||||
|
FBSDKLikeActionController *likeActionController = _likeButton.likeActionController;
|
||||||
|
NSString *objectID = likeActionController.objectID;
|
||||||
|
if ([self.objectID isEqualToString:objectID]) {
|
||||||
|
_likeBoxView.text = _likeButton.likeActionController.likeCountString;
|
||||||
|
|
||||||
|
if (animated) {
|
||||||
|
void(^hideView)(UIView *) = ^(UIView *view){
|
||||||
|
view.alpha = 0.0;
|
||||||
|
CGRect frame = view.frame;
|
||||||
|
frame.origin.y += kFBLikeControlSocialSentenceAnimationOffset;
|
||||||
|
view.frame = frame;
|
||||||
|
};
|
||||||
|
[UIView animateWithDuration:kFBLikeControlAnimationDuration animations:^{
|
||||||
|
hideView(self->_socialSentenceLabel);
|
||||||
|
} completion:^(BOOL finished) {
|
||||||
|
self->_socialSentenceLabel.text = likeActionController.socialSentence;
|
||||||
|
[self setNeedsLayout];
|
||||||
|
[self setNeedsUpdateConstraints];
|
||||||
|
[self invalidateIntrinsicContentSize];
|
||||||
|
[self layoutIfNeeded];
|
||||||
|
hideView(self->_socialSentenceLabel);
|
||||||
|
|
||||||
|
[UIView animateWithDuration:kFBLikeControlAnimationDuration animations:^{
|
||||||
|
self->_socialSentenceLabel.alpha = 1.0;
|
||||||
|
[self setNeedsLayout];
|
||||||
|
[self layoutIfNeeded];
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
_socialSentenceLabel.text = likeActionController.socialSentence;
|
||||||
|
[self setNeedsLayout];
|
||||||
|
[self setNeedsUpdateConstraints];
|
||||||
|
[self invalidateIntrinsicContentSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self sendActionsForControlEvents:UIControlEventValueChanged];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_updateEnabled
|
||||||
|
{
|
||||||
|
BOOL enabled = (!_isExplicitlyDisabled &&
|
||||||
|
self.objectID &&
|
||||||
|
![FBSDKLikeActionController isDisabled]);
|
||||||
|
BOOL currentEnabled = self.enabled;
|
||||||
|
super.enabled = enabled;
|
||||||
|
if (currentEnabled != enabled) {
|
||||||
|
[self invalidateIntrinsicContentSize];
|
||||||
|
[self setNeedsLayout];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_updateLikeBoxCaretPosition
|
||||||
|
{
|
||||||
|
if (self.likeControlStyle != FBSDKLikeControlStyleBoxCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (self.likeControlAuxiliaryPosition) {
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionInline:{
|
||||||
|
switch (self.likeControlHorizontalAlignment) {
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentLeft:
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentCenter:{
|
||||||
|
_likeBoxView.caretPosition = FBSDKLikeBoxCaretPositionLeft;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlHorizontalAlignmentRight:{
|
||||||
|
_likeBoxView.caretPosition = FBSDKLikeBoxCaretPositionRight;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionTop:{
|
||||||
|
_likeBoxView.caretPosition = FBSDKLikeBoxCaretPositionBottom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FBSDKLikeControlAuxiliaryPositionBottom:{
|
||||||
|
_likeBoxView.caretPosition = FBSDKLikeBoxCaretPositionTop;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
38
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeObjectType.h
generated
Normal file
38
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeObjectType.h
generated
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM (NSUInteger, FBSDKLikeObjectType)
|
||||||
|
Specifies the type of object referenced by the objectID for likes.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKLikeObjectType)
|
||||||
|
{
|
||||||
|
/** The objectID refers to an unknown object type. */
|
||||||
|
FBSDKLikeObjectTypeUnknown = 0,
|
||||||
|
/** The objectID refers to an Open Graph object. */
|
||||||
|
FBSDKLikeObjectTypeOpenGraph,
|
||||||
|
/** The objectID refers to an Page object. */
|
||||||
|
FBSDKLikeObjectTypePage,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an FBLikeControlObjectType to an NSString.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *NSStringFromFBSDKLikeObjectType(FBSDKLikeObjectType objectType);
|
||||||
32
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeObjectType.m
generated
Normal file
32
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLikeObjectType.m
generated
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKLikeObjectType.h"
|
||||||
|
|
||||||
|
NSString *NSStringFromFBSDKLikeObjectType(FBSDKLikeObjectType objectType)
|
||||||
|
{
|
||||||
|
switch (objectType) {
|
||||||
|
case FBSDKLikeObjectTypeUnknown:
|
||||||
|
return @"unknown";
|
||||||
|
case FBSDKLikeObjectTypeOpenGraph:
|
||||||
|
return @"open_graph";
|
||||||
|
case FBSDKLikeObjectTypePage:
|
||||||
|
return @"page";
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
49
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLiking.h
generated
Normal file
49
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKLiking.h
generated
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The common interface for components that initiate liking.
|
||||||
|
|
||||||
|
@see FBSDKLikeButton
|
||||||
|
|
||||||
|
@see FBSDKLikeControl
|
||||||
|
*/
|
||||||
|
@protocol FBSDKLiking <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The objectID for the object to like.
|
||||||
|
|
||||||
|
|
||||||
|
This value may be an Open Graph object ID or a string representation of an URL that describes an
|
||||||
|
Open Graph object. The objects may be public objects, like pages, or objects that are defined by your application.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *objectID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The type of object referenced by the objectID.
|
||||||
|
|
||||||
|
|
||||||
|
If the objectType is unknown, the control will determine the objectType by querying the server with the
|
||||||
|
objectID. Specifying a value for the objectType is an optimization that should be used if the type is known by the
|
||||||
|
consumer. Consider setting the objectType if it is known when setting the objectID.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKLikeObjectType objectType;
|
||||||
|
|
||||||
|
@end
|
||||||
47
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKMessageDialog.h
generated
Normal file
47
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKMessageDialog.h
generated
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKSharing.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A dialog for sharing content through Messenger.
|
||||||
|
|
||||||
|
SUPPORTED SHARE TYPES
|
||||||
|
- FBSDKShareLinkContent
|
||||||
|
- FBSDKShareMessengerOpenGraphMusicTemplateContent
|
||||||
|
- FBSDKShareMessengerMediaTemplateContent
|
||||||
|
- FBSDKShareMessengerGenericTemplateContent
|
||||||
|
|
||||||
|
UNSUPPORTED SHARE TYPES (DEPRECATED AUGUST 2018)
|
||||||
|
- FBSDKShareOpenGraphContent
|
||||||
|
- FBSDKSharePhotoContent
|
||||||
|
- FBSDKShareVideoContent
|
||||||
|
- Any other types that are not one of the four supported types listed above
|
||||||
|
*/
|
||||||
|
@interface FBSDKMessageDialog : NSObject <FBSDKSharingDialog>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to show a Message Share Dialog with content and a delegate.
|
||||||
|
@param content The content to be shared.
|
||||||
|
@param delegate The receiver's delegate.
|
||||||
|
*/
|
||||||
|
+ (instancetype)showWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate;
|
||||||
|
|
||||||
|
@end
|
||||||
244
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKMessageDialog.m
generated
Normal file
244
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKMessageDialog.m
generated
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKMessageDialog.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareCameraEffectContent.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareDefines.h"
|
||||||
|
#import "FBSDKShareMessengerGenericTemplateContent.h"
|
||||||
|
#import "FBSDKShareMessengerMediaTemplateContent.h"
|
||||||
|
#import "FBSDKShareMessengerOpenGraphMusicTemplateContent.h"
|
||||||
|
#import "FBSDKShareOpenGraphContent.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
#import "FBSDKShareVideoContent.h"
|
||||||
|
|
||||||
|
#define FBSDK_MESSAGE_DIALOG_APP_SCHEME @"fb-messenger-share-api"
|
||||||
|
|
||||||
|
@implementation FBSDKMessageDialog
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if ([FBSDKMessageDialog class] == self) {
|
||||||
|
[FBSDKInternalUtility checkRegisteredCanOpenURLScheme:FBSDK_CANOPENURL_MESSENGER];
|
||||||
|
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:NULL];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)showWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
|
||||||
|
{
|
||||||
|
FBSDKMessageDialog *dialog = [[self alloc] init];
|
||||||
|
dialog.shareContent = content;
|
||||||
|
dialog.delegate = delegate;
|
||||||
|
[dialog show];
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize delegate = _delegate;
|
||||||
|
@synthesize shareContent = _shareContent;
|
||||||
|
@synthesize shouldFailOnDataError = _shouldFailOnDataError;
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (BOOL)canShow
|
||||||
|
{
|
||||||
|
return [self _canShowNative];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)show
|
||||||
|
{
|
||||||
|
NSError *error;
|
||||||
|
if (!self.canShow) {
|
||||||
|
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorDialogNotAvailable
|
||||||
|
message:@"Message dialog is not available."];
|
||||||
|
[self _invokeDelegateDidFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self validateWithError:&error]) {
|
||||||
|
[self _invokeDelegateDidFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
id<FBSDKSharingContent> shareContent = self.shareContent;
|
||||||
|
NSDictionary *parameters = [FBSDKShareUtility parametersForShareContent:shareContent
|
||||||
|
bridgeOptions:FBSDKShareBridgeOptionsDefault
|
||||||
|
shouldFailOnDataError:self.shouldFailOnDataError];
|
||||||
|
NSString *methodName = ([shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]] ?
|
||||||
|
FBSDK_SHARE_OPEN_GRAPH_METHOD_NAME :
|
||||||
|
FBSDK_SHARE_METHOD_NAME);
|
||||||
|
FBSDKBridgeAPIRequest *request;
|
||||||
|
request = [FBSDKBridgeAPIRequest bridgeAPIRequestWithProtocolType:FBSDKBridgeAPIProtocolTypeNative
|
||||||
|
scheme:FBSDK_MESSAGE_DIALOG_APP_SCHEME
|
||||||
|
methodName:methodName
|
||||||
|
methodVersion:nil
|
||||||
|
parameters:parameters
|
||||||
|
userInfo:nil];
|
||||||
|
FBSDKServerConfiguration *configuration = [FBSDKServerConfigurationManager cachedServerConfiguration];
|
||||||
|
BOOL useSafariViewController = [configuration useSafariViewControllerForDialogName:FBSDKDialogConfigurationNameMessage];
|
||||||
|
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
|
||||||
|
[self _handleCompletionWithDialogResults:response.responseParameters response:response];
|
||||||
|
[FBSDKInternalUtility unregisterTransientObject:self];
|
||||||
|
};
|
||||||
|
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:request
|
||||||
|
useSafariViewController:useSafariViewController
|
||||||
|
fromViewController:nil
|
||||||
|
completionBlock:completionBlock];
|
||||||
|
|
||||||
|
[self _logDialogShow];
|
||||||
|
[FBSDKInternalUtility registerTransientObject:self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (self.shareContent) {
|
||||||
|
if ([self.shareContent isKindOfClass:[FBSDKShareLinkContent class]] ||
|
||||||
|
[self.shareContent isKindOfClass:[FBSDKShareMessengerGenericTemplateContent class]] ||
|
||||||
|
[self.shareContent isKindOfClass:[FBSDKShareMessengerMediaTemplateContent class]] ||
|
||||||
|
[self.shareContent isKindOfClass:[FBSDKShareMessengerOpenGraphMusicTemplateContent class]]) {
|
||||||
|
} else {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
NSString *message = [NSString stringWithFormat:@"Message dialog does not support %@.",
|
||||||
|
NSStringFromClass(self.shareContent.class)];
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"shareContent"
|
||||||
|
message:message];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [FBSDKShareUtility validateShareContent:self.shareContent
|
||||||
|
bridgeOptions:FBSDKShareBridgeOptionsDefault
|
||||||
|
error:errorRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (BOOL)_canShowNative
|
||||||
|
{
|
||||||
|
FBSDKServerConfiguration *configuration = [FBSDKServerConfigurationManager cachedServerConfiguration];
|
||||||
|
BOOL useNativeDialog = [configuration useNativeDialogForDialogName:FBSDKDialogConfigurationNameMessage];
|
||||||
|
return (useNativeDialog && [FBSDKInternalUtility isMessengerAppInstalled]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_handleCompletionWithDialogResults:(NSDictionary *)results response:(FBSDKBridgeAPIResponse *)response
|
||||||
|
{
|
||||||
|
NSString *completionGesture = results[FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
|
||||||
|
if ([completionGesture isEqualToString:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_CANCEL] ||
|
||||||
|
response.isCancelled) {
|
||||||
|
[self _invokeDelegateDidCancel];
|
||||||
|
} else if (response.error) {
|
||||||
|
[self _invokeDelegateDidFailWithError:response.error];
|
||||||
|
} else {
|
||||||
|
[self _invokeDelegateDidCompleteWithResults:results];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_invokeDelegateDidCancel
|
||||||
|
{
|
||||||
|
NSDictionary * parameters =@{
|
||||||
|
FBSDKAppEventParameterDialogOutcome : FBSDKAppEventsDialogOutcomeValue_Cancelled,
|
||||||
|
};
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
|
||||||
|
valueToSum:nil
|
||||||
|
parameters:parameters
|
||||||
|
accessToken:[FBSDKAccessToken currentAccessToken]];
|
||||||
|
|
||||||
|
if (!_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_delegate sharerDidCancel:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_invokeDelegateDidCompleteWithResults:(NSDictionary *)results
|
||||||
|
{
|
||||||
|
NSDictionary * parameters =@{
|
||||||
|
FBSDKAppEventParameterDialogOutcome : FBSDKAppEventsDialogOutcomeValue_Completed,
|
||||||
|
};
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
|
||||||
|
valueToSum:nil
|
||||||
|
parameters:parameters
|
||||||
|
accessToken:[FBSDKAccessToken currentAccessToken]];
|
||||||
|
|
||||||
|
if (!_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_delegate sharer:self didCompleteWithResults:[results copy]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_invokeDelegateDidFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
NSMutableDictionary * parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:FBSDKAppEventsDialogOutcomeValue_Failed, FBSDKAppEventParameterDialogOutcome, nil];
|
||||||
|
if (error) {
|
||||||
|
parameters[FBSDKAppEventParameterDialogErrorMessage] = [NSString stringWithFormat:@"%@", error];
|
||||||
|
}
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
|
||||||
|
valueToSum:nil
|
||||||
|
parameters:parameters
|
||||||
|
accessToken:[FBSDKAccessToken currentAccessToken]];
|
||||||
|
|
||||||
|
if (!_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_logDialogShow
|
||||||
|
{
|
||||||
|
NSString *contentType;
|
||||||
|
if([self.shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeOpenGraph;
|
||||||
|
} else if ([self.shareContent isKindOfClass:[FBSDKShareLinkContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeStatus;
|
||||||
|
} else if ([self.shareContent isKindOfClass:[FBSDKSharePhotoContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypePhoto;
|
||||||
|
} else if ([self.shareContent isKindOfClass:[FBSDKShareVideoContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeVideo;
|
||||||
|
} else if ([self.shareContent isKindOfClass:[FBSDKShareMessengerGenericTemplateContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeMessengerGenericTemplate;
|
||||||
|
} else if ([self.shareContent isKindOfClass:[FBSDKShareMessengerMediaTemplateContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeMessengerMediaTemplate;
|
||||||
|
} else if ([self.shareContent isKindOfClass:[FBSDKShareMessengerOpenGraphMusicTemplateContent class]]) {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeMessengerOpenGraphMusicTemplate;
|
||||||
|
} else {
|
||||||
|
contentType = FBSDKAppEventsDialogShareContentTypeUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *parameters = @{FBSDKAppEventParameterDialogShareContentType : contentType,
|
||||||
|
FBSDKAppEventParameterDialogShareContentUUID : self.shareContent.shareUUID ?: [NSNull null],
|
||||||
|
FBSDKAppEventParameterDialogShareContentPageID : self.shareContent.pageID ?: [NSNull null]};
|
||||||
|
|
||||||
|
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogShow
|
||||||
|
valueToSum:nil
|
||||||
|
parameters:parameters
|
||||||
|
accessToken:[FBSDKAccessToken currentAccessToken]];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
33
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKSendButton.h
generated
Normal file
33
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKSendButton.h
generated
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKButton.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingButton.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A button to send content through Messenger.
|
||||||
|
|
||||||
|
Tapping the receiver will invoke the FBSDKShareDialog with the attached shareContent. If the dialog cannot
|
||||||
|
be shown, the button will be disable.
|
||||||
|
*/
|
||||||
|
@interface FBSDKSendButton : FBSDKButton <FBSDKSharingButton>
|
||||||
|
|
||||||
|
@end
|
||||||
97
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKSendButton.m
generated
Normal file
97
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKSendButton.m
generated
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKSendButton.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKMessageDialog.h"
|
||||||
|
#import "FBSDKMessengerIcon.h"
|
||||||
|
|
||||||
|
@interface FBSDKSendButton () <FBSDKButtonImpressionTracking>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKSendButton
|
||||||
|
{
|
||||||
|
FBSDKMessageDialog *_dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
- (id<FBSDKSharingContent>)shareContent
|
||||||
|
{
|
||||||
|
return _dialog.shareContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setShareContent:(id<FBSDKSharingContent>)shareContent
|
||||||
|
{
|
||||||
|
_dialog.shareContent = shareContent;
|
||||||
|
[self checkImplicitlyDisabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButtonImpressionTracking
|
||||||
|
|
||||||
|
- (NSDictionary *)analyticsParameters
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingEventName
|
||||||
|
{
|
||||||
|
return FBSDKAppEventNameFBSDKSendButtonImpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingIdentifier
|
||||||
|
{
|
||||||
|
return @"send";
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButton
|
||||||
|
|
||||||
|
- (void)configureButton
|
||||||
|
{
|
||||||
|
NSString *title =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"SendButton.Send", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Send",
|
||||||
|
@"The label for FBSDKSendButton");
|
||||||
|
|
||||||
|
UIColor *backgroundColor = [UIColor colorWithRed:0.0 green:132.0/255.0 blue:1.0 alpha:1.0];
|
||||||
|
UIColor *highlightedColor = [UIColor colorWithRed:0.0 green:111.0/255.0 blue:1.0 alpha:1.0];
|
||||||
|
|
||||||
|
[self configureWithIcon:[[FBSDKMessengerIcon alloc] init]
|
||||||
|
title:title
|
||||||
|
backgroundColor:backgroundColor
|
||||||
|
highlightedColor:highlightedColor];
|
||||||
|
|
||||||
|
[self addTarget:self action:@selector(_share:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
_dialog = [[FBSDKMessageDialog alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isImplicitlyDisabled
|
||||||
|
{
|
||||||
|
return !_dialog.canShow || ![_dialog validateWithError:NULL];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_share:(id)sender
|
||||||
|
{
|
||||||
|
[self logTapEventWithEventName:FBSDKAppEventNameFBSDKSendButtonDidTap parameters:self.analyticsParameters];
|
||||||
|
[_dialog show];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
94
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareAPI.h
generated
Normal file
94
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareAPI.h
generated
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKAccessToken.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKShareOpenGraphObject.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharing.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A utility class for sharing through the graph API. Using this class requires an access token that
|
||||||
|
has been granted the "publish_actions" permission.
|
||||||
|
|
||||||
|
FBSDKShareAPI network requests are scheduled on the current run loop in the default run loop mode.
|
||||||
|
If you want to use FBSDKShareAPI in a background thread, you must manage the run loop
|
||||||
|
yourself.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareAPI : NSObject <FBSDKSharing>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to build up a share API with content and a delegate.
|
||||||
|
@param content The content to be shared.
|
||||||
|
@param delegate The receiver's delegate.
|
||||||
|
*/
|
||||||
|
+ (instancetype)shareWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The message the person has provided through the custom dialog that will accompany the share content.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The graph node to which content should be shared.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *graphNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The access token used when performing a share. The access token must have the "publish_actions"
|
||||||
|
permission granted.
|
||||||
|
|
||||||
|
Defaults to [FBSDKAccessToken currentAccessToken]. Setting this to nil will revert the access token to
|
||||||
|
[FBSDKAccessToken currentAccessToken].
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) FBSDKAccessToken *accessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A Boolean value that indicates whether the receiver can send the share.
|
||||||
|
|
||||||
|
May return NO if the appropriate Facebook app is not installed and is required or an access token is
|
||||||
|
required but not available. This method does not validate the content on the receiver, so this can be checked before
|
||||||
|
building up the content.
|
||||||
|
|
||||||
|
@see [FBSDKSharing validateWithError:]
|
||||||
|
@return YES if the receiver can send, otherwise NO.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) BOOL canShare;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates an User Owned Open Graph object without an action.
|
||||||
|
@param openGraphObject The open graph object to create.
|
||||||
|
|
||||||
|
Use this method to create an object alone, when an action is not going to be posted with the object. If
|
||||||
|
the object will be used within an action, just put the object in the action and share that as the shareContent and the
|
||||||
|
object will be created in the process. The delegate will be messaged with the results.
|
||||||
|
|
||||||
|
Also see https://developers.facebook.com/docs/sharing/opengraph/object-api#objectapi-creatinguser
|
||||||
|
|
||||||
|
@return YES if the receiver was able to send the request to create the object, otherwise NO.
|
||||||
|
*/
|
||||||
|
- (BOOL)createOpenGraphObject:(FBSDKShareOpenGraphObject *)openGraphObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Begins the send from the receiver.
|
||||||
|
@return YES if the receiver was able to send the share, otherwise NO.
|
||||||
|
*/
|
||||||
|
- (BOOL)share;
|
||||||
|
|
||||||
|
@end
|
||||||
849
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareAPI.m
generated
Normal file
849
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareAPI.m
generated
Normal file
@ -0,0 +1,849 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareAPI.h"
|
||||||
|
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
#import <AssetsLibrary/AssetsLibrary.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKGraphRequest.h>
|
||||||
|
#import <FBSDKCoreKit/FBSDKGraphRequestDataAttachment.h>
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareDefines.h"
|
||||||
|
#import "FBSDKShareLinkContent.h"
|
||||||
|
#import "FBSDKShareOpenGraphAction.h"
|
||||||
|
#import "FBSDKShareOpenGraphContent.h"
|
||||||
|
#import "FBSDKShareOpenGraphObject.h"
|
||||||
|
#import "FBSDKSharePhoto.h"
|
||||||
|
#import "FBSDKSharePhotoContent.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
#import "FBSDKShareVideo.h"
|
||||||
|
#import "FBSDKShareVideoContent.h"
|
||||||
|
#import "FBSDKVideoUploader.h"
|
||||||
|
|
||||||
|
static NSString *const FBSDKShareAPIDefaultGraphNode = @"me";
|
||||||
|
static NSString *const FBSDKShareAPIPhotosEdge = @"photos";
|
||||||
|
static NSString *const FBSDKShareAPIVideosEdge = @"videos";
|
||||||
|
static NSMutableArray *g_pendingFBSDKShareAPI;
|
||||||
|
|
||||||
|
@interface FBSDKShareAPI () <FBSDKVideoUploaderDelegate>
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation FBSDKShareAPI {
|
||||||
|
NSFileHandle *_fileHandle;
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
ALAssetRepresentation *_assetRepresentation;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (instancetype)shareWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
|
||||||
|
{
|
||||||
|
FBSDKShareAPI *API = [[self alloc] init];
|
||||||
|
API.shareContent = content;
|
||||||
|
API.delegate = delegate;
|
||||||
|
[API share];
|
||||||
|
return API;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize delegate = _delegate;
|
||||||
|
@synthesize shareContent = _shareContent;
|
||||||
|
@synthesize shouldFailOnDataError = _shouldFailOnDataError;
|
||||||
|
@synthesize accessToken = _accessToken;
|
||||||
|
|
||||||
|
#pragma mark - Object Lifecycle
|
||||||
|
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
+ (ALAssetsLibrary *)defaultAssetsLibrary {
|
||||||
|
static dispatch_once_t pred = 0;
|
||||||
|
static ALAssetsLibrary *library = nil;
|
||||||
|
dispatch_once(&pred, ^{
|
||||||
|
library = [[fbsdkdfl_ALAssetsLibraryClass() alloc] init];
|
||||||
|
});
|
||||||
|
return library;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if (self == [FBSDKShareAPI class]) {
|
||||||
|
g_pendingFBSDKShareAPI = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
if ((self = [super init])) {
|
||||||
|
_graphNode = FBSDKShareAPIDefaultGraphNode;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Public Methods
|
||||||
|
|
||||||
|
- (BOOL)canShare
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)createOpenGraphObject:(FBSDKShareOpenGraphObject *)openGraphObject
|
||||||
|
{
|
||||||
|
NSError *error;
|
||||||
|
if (!self.canShare) {
|
||||||
|
NSString *message = @"Share API is not available; verify 'canShare' returns YES";
|
||||||
|
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorDialogNotAvailable
|
||||||
|
message:message];
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self _hasPublishActions]) {
|
||||||
|
NSString *message = @"Warning: Access token is missing publish_actions permissions";
|
||||||
|
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors logEntry:message];
|
||||||
|
}
|
||||||
|
if (!openGraphObject) {
|
||||||
|
error = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"openGraphObject"
|
||||||
|
message:nil];
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
|
||||||
|
void(^completionHandler)(id) = ^(NSDictionary *result) {
|
||||||
|
[self->_delegate sharer:self didCompleteWithResults:result];
|
||||||
|
};
|
||||||
|
if (![self _stageOpenGraphObject:openGraphObject
|
||||||
|
connection:connection
|
||||||
|
stagingHandler:NULL
|
||||||
|
completionHandler:completionHandler]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
[connection start];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)share
|
||||||
|
{
|
||||||
|
NSError *error;
|
||||||
|
if (!self.canShare) {
|
||||||
|
NSString *message = @"Share API is not available; verify 'canShare' returns YES";
|
||||||
|
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorDialogNotAvailable
|
||||||
|
message:message];
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self _hasPublishActions]) {
|
||||||
|
NSString *message = @"Warning: Access token is missing publish_actions permissions";
|
||||||
|
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors logEntry:message];
|
||||||
|
}
|
||||||
|
if (![self validateWithError:&error]) {
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
id<FBSDKSharingContent> shareContent = self.shareContent;
|
||||||
|
|
||||||
|
if ([shareContent isKindOfClass:[FBSDKShareLinkContent class]]) {
|
||||||
|
return [self _shareLinkContent:(FBSDKShareLinkContent *)shareContent];
|
||||||
|
} else if ([shareContent isKindOfClass:[FBSDKSharePhotoContent class]]) {
|
||||||
|
return [self _sharePhotoContent:(FBSDKSharePhotoContent *)shareContent];
|
||||||
|
} else if ([shareContent isKindOfClass:[FBSDKShareVideoContent class]]) {
|
||||||
|
return [self _shareVideoContent:(FBSDKShareVideoContent *)shareContent];
|
||||||
|
} else if ([shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
|
||||||
|
return [self _shareOpenGraphContent:(FBSDKShareOpenGraphContent *)shareContent];
|
||||||
|
} else {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
id<FBSDKSharingContent> shareContent = self.shareContent;
|
||||||
|
if (!shareContent) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"shareContent"
|
||||||
|
message:@"Share content cannot be null."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if ([shareContent isKindOfClass:[FBSDKShareVideoContent class]]) {
|
||||||
|
if (shareContent.peopleIDs.count > 0) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"peopleIDs"
|
||||||
|
value:shareContent.peopleIDs
|
||||||
|
message:@"Cannot specify peopleIDs with FBSDKShareVideoContent."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (shareContent.placeID) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"placeID"
|
||||||
|
value:shareContent.placeID
|
||||||
|
message:@"Cannot specify place ID with FBSDKShareVideoContent."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errorRef != NULL){
|
||||||
|
*errorRef = nil;
|
||||||
|
}
|
||||||
|
return [FBSDKShareUtility validateShareContent:shareContent bridgeOptions:FBSDKShareBridgeOptionsDefault error:errorRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (FBSDKAccessToken *)accessToken
|
||||||
|
{
|
||||||
|
return _accessToken ?: [FBSDKAccessToken currentAccessToken];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (NSString *)_graphPathWithSuffix:(NSString *)suffix, ... NS_REQUIRES_NIL_TERMINATION
|
||||||
|
{
|
||||||
|
NSMutableString *graphPath = [[NSMutableString alloc] initWithString:self.graphNode];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, suffix);
|
||||||
|
for (NSString *arg = suffix; arg != nil; arg = va_arg(args, NSString *)) {
|
||||||
|
[graphPath appendFormat:@"/%@", arg];
|
||||||
|
}
|
||||||
|
va_end(args);
|
||||||
|
return graphPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_addCommonParameters:(NSMutableDictionary *)parameters content:(id<FBSDKSharingContent>)content
|
||||||
|
{
|
||||||
|
if (content.peopleIDs.count > 0) {
|
||||||
|
NSString *tags;
|
||||||
|
if ([content isKindOfClass:[FBSDKSharePhotoContent class]]) {
|
||||||
|
NSMutableArray *tagsArray = [[NSMutableArray alloc] init];
|
||||||
|
for (NSString *peopleID in content.peopleIDs) {
|
||||||
|
[tagsArray addObject:@{ @"tag_uid" : peopleID }];
|
||||||
|
}
|
||||||
|
NSData *tagsJSON = [NSJSONSerialization dataWithJSONObject:tagsArray options:0 error:nil];
|
||||||
|
tags = [[NSString alloc] initWithData:tagsJSON encoding:NSUTF8StringEncoding];
|
||||||
|
} else {
|
||||||
|
tags = [content.peopleIDs componentsJoinedByString:@","];
|
||||||
|
}
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:tags forKey:@"tags"];
|
||||||
|
}
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.placeID forKey:@"place"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:content.ref forKey:@"ref"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_hasPublishActions
|
||||||
|
{
|
||||||
|
return [self.accessToken.permissions containsObject:@"publish_actions"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_shareLinkContent:(FBSDKShareLinkContent *)linkContent
|
||||||
|
{
|
||||||
|
FBSDKGraphRequestHandler completionHandler = ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
if (!self->_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
} else {
|
||||||
|
result = [FBSDKTypeUtility dictionaryValue:result];
|
||||||
|
NSMutableDictionary *shareResults = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST
|
||||||
|
forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:result[@"id"]]
|
||||||
|
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
|
||||||
|
[self->_delegate sharer:self didCompleteWithResults:shareResults];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
||||||
|
[self _addCommonParameters:parameters content:linkContent];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:self.message forKey:@"message"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:linkContent.contentURL forKey:@"link"];
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:linkContent.imageURL forKey:@"picture"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:linkContent.contentTitle forKey:@"name"];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:linkContent.contentDescription forKey:@"description"];
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
[[[FBSDKGraphRequest alloc] initWithGraphPath:[self _graphPathWithSuffix:@"feed", nil]
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:self.accessToken.tokenString
|
||||||
|
version:nil
|
||||||
|
HTTPMethod:@"POST"] startWithCompletionHandler:completionHandler];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_shareOpenGraphContent:(FBSDKShareOpenGraphContent *)openGraphContent
|
||||||
|
{
|
||||||
|
// In order to create a new Open Graph action using a custom object that does not already exist (objectID or URL), you
|
||||||
|
// must first send a request to post the object and then another to post the action. If a local image is supplied
|
||||||
|
// with the object or action, that must be staged first and then referenced by the staging URL that is returned by
|
||||||
|
// that request.
|
||||||
|
FBSDKShareOpenGraphAction *action = openGraphContent.action;
|
||||||
|
FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
|
||||||
|
void(^stagingHandler)(NSDictionary *) = ^(NSDictionary *stagedContainer) {
|
||||||
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:stagedContainer];
|
||||||
|
[self _addCommonParameters:parameters content:openGraphContent];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:self.message forKey:@"message"];
|
||||||
|
|
||||||
|
FBSDKGraphRequestHandler requestHandler = ^(FBSDKGraphRequestConnection *requestConnection,
|
||||||
|
id result,
|
||||||
|
NSError *requestError) {
|
||||||
|
if (!self->_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (requestError) {
|
||||||
|
NSError *error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorOpenGraph
|
||||||
|
message:@"Error sharing Open Graph content"
|
||||||
|
underlyingError:requestError];
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
} else if (result) {
|
||||||
|
NSMutableDictionary *shareResults = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST
|
||||||
|
forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:result[@"id"]]
|
||||||
|
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
|
||||||
|
[self->_delegate sharer:self didCompleteWithResults:shareResults];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NSString *graphPath = [self _graphPathWithSuffix:[FBSDKUtility URLEncode:action.actionType], nil];
|
||||||
|
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:graphPath
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:self.accessToken.tokenString
|
||||||
|
version:nil
|
||||||
|
HTTPMethod:@"POST"];
|
||||||
|
[self _connection:connection addRequest:request completionHandler:requestHandler];
|
||||||
|
[connection start];
|
||||||
|
};
|
||||||
|
if (![self _stageOpenGraphValueContainer:action connection:connection stagingHandler:stagingHandler]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_sharePhotoContent:(FBSDKSharePhotoContent *)photoContent
|
||||||
|
{
|
||||||
|
NSArray *photos = photoContent.photos;
|
||||||
|
NSMutableArray *requests = [[NSMutableArray alloc] init];
|
||||||
|
for (FBSDKSharePhoto *photo in photos) {
|
||||||
|
UIImage *image = photo.image;
|
||||||
|
if (!image && photo.imageURL.isFileURL) {
|
||||||
|
image = [UIImage imageWithContentsOfFile:photo.imageURL.path];
|
||||||
|
}
|
||||||
|
if (image) {
|
||||||
|
NSString *graphPath = [self _graphPathWithSuffix:FBSDKShareAPIPhotosEdge, nil];
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
||||||
|
[self _addCommonParameters:parameters content:photoContent];
|
||||||
|
NSString *caption = photo.caption ?: self.message;
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:caption forKey:@"caption"];
|
||||||
|
parameters[@"picture"] = image;
|
||||||
|
[requests addObject:[[FBSDKGraphRequest alloc] initWithGraphPath:graphPath
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:self.accessToken.tokenString
|
||||||
|
version:nil
|
||||||
|
HTTPMethod:@"POST"]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NSUInteger requestCount = requests.count;
|
||||||
|
NSMutableArray *results = [[NSMutableArray alloc] init];
|
||||||
|
NSMutableArray *errors = [[NSMutableArray alloc] init];
|
||||||
|
__block NSUInteger completedCount = 0;
|
||||||
|
FBSDKGraphRequestHandler completionHandler = ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||||
|
result = [FBSDKTypeUtility dictionaryValue:result];
|
||||||
|
[FBSDKInternalUtility array:results addObject:result];
|
||||||
|
[FBSDKInternalUtility array:errors addObject:error];
|
||||||
|
if (++completedCount != requestCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!self->_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (errors.count) {
|
||||||
|
[self->_delegate sharer:self didFailWithError:errors[0]];
|
||||||
|
} else if (results.count) {
|
||||||
|
NSArray *individualPhotoIDs = [results valueForKeyPath:@"id"];
|
||||||
|
// each photo upload will be merged into the same post, so grab the post_id from the first and use that
|
||||||
|
NSMutableDictionary *shareResults = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST
|
||||||
|
forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
|
||||||
|
NSDictionary *firstResult = [FBSDKTypeUtility dictionaryValue:results[0]];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:firstResult[@"post_id"]]
|
||||||
|
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:individualPhotoIDs forKey:FBSDK_SHARE_RESULT_PHOTO_IDS_KEY];
|
||||||
|
[self->_delegate sharer:self didCompleteWithResults:shareResults];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (FBSDKGraphRequest *request in requests) {
|
||||||
|
[request startWithCompletionHandler:completionHandler];
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_shareVideoContent:(FBSDKShareVideoContent *)videoContent
|
||||||
|
{
|
||||||
|
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
||||||
|
[self _addCommonParameters:parameters content:videoContent];
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:self.message forKey:@"description"];
|
||||||
|
if ([self.accessToken.permissions containsObject:@"ads_management"]) {
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
FBSDKSharePhoto *photo = videoContent.previewPhoto;
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
UIImage *image = photo.image;
|
||||||
|
if (!image && photo.imageURL.fileURL) {
|
||||||
|
image = [UIImage imageWithContentsOfFile:photo.imageURL.path];
|
||||||
|
}
|
||||||
|
[FBSDKInternalUtility dictionary:parameters setObject:image forKey:@"thumb"];
|
||||||
|
}
|
||||||
|
FBSDKShareVideo *video = videoContent.video;
|
||||||
|
NSURL *videoURL = video.videoURL;
|
||||||
|
if (videoURL.fileURL) {
|
||||||
|
NSError *fileError;
|
||||||
|
_fileHandle = [NSFileHandle fileHandleForReadingFromURL:videoURL error:&fileError];
|
||||||
|
if (!_fileHandle) {
|
||||||
|
[_delegate sharer:self didFailWithError:fileError];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![self _addToPendingShareAPI]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
FBSDKVideoUploader *videoUploader = [[FBSDKVideoUploader alloc] initWithVideoName:videoURL.lastPathComponent
|
||||||
|
videoSize:(unsigned long)[_fileHandle seekToEndOfFile]
|
||||||
|
parameters:parameters
|
||||||
|
delegate:self];
|
||||||
|
videoUploader.graphNode = self.graphNode;
|
||||||
|
[videoUploader start];
|
||||||
|
return YES;
|
||||||
|
} else if (videoURL) {
|
||||||
|
#if TARGET_OS_TV
|
||||||
|
return NO;
|
||||||
|
#else
|
||||||
|
if (![self _addToPendingShareAPI]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
[[FBSDKShareAPI defaultAssetsLibrary] assetForURL:videoURL resultBlock:^(ALAsset *asset) {
|
||||||
|
self->_assetRepresentation = [asset defaultRepresentation];
|
||||||
|
NSUInteger size = (NSUInteger)self->_assetRepresentation.size;
|
||||||
|
FBSDKVideoUploader *videoUploader = [[FBSDKVideoUploader alloc] initWithVideoName:videoURL.lastPathComponent
|
||||||
|
videoSize:size
|
||||||
|
parameters:parameters
|
||||||
|
delegate:self];
|
||||||
|
videoUploader.graphNode = self.graphNode;
|
||||||
|
[videoUploader start];
|
||||||
|
} failureBlock:^(NSError *error) {
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
}];
|
||||||
|
return YES;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_addEncodedParametersToDictionary:(NSMutableDictionary *)parameters
|
||||||
|
key:(NSString *)key
|
||||||
|
value:(id)value
|
||||||
|
error:(NSError * __autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if ([value isKindOfClass:[NSString class]] ||
|
||||||
|
[value isKindOfClass:[NSNumber class]] ||
|
||||||
|
[value isKindOfClass:[NSNull class]]) {
|
||||||
|
parameters[key] = value;
|
||||||
|
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||||
|
__block BOOL didEncode = YES;
|
||||||
|
[(NSArray *)value enumerateObjectsUsingBlock:^(id subvalue, NSUInteger idx, BOOL *stop) {
|
||||||
|
NSString *subkey = [[NSString alloc] initWithFormat:@"%@[%lu]", key, (unsigned long)idx];
|
||||||
|
if (![self _addEncodedParametersToDictionary:parameters key:subkey value:subvalue error:errorRef]) {
|
||||||
|
*stop = YES;
|
||||||
|
didEncode = NO;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
if (!didEncode) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||||
|
__block BOOL didEncode = YES;
|
||||||
|
[(NSDictionary *)value enumerateKeysAndObjectsUsingBlock:^(id subkey, id subvalue, BOOL *stop) {
|
||||||
|
subkey = [[NSString alloc] initWithFormat:@"%@[%@]", key, subkey];
|
||||||
|
if (![self _addEncodedParametersToDictionary:parameters key:subkey value:subvalue error:errorRef]) {
|
||||||
|
*stop = YES;
|
||||||
|
didEncode = NO;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
if (!didEncode) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:key
|
||||||
|
value:value
|
||||||
|
message:nil];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = nil;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_stageArray:(NSArray *)array
|
||||||
|
connection:(FBSDKGraphRequestConnection *)connection
|
||||||
|
stagingHandler:(void(^)(NSArray *stagedArray))stagingHandler
|
||||||
|
{
|
||||||
|
__block BOOL result = YES;
|
||||||
|
__block NSUInteger pendingCount = 1;
|
||||||
|
NSMutableArray *stagedArray = [[NSMutableArray alloc] initWithArray:array];
|
||||||
|
void(^itemDidFail)(void) = ^{
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = NO;
|
||||||
|
};
|
||||||
|
void(^itemDidSucceed)(void) = ^{
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((--pendingCount == 0) && (stagingHandler != NULL)) {
|
||||||
|
stagingHandler(stagedArray);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
[array enumerateObjectsUsingBlock:^(id item, NSUInteger idx, BOOL *stop) {
|
||||||
|
pendingCount++;
|
||||||
|
void(^itemHandler)(id) = ^(id stagedValue) {
|
||||||
|
if (stagedValue) {
|
||||||
|
stagedArray[idx] = stagedValue;
|
||||||
|
itemDidSucceed();
|
||||||
|
} else {
|
||||||
|
NSError *error = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"value"
|
||||||
|
value:item
|
||||||
|
message:@"Error staging object."];
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
itemDidFail();
|
||||||
|
*stop = YES;
|
||||||
|
result = NO;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (![self _stageValue:item connection:connection stagingHandler:itemHandler]) {
|
||||||
|
itemDidFail();
|
||||||
|
*stop = YES;
|
||||||
|
result = NO;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
if (result) {
|
||||||
|
itemDidSucceed();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_stageOpenGraphObject:(FBSDKShareOpenGraphObject *)openGraphObject
|
||||||
|
connection:(FBSDKGraphRequestConnection *)connection
|
||||||
|
stagingHandler:(void(^)(id stagedObject))stagingHandler
|
||||||
|
completionHandler:(void(^)(NSDictionary *result))completionHandler
|
||||||
|
{
|
||||||
|
NSString *type = [FBSDKTypeUtility stringValue:openGraphObject[@"og:type"]];
|
||||||
|
if (!type) {
|
||||||
|
NSString *message = @"Open Graph objects must contain a og:type value.";
|
||||||
|
NSError *error = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"og:type"
|
||||||
|
message:message];
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
void(^containerHandler)(NSDictionary *) = ^(NSDictionary *stagedContainer) {
|
||||||
|
NSError *JSONError;
|
||||||
|
NSString *objectString = [FBSDKInternalUtility JSONStringForObject:stagedContainer
|
||||||
|
error:&JSONError
|
||||||
|
invalidObjectHandler:NULL];
|
||||||
|
if (!objectString) {
|
||||||
|
[self->_delegate sharer:self didFailWithError:JSONError];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSString *graphPath = [self _graphPathWithSuffix:@"objects", type, nil];
|
||||||
|
NSDictionary *parameters = @{ @"object": objectString };
|
||||||
|
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:graphPath
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:self.accessToken.tokenString
|
||||||
|
version:nil
|
||||||
|
HTTPMethod:@"POST"];
|
||||||
|
FBSDKGraphRequestHandler requestCompletionHandler = ^(FBSDKGraphRequestConnection *requestConnection,
|
||||||
|
id result,
|
||||||
|
NSError *requestError) {
|
||||||
|
if (!self->_delegate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (requestError) {
|
||||||
|
NSString *message = [[NSString alloc] initWithFormat:@"Error creating Open Graph object: %@",
|
||||||
|
requestError.description];
|
||||||
|
NSError *error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorOpenGraph
|
||||||
|
message:message
|
||||||
|
underlyingError:requestError];
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
} else if (completionHandler != NULL) {
|
||||||
|
completionHandler([FBSDKTypeUtility dictionaryValue:result]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NSString *batchEntryName = [self _connection:connection
|
||||||
|
addRequest:request
|
||||||
|
completionHandler:requestCompletionHandler];
|
||||||
|
if (stagingHandler != NULL) {
|
||||||
|
stagingHandler([[NSString alloc] initWithFormat:@"{result=%@:$.id}", batchEntryName]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return [self _stageOpenGraphValueContainer:openGraphObject connection:connection stagingHandler:containerHandler];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_stageOpenGraphValueContainer:(id<FBSDKShareOpenGraphValueContaining>)container
|
||||||
|
connection:(FBSDKGraphRequestConnection *)connection
|
||||||
|
stagingHandler:(void(^)(NSDictionary *stagedContainer))stagingHandler
|
||||||
|
{
|
||||||
|
__block BOOL result = YES;
|
||||||
|
__block NSUInteger pendingCount = 1;
|
||||||
|
NSMutableDictionary *stagedContainer = [[NSMutableDictionary alloc] init];
|
||||||
|
void(^itemDidFail)(void) = ^{
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = NO;
|
||||||
|
};
|
||||||
|
void(^itemDidSucceed)(void) = ^{
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((--pendingCount == 0) && (stagingHandler != NULL)) {
|
||||||
|
stagingHandler(stagedContainer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
BOOL isAction = [container isKindOfClass:[FBSDKShareOpenGraphAction class]];
|
||||||
|
[container enumerateKeysAndObjectsUsingBlock:^(NSString *key, id object, BOOL *stop) {
|
||||||
|
pendingCount++;
|
||||||
|
|
||||||
|
// The server does not understand custom namespaces remove them until the server is fixed
|
||||||
|
NSString *namespace;
|
||||||
|
key = [FBSDKShareUtility getOpenGraphNameAndNamespaceFromFullName:key namespace:&namespace];
|
||||||
|
if (namespace && !isAction) {
|
||||||
|
if (!stagedContainer[namespace]) {
|
||||||
|
stagedContainer[namespace] = [[NSMutableDictionary alloc] init];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void(^itemHandler)(id) = ^(id stagedValue) {
|
||||||
|
if (stagedValue) {
|
||||||
|
if (isAction) {
|
||||||
|
NSError *error;
|
||||||
|
if (![self _addEncodedParametersToDictionary:stagedContainer key:key value:stagedValue error:&error]) {
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
itemDidFail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NSMutableDictionary *valueContainer = (namespace ? stagedContainer[namespace] : stagedContainer);
|
||||||
|
valueContainer[key] = stagedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemDidSucceed();
|
||||||
|
};
|
||||||
|
if (![self _stageValue:object connection:connection stagingHandler:itemHandler]) {
|
||||||
|
*stop = YES;
|
||||||
|
result = NO;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
if (result) {
|
||||||
|
itemDidSucceed();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_stagePhoto:(FBSDKSharePhoto *)photo
|
||||||
|
connection:(FBSDKGraphRequestConnection *)connection
|
||||||
|
stagingHandler:(void(^)(id stagedPhoto))stagingHandler
|
||||||
|
{
|
||||||
|
if (photo.imageURL) {
|
||||||
|
NSMutableDictionary *stagedPhoto = [[NSMutableDictionary alloc]initWithDictionary: @{
|
||||||
|
@"url": photo.imageURL.absoluteString,
|
||||||
|
@"user_generated": @(photo.userGenerated),
|
||||||
|
}];
|
||||||
|
[FBSDKInternalUtility dictionary:stagedPhoto setObject:photo.caption forKey:@"caption"];
|
||||||
|
if (stagingHandler) {
|
||||||
|
stagingHandler(stagedPhoto);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
} else if (photo.image) {
|
||||||
|
NSString *graphPath = @"/me/staging_resources";
|
||||||
|
NSDictionary *parameters = @{ @"file": photo.image };
|
||||||
|
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:graphPath
|
||||||
|
parameters:parameters
|
||||||
|
tokenString:self.accessToken.tokenString
|
||||||
|
version:nil
|
||||||
|
HTTPMethod:@"POST"];
|
||||||
|
FBSDKGraphRequestHandler completionHandler = ^(FBSDKGraphRequestConnection *requestConnection,
|
||||||
|
id result,
|
||||||
|
NSError *requestError) {
|
||||||
|
NSString *stagedPhotoURLString = [FBSDKTypeUtility stringValue:result[@"uri"]];
|
||||||
|
if (requestError || !stagedPhotoURLString) {
|
||||||
|
NSError *error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
code:FBSDKShareErrorOpenGraph
|
||||||
|
message:@"Error staging photo"
|
||||||
|
underlyingError:requestError];
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
} else if (stagingHandler) {
|
||||||
|
NSMutableDictionary *stagedPhoto = [[NSMutableDictionary alloc] initWithDictionary: @{
|
||||||
|
@"url": stagedPhotoURLString,
|
||||||
|
@"user_generated": @(photo.userGenerated),
|
||||||
|
}];
|
||||||
|
[FBSDKInternalUtility dictionary:stagedPhoto setObject:photo.caption forKey:@"caption"];
|
||||||
|
stagingHandler(stagedPhoto);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
[request startWithCompletionHandler:completionHandler];
|
||||||
|
return YES;
|
||||||
|
} else {
|
||||||
|
NSError *error = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"photo"
|
||||||
|
value:photo
|
||||||
|
message:@"Photos must have an imageURL or image."];
|
||||||
|
[self->_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_stageValue:(id)value
|
||||||
|
connection:(FBSDKGraphRequestConnection *)connection
|
||||||
|
stagingHandler:(void(^)(id stagedValue))stagingHandler
|
||||||
|
{
|
||||||
|
if ([value isKindOfClass:[NSString class]] ||
|
||||||
|
[value isKindOfClass:[NSNumber class]]) {
|
||||||
|
if (stagingHandler != NULL) {
|
||||||
|
stagingHandler(value);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
} else if ([value isKindOfClass:[NSURL class]]) {
|
||||||
|
if (stagingHandler != NULL) {
|
||||||
|
stagingHandler(((NSURL *)value).absoluteString);
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
} else if ([value isKindOfClass:[FBSDKSharePhoto class]]) {
|
||||||
|
return [self _stagePhoto:(FBSDKSharePhoto *)value connection:connection stagingHandler:stagingHandler];
|
||||||
|
} else if ([value isKindOfClass:[FBSDKShareOpenGraphObject class]]) {
|
||||||
|
return [self _stageOpenGraphObject:(FBSDKShareOpenGraphObject *)value
|
||||||
|
connection:connection
|
||||||
|
stagingHandler:stagingHandler
|
||||||
|
completionHandler:NULL];
|
||||||
|
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||||
|
return [self _stageArray:(NSArray *)value connection:connection stagingHandler:stagingHandler];
|
||||||
|
} else {
|
||||||
|
NSError *error = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"value"
|
||||||
|
value:value
|
||||||
|
message:@"Invalid value type found in Open Graph object."];
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_connection:(FBSDKGraphRequestConnection *)connection
|
||||||
|
addRequest:(FBSDKGraphRequest *)request
|
||||||
|
completionHandler:(FBSDKGraphRequestHandler)completionHandler
|
||||||
|
{
|
||||||
|
NSUInteger requestCount = connection.requests.count;
|
||||||
|
NSString *batchEntryName = [[NSString alloc] initWithFormat:@"request_%lu", (unsigned long)requestCount];
|
||||||
|
[connection addRequest:request batchEntryName:batchEntryName completionHandler:completionHandler];
|
||||||
|
return batchEntryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_addToPendingShareAPI
|
||||||
|
{
|
||||||
|
@synchronized(g_pendingFBSDKShareAPI) {
|
||||||
|
if ([g_pendingFBSDKShareAPI containsObject:self]) {
|
||||||
|
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors logEntry:@"FBSDKShareAPI did not share video content. Video upload already in progress."];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
[g_pendingFBSDKShareAPI addObject:self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_removeFromPendingShareAPI
|
||||||
|
{
|
||||||
|
@synchronized(g_pendingFBSDKShareAPI) {
|
||||||
|
[g_pendingFBSDKShareAPI removeObject:self];
|
||||||
|
_fileHandle = nil;
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
_assetRepresentation = nil;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKVideoUploaderDelegate
|
||||||
|
|
||||||
|
- (NSData *)videoChunkDataForVideoUploader:(FBSDKVideoUploader *)videoUploader startOffset:(NSUInteger)startOffset endOffset:(NSUInteger)endOffset
|
||||||
|
{
|
||||||
|
NSUInteger chunkSize = endOffset - startOffset;
|
||||||
|
if (_fileHandle) {
|
||||||
|
[_fileHandle seekToFileOffset:startOffset];
|
||||||
|
NSData *videoChunkData = [_fileHandle readDataOfLength:chunkSize];
|
||||||
|
if (videoChunkData == nil || videoChunkData.length != chunkSize) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return videoChunkData;
|
||||||
|
}
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
else if (_assetRepresentation) {
|
||||||
|
NSMutableData *data = [NSMutableData dataWithLength:chunkSize];
|
||||||
|
NSError *error;
|
||||||
|
NSUInteger bufferedLength = [_assetRepresentation getBytes:data.mutableBytes fromOffset:startOffset length:chunkSize error:&error];
|
||||||
|
if (bufferedLength != chunkSize || data == nil || error) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)videoUploader:(FBSDKVideoUploader *)videoUploader didCompleteWithResults:(NSDictionary *)results
|
||||||
|
{
|
||||||
|
results = [FBSDKTypeUtility dictionaryValue:results];
|
||||||
|
NSMutableDictionary *shareResults = [[NSMutableDictionary alloc] init];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
|
||||||
|
[FBSDKInternalUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:results[FBSDK_SHARE_VIDEO_ID]] forKey:FBSDK_SHARE_VIDEO_ID];
|
||||||
|
[_delegate sharer:self didCompleteWithResults:shareResults];
|
||||||
|
[self _removeFromPendingShareAPI];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)videoUploader:(FBSDKVideoUploader *)videoUploader didFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
[_delegate sharer:self didFailWithError:error];
|
||||||
|
[self _removeFromPendingShareAPI];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
33
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareButton.h
generated
Normal file
33
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareButton.h
generated
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKButton.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingButton.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A button to share content.
|
||||||
|
|
||||||
|
Tapping the receiver will invoke the FBSDKShareDialog with the attached shareContent. If the dialog cannot
|
||||||
|
be shown, the button will be disabled.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareButton : FBSDKButton <FBSDKSharingButton>
|
||||||
|
|
||||||
|
@end
|
||||||
90
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareButton.m
generated
Normal file
90
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareButton.m
generated
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareButton.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareDialog.h"
|
||||||
|
|
||||||
|
@implementation FBSDKShareButton
|
||||||
|
{
|
||||||
|
FBSDKShareDialog *_dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
- (id<FBSDKSharingContent>)shareContent
|
||||||
|
{
|
||||||
|
return _dialog.shareContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setShareContent:(id<FBSDKSharingContent>)shareContent
|
||||||
|
{
|
||||||
|
_dialog.shareContent = shareContent;
|
||||||
|
[self checkImplicitlyDisabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButtonImpressionTracking
|
||||||
|
|
||||||
|
- (NSDictionary *)analyticsParameters
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingEventName
|
||||||
|
{
|
||||||
|
return FBSDKAppEventNameFBSDKShareButtonImpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)impressionTrackingIdentifier
|
||||||
|
{
|
||||||
|
return @"share";
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKButton
|
||||||
|
|
||||||
|
- (void)configureButton
|
||||||
|
{
|
||||||
|
NSString *title =
|
||||||
|
NSLocalizedStringWithDefaultValue(@"ShareButton.Share", @"FacebookSDK", [FBSDKInternalUtility bundleForStrings],
|
||||||
|
@"Share",
|
||||||
|
@"The label for FBSDKShareButton");
|
||||||
|
|
||||||
|
[self configureWithIcon:nil
|
||||||
|
title:title
|
||||||
|
backgroundColor:nil
|
||||||
|
highlightedColor:nil];
|
||||||
|
|
||||||
|
[self addTarget:self action:@selector(_share:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
_dialog = [[FBSDKShareDialog alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isImplicitlyDisabled
|
||||||
|
{
|
||||||
|
return ![_dialog canShow] || ![_dialog validateWithError:NULL];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Helper Methods
|
||||||
|
|
||||||
|
- (void)_share:(id)sender
|
||||||
|
{
|
||||||
|
[self logTapEventWithEventName:FBSDKAppEventNameFBSDKShareButtonDidTap parameters:[self analyticsParameters]];
|
||||||
|
[_dialog show];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
53
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareCameraEffectContent.h
generated
Normal file
53
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareCameraEffectContent.h
generated
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKCameraEffectArguments.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKCameraEffectTextures.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingScheme.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for content to share with a Facebook camera effect.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareCameraEffectContent : NSObject <FBSDKSharingContent, FBSDKSharingScheme>
|
||||||
|
|
||||||
|
/**
|
||||||
|
ID of the camera effect to use.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *effectID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Arguments for the effect.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) FBSDKCameraEffectArguments *effectArguments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Textures for the effect.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) FBSDKCameraEffectTextures *effectTextures;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another camera effect content.
|
||||||
|
@param content The other content
|
||||||
|
@return YES if the receiver's values are equal to the other content's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToShareCameraEffectContent:(FBSDKShareCameraEffectContent *)content;
|
||||||
|
|
||||||
|
@end
|
||||||
245
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareCameraEffectContent.m
generated
Normal file
245
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareCameraEffectContent.m
generated
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareCameraEffectContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCameraEffectArguments+Internal.h"
|
||||||
|
#import "FBSDKCameraEffectTextures+Internal.h"
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKHashtag.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentEffectIDKey = @"effectID";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentEffectArgumentsKey = @"effectArguments";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentEffectTexturesKey = @"effectTextures";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentContentURLKey = @"contentURL";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentHashtagKey = @"hashtag";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentPeopleIDsKey = @"peopleIDs";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentPlaceIDKey = @"placeID";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentRefKey = @"ref";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentPageIDKey = @"pageID";
|
||||||
|
static NSString *const kFBSDKShareCameraEffectContentUUIDKey = @"uuid";
|
||||||
|
|
||||||
|
@implementation FBSDKShareCameraEffectContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize effectID = _effectID;
|
||||||
|
@synthesize effectArguments = _effectArguments;
|
||||||
|
@synthesize effectTextures = _effectTextures;
|
||||||
|
@synthesize contentURL = _contentURL;
|
||||||
|
@synthesize hashtag = _hashtag;
|
||||||
|
@synthesize peopleIDs = _peopleIDs;
|
||||||
|
@synthesize placeID = _placeID;
|
||||||
|
@synthesize ref = _ref;
|
||||||
|
@synthesize pageID = _pageID;
|
||||||
|
@synthesize shareUUID = _shareUUID;
|
||||||
|
|
||||||
|
#pragma mark - Initializer
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingContent
|
||||||
|
|
||||||
|
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
[parameters addEntriesFromDictionary:[self addParameters:parameters bridgeOptions:bridgeOptions]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, id> *updatedParameters = [NSMutableDictionary dictionaryWithDictionary:existingParameters];
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters
|
||||||
|
setObject:_effectID
|
||||||
|
forKey:@"effect_id"];
|
||||||
|
|
||||||
|
NSString *effectArgumentsJSON;
|
||||||
|
if (_effectArguments) {
|
||||||
|
effectArgumentsJSON = [FBSDKInternalUtility JSONStringForObject:[_effectArguments allArguments]
|
||||||
|
error:NULL
|
||||||
|
invalidObjectHandler:NULL];
|
||||||
|
}
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters
|
||||||
|
setObject:effectArgumentsJSON
|
||||||
|
forKey:@"effect_arguments"];
|
||||||
|
|
||||||
|
NSData *effectTexturesData;
|
||||||
|
if (_effectTextures) {
|
||||||
|
// Convert the entire textures dictionary into one NSData, because
|
||||||
|
// the existing API protocol only allows one value to be put into the pasteboard.
|
||||||
|
NSDictionary<NSString *, UIImage *> *texturesDict = [_effectTextures allTextures];
|
||||||
|
NSMutableDictionary<NSString *, NSData *> *texturesDataDict = [NSMutableDictionary dictionaryWithCapacity:texturesDict.count];
|
||||||
|
[texturesDict enumerateKeysAndObjectsUsingBlock:^(NSString *key, UIImage *img, BOOL *stop) {
|
||||||
|
// Convert UIImages to NSData, because UIImage is not archivable.
|
||||||
|
NSData *imageData = UIImagePNGRepresentation(img);
|
||||||
|
if (imageData) {
|
||||||
|
texturesDataDict[key] = imageData;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
effectTexturesData = [NSKeyedArchiver archivedDataWithRootObject:texturesDataDict];
|
||||||
|
}
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters
|
||||||
|
setObject:effectTexturesData
|
||||||
|
forKey:@"effect_textures"];
|
||||||
|
|
||||||
|
return updatedParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingScheme
|
||||||
|
|
||||||
|
- (NSString *)schemeForMode:(FBSDKShareDialogMode)mode
|
||||||
|
{
|
||||||
|
if ((FBSDKShareDialogModeNative == mode) || (FBSDKShareDialogModeAutomatic == mode)) {
|
||||||
|
if ([FBSDKInternalUtility isMSQRDPlayerAppInstalled]) {
|
||||||
|
// If installed, launch MSQRD Player for testing effects.
|
||||||
|
return FBSDK_CANOPENURL_MSQRD_PLAYER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (_effectID.length > 0) {
|
||||||
|
NSCharacterSet* nonDigitCharacters = [NSCharacterSet decimalDigitCharacterSet].invertedSet;
|
||||||
|
if ([_effectID rangeOfCharacterFromSet:nonDigitCharacters].location != NSNotFound) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithName:@"effectID"
|
||||||
|
value:_effectID
|
||||||
|
message:@"Invalid value for effectID, effectID can contain only numerical characters."];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
NSUInteger subhashes[] = {
|
||||||
|
_effectID.hash,
|
||||||
|
_effectArguments.hash,
|
||||||
|
_effectTextures.hash,
|
||||||
|
_contentURL.hash,
|
||||||
|
_hashtag.hash,
|
||||||
|
_peopleIDs.hash,
|
||||||
|
_placeID.hash,
|
||||||
|
_ref.hash,
|
||||||
|
_pageID.hash,
|
||||||
|
_shareUUID.hash,
|
||||||
|
};
|
||||||
|
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKShareCameraEffectContent class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToShareCameraEffectContent:(FBSDKShareCameraEffectContent *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToShareCameraEffectContent:(FBSDKShareCameraEffectContent *)content
|
||||||
|
{
|
||||||
|
return (content &&
|
||||||
|
[FBSDKInternalUtility object:_effectID isEqualToObject:content.effectID] &&
|
||||||
|
[FBSDKInternalUtility object:_effectArguments isEqualToObject:content.effectArguments] &&
|
||||||
|
[FBSDKInternalUtility object:_effectTextures isEqualToObject:content.effectTextures] &&
|
||||||
|
[FBSDKInternalUtility object:_contentURL isEqualToObject:content.contentURL] &&
|
||||||
|
[FBSDKInternalUtility object:_hashtag isEqualToObject:content.hashtag] &&
|
||||||
|
[FBSDKInternalUtility object:_peopleIDs isEqualToObject:content.peopleIDs] &&
|
||||||
|
[FBSDKInternalUtility object:_placeID isEqualToObject:content.placeID] &&
|
||||||
|
[FBSDKInternalUtility object:_ref isEqualToObject:content.ref] &&
|
||||||
|
[FBSDKInternalUtility object:_shareUUID isEqualToObject:content.shareUUID] &&
|
||||||
|
[FBSDKInternalUtility object:_pageID isEqualToObject:content.pageID]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_effectID = [decoder decodeObjectOfClass:[NSString class] forKey:kFBSDKShareCameraEffectContentEffectIDKey];
|
||||||
|
_effectArguments = [decoder decodeObjectOfClass:[FBSDKCameraEffectArguments class] forKey:kFBSDKShareCameraEffectContentEffectArgumentsKey];
|
||||||
|
_effectTextures = [decoder decodeObjectOfClass:[FBSDKCameraEffectTextures class] forKey:kFBSDKShareCameraEffectContentEffectTexturesKey];
|
||||||
|
_contentURL = [decoder decodeObjectOfClass:[NSURL class] forKey:kFBSDKShareCameraEffectContentContentURLKey];
|
||||||
|
_hashtag = [decoder decodeObjectOfClass:[FBSDKHashtag class] forKey:kFBSDKShareCameraEffectContentHashtagKey];
|
||||||
|
_peopleIDs = [decoder decodeObjectOfClass:[NSArray class] forKey:kFBSDKShareCameraEffectContentPeopleIDsKey];
|
||||||
|
_placeID = [decoder decodeObjectOfClass:[NSString class] forKey:kFBSDKShareCameraEffectContentPlaceIDKey];
|
||||||
|
_ref = [decoder decodeObjectOfClass:[NSString class] forKey:kFBSDKShareCameraEffectContentRefKey];
|
||||||
|
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:kFBSDKShareCameraEffectContentPageIDKey];
|
||||||
|
_shareUUID = [decoder decodeObjectOfClass:[NSString class] forKey:kFBSDKShareCameraEffectContentUUIDKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_effectID forKey:kFBSDKShareCameraEffectContentEffectIDKey];
|
||||||
|
[encoder encodeObject:_effectArguments forKey:kFBSDKShareCameraEffectContentEffectArgumentsKey];
|
||||||
|
[encoder encodeObject:_effectTextures forKey:kFBSDKShareCameraEffectContentEffectTexturesKey];
|
||||||
|
[encoder encodeObject:_contentURL forKey:kFBSDKShareCameraEffectContentContentURLKey];
|
||||||
|
[encoder encodeObject:_hashtag forKey:kFBSDKShareCameraEffectContentHashtagKey];
|
||||||
|
[encoder encodeObject:_peopleIDs forKey:kFBSDKShareCameraEffectContentPeopleIDsKey];
|
||||||
|
[encoder encodeObject:_placeID forKey:kFBSDKShareCameraEffectContentPlaceIDKey];
|
||||||
|
[encoder encodeObject:_ref forKey:kFBSDKShareCameraEffectContentRefKey];
|
||||||
|
[encoder encodeObject:_pageID forKey:kFBSDKShareCameraEffectContentPageIDKey];
|
||||||
|
[encoder encodeObject:_shareUUID forKey:kFBSDKShareCameraEffectContentUUIDKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareCameraEffectContent *copy = [[FBSDKShareCameraEffectContent alloc] init];
|
||||||
|
copy->_effectID = [_effectID copy];
|
||||||
|
copy->_effectArguments = [_effectArguments copy];
|
||||||
|
copy->_effectTextures = [_effectTextures copy];
|
||||||
|
copy->_contentURL = [_contentURL copy];
|
||||||
|
copy->_hashtag = [_hashtag copy];
|
||||||
|
copy->_peopleIDs = [_peopleIDs copy];
|
||||||
|
copy->_placeID = [_placeID copy];
|
||||||
|
copy->_ref = [_ref copy];
|
||||||
|
copy->_pageID = [_pageID copy];
|
||||||
|
copy->_shareUUID = [_shareUUID copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
85
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareConstants.h
generated
Normal file
85
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareConstants.h
generated
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error domain for all errors from FBSDKShareKit.
|
||||||
|
|
||||||
|
Error codes from the SDK in the range 200-299 are reserved for this domain.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSErrorDomain const FBSDKShareErrorDomain;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error domain for all errors from FBSDKShareKit.
|
||||||
|
|
||||||
|
Error codes from the SDK in the range 200-299 are reserved for this domain.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *const FBSDKShareErrorDomain;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NS_ERROR_ENUM
|
||||||
|
#define NS_ERROR_ENUM(_domain, _name) \
|
||||||
|
enum _name: NSInteger _name; \
|
||||||
|
enum __attribute__((ns_error_domain(_domain))) _name: NSInteger
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
FBSDKShareError
|
||||||
|
Error codes for FBSDKShareErrorDomain.
|
||||||
|
*/
|
||||||
|
typedef NS_ERROR_ENUM(FBSDKShareErrorDomain, FBSDKShareError)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
Reserved.
|
||||||
|
*/
|
||||||
|
FBSDKShareErrorReserved = 200,
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error code for errors from uploading open graph objects.
|
||||||
|
*/
|
||||||
|
FBSDKShareErrorOpenGraph,
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error code for when a sharing dialog is not available.
|
||||||
|
|
||||||
|
Use the canShare methods to check for this case before calling show.
|
||||||
|
*/
|
||||||
|
FBSDKShareErrorDialogNotAvailable,
|
||||||
|
|
||||||
|
/**
|
||||||
|
@The error code for unknown errors.
|
||||||
|
*/
|
||||||
|
FBSDKShareErrorUnknown,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deprecated
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSInteger, FBSDKShareErrorCode)
|
||||||
|
{
|
||||||
|
FBSDKShareReservedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKShareErrorReserved instead") = 200,
|
||||||
|
FBSDKShareOpenGraphErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKShareErrorOpenGraph instead"),
|
||||||
|
FBSDKShareDialogNotAvailableErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKShareErrorDialogNotAvailable instead"),
|
||||||
|
FBSDKShareUnknownErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKShareErrorUnknown instead"),
|
||||||
|
} DEPRECATED_MSG_ATTRIBUTE("use FBSDKShareError instead");
|
||||||
29
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareConstants.m
generated
Normal file
29
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareConstants.m
generated
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
|
||||||
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||||
|
|
||||||
|
NSErrorDomain const FBSDKShareErrorDomain = @"com.facebook.sdk.share";
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NSString *const FBSDKShareErrorDomain = @"com.facebook.sdk.share";
|
||||||
|
|
||||||
|
#endif
|
||||||
54
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialog.h
generated
Normal file
54
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialog.h
generated
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKShareDialogMode.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharing.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A dialog for sharing content on Facebook.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareDialog : NSObject <FBSDKSharingDialog>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to show an FBSDKShareDialog with a fromViewController, content and a delegate.
|
||||||
|
@param viewController A UIViewController to present the dialog from, if appropriate.
|
||||||
|
@param content The content to be shared.
|
||||||
|
@param delegate The receiver's delegate.
|
||||||
|
*/
|
||||||
|
+ (instancetype)showFromViewController:(UIViewController *)viewController
|
||||||
|
withContent:(id<FBSDKSharingContent>)content
|
||||||
|
delegate:(id<FBSDKSharingDelegate>)delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A UIViewController to present the dialog from.
|
||||||
|
|
||||||
|
If not specified, the top most view controller will be automatically determined as best as possible.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) UIViewController *fromViewController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The mode with which to display the dialog.
|
||||||
|
|
||||||
|
Defaults to FBSDKShareDialogModeAutomatic, which will automatically choose the best available mode.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKShareDialogMode mode;
|
||||||
|
|
||||||
|
@end
|
||||||
1223
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialog.m
generated
Normal file
1223
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialog.m
generated
Normal file
File diff suppressed because it is too large
Load Diff
63
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialogMode.h
generated
Normal file
63
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialogMode.h
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
NS_ENUM(NSUInteger, FBSDKShareDialogMode)
|
||||||
|
Modes for the FBSDKShareDialog.
|
||||||
|
|
||||||
|
The automatic mode will progressively check the availability of different modes and open the most
|
||||||
|
appropriate mode for the dialog that is available.
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKShareDialogMode)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
Acts with the most appropriate mode that is available.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeAutomatic = 0,
|
||||||
|
/**
|
||||||
|
@Displays the dialog in the main native Facebook app.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeNative,
|
||||||
|
/**
|
||||||
|
@Displays the dialog in the iOS integrated share sheet.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeShareSheet,
|
||||||
|
/**
|
||||||
|
@Displays the dialog in Safari.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeBrowser,
|
||||||
|
/**
|
||||||
|
@Displays the dialog in a UIWebView within the app.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeWeb,
|
||||||
|
/**
|
||||||
|
@Displays the feed dialog in Safari.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeFeedBrowser,
|
||||||
|
/**
|
||||||
|
@Displays the feed dialog in a UIWebView within the app.
|
||||||
|
*/
|
||||||
|
FBSDKShareDialogModeFeedWeb,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Converts an FBSDKShareDialogMode to an NSString.
|
||||||
|
*/
|
||||||
|
FOUNDATION_EXPORT NSString *NSStringFromFBSDKShareDialogMode(FBSDKShareDialogMode dialogMode);
|
||||||
51
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialogMode.m
generated
Normal file
51
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareDialogMode.m
generated
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareDialogMode.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
|
||||||
|
NSString *NSStringFromFBSDKShareDialogMode(FBSDKShareDialogMode dialogMode)
|
||||||
|
{
|
||||||
|
switch (dialogMode) {
|
||||||
|
case FBSDKShareDialogModeAutomatic:{
|
||||||
|
return FBSDKAppEventsDialogShareModeAutomatic;
|
||||||
|
}
|
||||||
|
case FBSDKShareDialogModeBrowser:{
|
||||||
|
return FBSDKAppEventsDialogShareModeBrowser;
|
||||||
|
}
|
||||||
|
case FBSDKShareDialogModeNative:{
|
||||||
|
return FBSDKAppEventsDialogShareModeNative;
|
||||||
|
}
|
||||||
|
case FBSDKShareDialogModeShareSheet:{
|
||||||
|
return FBSDKAppEventsDialogShareModeShareSheet;
|
||||||
|
}
|
||||||
|
case FBSDKShareDialogModeWeb:{
|
||||||
|
return FBSDKAppEventsDialogShareModeWeb;
|
||||||
|
}
|
||||||
|
case FBSDKShareDialogModeFeedBrowser: {
|
||||||
|
return FBSDKAppEventsDialogShareModeFeedBrowser;
|
||||||
|
}
|
||||||
|
case FBSDKShareDialogModeFeedWeb:{
|
||||||
|
return FBSDKAppEventsDialogShareModeFeedWeb;
|
||||||
|
}
|
||||||
|
default:{
|
||||||
|
return FBSDKAppEventsDialogShareModeUnknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
62
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit.h
generated
Normal file
62
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit.h
generated
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKHashtag.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareAPI.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareConstants.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareLinkContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMediaContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerGenericTemplateContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerGenericTemplateElement.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerMediaTemplateContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerOpenGraphMusicTemplateContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerURLActionButton.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareOpenGraphAction.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareOpenGraphContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareOpenGraphObject.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharePhoto.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharePhotoContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareVideo.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareVideoContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharing.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
#import <FBSDKShareKit/FBSDKAppGroupAddDialog.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKAppGroupContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKAppGroupJoinDialog.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKAppInviteContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKAppInviteDialog.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKGameRequestContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKGameRequestDialog.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKLikeButton.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKLikeControl.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKLikeObjectType.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKMessageDialog.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareButton.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareCameraEffectContent.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareDialog.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareDialogMode.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSendButton.h>
|
||||||
|
#else
|
||||||
|
#import <FBSDKShareKit/FBSDKDeviceShareViewController.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKDeviceShareButton.h>
|
||||||
|
#endif
|
||||||
78
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareLinkContent.h
generated
Normal file
78
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareLinkContent.h
generated
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for status and link content to be shared.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareLinkContent : NSObject <FBSDKSharingContent>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The description of the link.
|
||||||
|
|
||||||
|
If not specified, this field is automatically populated by information scraped from the contentURL,
|
||||||
|
typically the title of the page. This value may be discarded for specially handled links (ex: iTunes URLs).
|
||||||
|
@return The description of the link
|
||||||
|
|
||||||
|
@deprecated `contentDescription` is deprecated from Graph API 2.9.
|
||||||
|
For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) NSString *contentDescription
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("`contentDescription` is deprecated from Graph API 2.9");
|
||||||
|
|
||||||
|
/**
|
||||||
|
The title to display for this link.
|
||||||
|
|
||||||
|
This value may be discarded for specially handled links (ex: iTunes URLs).
|
||||||
|
@return The link title
|
||||||
|
|
||||||
|
@deprecated `contentTitle` is deprecated from Graph API 2.9.
|
||||||
|
For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) NSString *contentTitle
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("`contentTitle` is deprecated from Graph API 2.9");
|
||||||
|
|
||||||
|
/**
|
||||||
|
The URL of a picture to attach to this content.
|
||||||
|
@return The network URL of an image
|
||||||
|
|
||||||
|
@deprecated `imageURL` is deprecated from Graph API 2.9.
|
||||||
|
For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) NSURL *imageURL
|
||||||
|
DEPRECATED_MSG_ATTRIBUTE("`imageURL` is deprecated from Graph API 2.9");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Some quote text of the link.
|
||||||
|
|
||||||
|
If specified, the quote text will render with custom styling on top of the link.
|
||||||
|
@return The quote text of a link
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *quote;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another link content.
|
||||||
|
@param content The other content
|
||||||
|
@return YES if the receiver's values are equal to the other content's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToShareLinkContent:(FBSDKShareLinkContent *)content;
|
||||||
|
|
||||||
|
@end
|
||||||
238
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareLinkContent.m
generated
Normal file
238
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareLinkContent.m
generated
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareLinkContent+Internal.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKHashtag.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_CONTENT_DESCRIPTION_KEY @"contentDescription"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_CONTENT_TITLE_KEY @"contentTitle"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_CONTENT_URL_KEY @"contentURL"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_HASHTAG_KEY @"hashtag"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_IMAGE_URL_KEY @"imageURL"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_PEOPLE_IDS_KEY @"peopleIDs"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_PLACE_ID_KEY @"placeID"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_REF_KEY @"ref"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_PAGE_ID_KEY @"pageID"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_QUOTE_TEXT_KEY @"quote"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_FEED_PARAMETERS_KEY @"feedParameters"
|
||||||
|
#define FBSDK_SHARE_STATUS_CONTENT_UUID_KEY @"uuid"
|
||||||
|
|
||||||
|
@implementation FBSDKShareLinkContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize contentURL = _contentURL;
|
||||||
|
@synthesize hashtag = _hashtag;
|
||||||
|
@synthesize peopleIDs = _peopleIDs;
|
||||||
|
@synthesize placeID = _placeID;
|
||||||
|
@synthesize ref = _ref;
|
||||||
|
@synthesize pageID = _pageID;
|
||||||
|
@synthesize feedParameters = _feedParameters;
|
||||||
|
@synthesize quote = _quote;
|
||||||
|
@synthesize shareUUID = _shareUUID;
|
||||||
|
|
||||||
|
#pragma mark - Initializer
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Setters
|
||||||
|
|
||||||
|
- (void)setPeopleIDs:(NSArray *)peopleIDs
|
||||||
|
{
|
||||||
|
[FBSDKShareUtility assertCollection:peopleIDs ofClass:[NSString class] name:@"peopleIDs"];
|
||||||
|
if (![FBSDKInternalUtility object:_peopleIDs isEqualToObject:peopleIDs]) {
|
||||||
|
_peopleIDs = [peopleIDs copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setFeedParameters:(NSDictionary *)feedParameters
|
||||||
|
{
|
||||||
|
if (![_feedParameters isEqualToDictionary:feedParameters]) {
|
||||||
|
_feedParameters = [feedParameters copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingContent
|
||||||
|
|
||||||
|
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
[parameters addEntriesFromDictionary:[self addParameters:parameters bridgeOptions:bridgeOptions]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, id> *updatedParameters = [NSMutableDictionary dictionaryWithDictionary:existingParameters];
|
||||||
|
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters setObject:_contentURL forKey:@"link"];
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters setObject:_contentTitle forKey:@"name"];
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters setObject:_contentDescription forKey:@"description"];
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters setObject:_imageURL forKey:@"picture"];
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters setObject:_quote forKey:@"quote"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
Pass link parameter as "messenger_link" due to versioning requirements for message dialog flow.
|
||||||
|
We will only use the new share flow we developed if messenger_link is present, not link.
|
||||||
|
*/
|
||||||
|
[FBSDKInternalUtility dictionary:updatedParameters setObject:_contentURL forKey:@"messenger_link"];
|
||||||
|
|
||||||
|
return updatedParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
return ([FBSDKShareUtility validateNetworkURL:_contentURL name:@"contentURL" error:errorRef] &&
|
||||||
|
[FBSDKShareUtility validateNetworkURL:_imageURL name:@"imageURL" error:errorRef]);
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
NSUInteger subhashes[] = {
|
||||||
|
_contentDescription.hash,
|
||||||
|
_contentURL.hash,
|
||||||
|
_hashtag.hash,
|
||||||
|
_imageURL.hash,
|
||||||
|
_peopleIDs.hash,
|
||||||
|
_placeID.hash,
|
||||||
|
_ref.hash,
|
||||||
|
_pageID.hash,
|
||||||
|
_contentTitle.hash,
|
||||||
|
_feedParameters.hash,
|
||||||
|
_quote.hash,
|
||||||
|
_shareUUID.hash,
|
||||||
|
};
|
||||||
|
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKShareLinkContent class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToShareLinkContent:(FBSDKShareLinkContent *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToShareLinkContent:(FBSDKShareLinkContent *)content
|
||||||
|
{
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
return (content &&
|
||||||
|
[FBSDKInternalUtility object:_contentDescription isEqualToObject:content.contentDescription] &&
|
||||||
|
[FBSDKInternalUtility object:_contentTitle isEqualToObject:content.contentTitle] &&
|
||||||
|
[FBSDKInternalUtility object:_contentURL isEqualToObject:content.contentURL] &&
|
||||||
|
[FBSDKInternalUtility object:_hashtag isEqualToObject:content.hashtag] &&
|
||||||
|
[FBSDKInternalUtility object:_feedParameters isEqualToObject:content.feedParameters] &&
|
||||||
|
[FBSDKInternalUtility object:_imageURL isEqualToObject:content.imageURL] &&
|
||||||
|
[FBSDKInternalUtility object:_peopleIDs isEqualToObject:content.peopleIDs] &&
|
||||||
|
[FBSDKInternalUtility object:_placeID isEqualToObject:content.placeID] &&
|
||||||
|
[FBSDKInternalUtility object:_ref isEqualToObject:content.ref] &&
|
||||||
|
[FBSDKInternalUtility object:_pageID isEqualToObject:content.pageID] &&
|
||||||
|
[FBSDKInternalUtility object:_shareUUID isEqualToObject:content.shareUUID]) &&
|
||||||
|
[FBSDKInternalUtility object:_quote isEqualToObject:content.quote];
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_contentDescription = [decoder decodeObjectOfClass:[NSString class]
|
||||||
|
forKey:FBSDK_SHARE_STATUS_CONTENT_CONTENT_DESCRIPTION_KEY];
|
||||||
|
_contentTitle = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_STATUS_CONTENT_CONTENT_TITLE_KEY];
|
||||||
|
_contentURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_SHARE_STATUS_CONTENT_CONTENT_URL_KEY];
|
||||||
|
_feedParameters = [decoder decodeObjectOfClass:[NSDictionary class] forKey:FBSDK_SHARE_STATUS_CONTENT_FEED_PARAMETERS_KEY];
|
||||||
|
_hashtag = [decoder decodeObjectOfClass:[FBSDKHashtag class] forKey:FBSDK_SHARE_STATUS_CONTENT_HASHTAG_KEY];
|
||||||
|
_imageURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_SHARE_STATUS_CONTENT_IMAGE_URL_KEY];
|
||||||
|
_peopleIDs = [decoder decodeObjectOfClass:[NSArray class] forKey:FBSDK_SHARE_STATUS_CONTENT_PEOPLE_IDS_KEY];
|
||||||
|
_placeID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_STATUS_CONTENT_PLACE_ID_KEY];
|
||||||
|
_ref = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_STATUS_CONTENT_REF_KEY];
|
||||||
|
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_STATUS_CONTENT_PAGE_ID_KEY];
|
||||||
|
_quote = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_STATUS_CONTENT_QUOTE_TEXT_KEY];
|
||||||
|
_shareUUID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_STATUS_CONTENT_UUID_KEY];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_contentDescription forKey:FBSDK_SHARE_STATUS_CONTENT_CONTENT_DESCRIPTION_KEY];
|
||||||
|
[encoder encodeObject:_contentTitle forKey:FBSDK_SHARE_STATUS_CONTENT_CONTENT_TITLE_KEY];
|
||||||
|
[encoder encodeObject:_contentURL forKey:FBSDK_SHARE_STATUS_CONTENT_CONTENT_URL_KEY];
|
||||||
|
[encoder encodeObject:_feedParameters forKey:FBSDK_SHARE_STATUS_CONTENT_FEED_PARAMETERS_KEY];
|
||||||
|
[encoder encodeObject:_hashtag forKey:FBSDK_SHARE_STATUS_CONTENT_HASHTAG_KEY];
|
||||||
|
[encoder encodeObject:_imageURL forKey:FBSDK_SHARE_STATUS_CONTENT_IMAGE_URL_KEY];
|
||||||
|
[encoder encodeObject:_peopleIDs forKey:FBSDK_SHARE_STATUS_CONTENT_PEOPLE_IDS_KEY];
|
||||||
|
[encoder encodeObject:_placeID forKey:FBSDK_SHARE_STATUS_CONTENT_PLACE_ID_KEY];
|
||||||
|
[encoder encodeObject:_ref forKey:FBSDK_SHARE_STATUS_CONTENT_REF_KEY];
|
||||||
|
[encoder encodeObject:_pageID forKey:FBSDK_SHARE_STATUS_CONTENT_PAGE_ID_KEY];
|
||||||
|
[encoder encodeObject:_quote forKey:FBSDK_SHARE_STATUS_CONTENT_QUOTE_TEXT_KEY];
|
||||||
|
[encoder encodeObject:_shareUUID forKey:FBSDK_SHARE_STATUS_CONTENT_UUID_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareLinkContent *copy = [[FBSDKShareLinkContent alloc] init];
|
||||||
|
copy->_contentDescription = [_contentDescription copy];
|
||||||
|
copy->_contentTitle = [_contentTitle copy];
|
||||||
|
copy->_contentURL = [_contentURL copy];
|
||||||
|
copy->_feedParameters = [_feedParameters copy];
|
||||||
|
copy->_hashtag = [_hashtag copy];
|
||||||
|
copy->_imageURL = [_imageURL copy];
|
||||||
|
copy->_peopleIDs = [_peopleIDs copy];
|
||||||
|
copy->_placeID = [_placeID copy];
|
||||||
|
copy->_ref = [_ref copy];
|
||||||
|
copy->_pageID = [_pageID copy];
|
||||||
|
copy->_quote = [_quote copy];
|
||||||
|
copy->_shareUUID = [_shareUUID copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
41
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMediaContent.h
generated
Normal file
41
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMediaContent.h
generated
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for media content (photo or video) to be shared.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareMediaContent : NSObject <FBSDKSharingContent>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Media to be shared.
|
||||||
|
@return Array of the media (FBSDKSharePhoto or FBSDKShareVideo)
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSArray *media;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another media content.
|
||||||
|
@param content The other content
|
||||||
|
@return YES if the receiver's values are equal to the other content's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToShareMediaContent:(FBSDKShareMediaContent *)content;
|
||||||
|
|
||||||
|
@end
|
||||||
237
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMediaContent.m
generated
Normal file
237
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMediaContent.m
generated
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareMediaContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKHashtag.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKSharePhoto.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
#import "FBSDKShareVideo.h"
|
||||||
|
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_CONTENT_URL_KEY @"contentURL"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_HASHTAG_KEY @"hashtag"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_PEOPLE_IDS_KEY @"peopleIDs"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_MEDIA_KEY @"media"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_PLACE_ID_KEY @"placeID"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_REF_KEY @"ref"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_PAGE_ID_KEY @"pageID"
|
||||||
|
#define FBSDK_SHARE_MEDIA_CONTENT_UUID_KEY @"uuid"
|
||||||
|
|
||||||
|
@implementation FBSDKShareMediaContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize contentURL = _contentURL;
|
||||||
|
@synthesize hashtag = _hashtag;
|
||||||
|
@synthesize peopleIDs = _peopleIDs;
|
||||||
|
@synthesize placeID = _placeID;
|
||||||
|
@synthesize ref = _ref;
|
||||||
|
@synthesize pageID = _pageID;
|
||||||
|
@synthesize shareUUID = _shareUUID;
|
||||||
|
|
||||||
|
#pragma mark - Initializer
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Setters
|
||||||
|
|
||||||
|
- (void)setPeopleIDs:(NSArray *)peopleIDs
|
||||||
|
{
|
||||||
|
[FBSDKShareUtility assertCollection:peopleIDs ofClass:[NSString class] name:@"peopleIDs"];
|
||||||
|
if (![FBSDKInternalUtility object:_peopleIDs isEqualToObject:peopleIDs]) {
|
||||||
|
_peopleIDs = [peopleIDs copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setMedia:(NSArray *)media
|
||||||
|
{
|
||||||
|
[FBSDKShareUtility assertCollection:media ofClassStrings:@[NSStringFromClass([FBSDKSharePhoto class]), NSStringFromClass([FBSDKShareVideo class])] name:@"media"];
|
||||||
|
if (![FBSDKInternalUtility object:_media isEqualToObject:media]) {
|
||||||
|
_media = [media copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingContent
|
||||||
|
|
||||||
|
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
// FBSDKShareMediaContent is currently available via the Share extension only (thus no parameterization implemented at this time)
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
// FBSDKShareMediaContent is currently available via the Share extension only (thus no parameterization implemented at this time)
|
||||||
|
return existingParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (![FBSDKShareUtility validateArray:_media minCount:1 maxCount:20 name:@"photos" error:errorRef]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
int videoCount = 0;
|
||||||
|
for (id media in _media) {
|
||||||
|
if ([media isKindOfClass:[FBSDKSharePhoto class]]) {
|
||||||
|
FBSDKSharePhoto *photo = (FBSDKSharePhoto *)media;
|
||||||
|
if (![photo validateWithOptions:bridgeOptions error:NULL]) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"media"
|
||||||
|
value:media
|
||||||
|
message:@"photos must have UIImages"];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
} else if ([media isKindOfClass:[FBSDKShareVideo class]]) {
|
||||||
|
if (videoCount > 0) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"media"
|
||||||
|
value:media
|
||||||
|
message:@"Only 1 video is allowed"];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
videoCount++;
|
||||||
|
FBSDKShareVideo *video = (FBSDKShareVideo *)media;
|
||||||
|
if (![FBSDKShareUtility validateRequiredValue:video name:@"video" error:errorRef]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
if (![video validateWithOptions:bridgeOptions error:errorRef]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"media"
|
||||||
|
value:media
|
||||||
|
message:@"Only FBSDKSharePhoto and FBSDKShareVideo are allowed in `media` property"];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
NSUInteger subhashes[] = {
|
||||||
|
_contentURL.hash,
|
||||||
|
_hashtag.hash,
|
||||||
|
_peopleIDs.hash,
|
||||||
|
_media.hash,
|
||||||
|
_placeID.hash,
|
||||||
|
_ref.hash,
|
||||||
|
_pageID.hash,
|
||||||
|
_shareUUID.hash,
|
||||||
|
};
|
||||||
|
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKShareMediaContent class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToShareMediaContent:(FBSDKShareMediaContent *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToShareMediaContent:(FBSDKShareMediaContent *)content
|
||||||
|
{
|
||||||
|
return (content &&
|
||||||
|
[FBSDKInternalUtility object:_contentURL isEqualToObject:content.contentURL] &&
|
||||||
|
[FBSDKInternalUtility object:_hashtag isEqualToObject:content.hashtag] &&
|
||||||
|
[FBSDKInternalUtility object:_peopleIDs isEqualToObject:content.peopleIDs] &&
|
||||||
|
[FBSDKInternalUtility object:_media isEqualToObject:content.media] &&
|
||||||
|
[FBSDKInternalUtility object:_placeID isEqualToObject:content.placeID] &&
|
||||||
|
[FBSDKInternalUtility object:_ref isEqualToObject:content.ref] &&
|
||||||
|
[FBSDKInternalUtility object:_shareUUID isEqualToObject:content.shareUUID] &&
|
||||||
|
[FBSDKInternalUtility object:_pageID isEqualToObject:content.pageID]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_contentURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_SHARE_MEDIA_CONTENT_CONTENT_URL_KEY];
|
||||||
|
_hashtag = [decoder decodeObjectOfClass:[FBSDKHashtag class] forKey:FBSDK_SHARE_MEDIA_CONTENT_HASHTAG_KEY];
|
||||||
|
_peopleIDs = [decoder decodeObjectOfClass:[NSArray class] forKey:FBSDK_SHARE_MEDIA_CONTENT_PEOPLE_IDS_KEY];
|
||||||
|
NSSet *classes = [NSSet setWithObjects:[NSArray class], [FBSDKSharePhoto class], nil];
|
||||||
|
_media = [decoder decodeObjectOfClasses:classes forKey:FBSDK_SHARE_MEDIA_CONTENT_MEDIA_KEY];
|
||||||
|
_placeID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_MEDIA_CONTENT_PLACE_ID_KEY];
|
||||||
|
_ref = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_MEDIA_CONTENT_REF_KEY];
|
||||||
|
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_MEDIA_CONTENT_PAGE_ID_KEY];
|
||||||
|
_shareUUID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_MEDIA_CONTENT_UUID_KEY];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_contentURL forKey:FBSDK_SHARE_MEDIA_CONTENT_CONTENT_URL_KEY];
|
||||||
|
[encoder encodeObject:_hashtag forKey:FBSDK_SHARE_MEDIA_CONTENT_HASHTAG_KEY];
|
||||||
|
[encoder encodeObject:_peopleIDs forKey:FBSDK_SHARE_MEDIA_CONTENT_PEOPLE_IDS_KEY];
|
||||||
|
[encoder encodeObject:_media forKey:FBSDK_SHARE_MEDIA_CONTENT_MEDIA_KEY];
|
||||||
|
[encoder encodeObject:_placeID forKey:FBSDK_SHARE_MEDIA_CONTENT_PLACE_ID_KEY];
|
||||||
|
[encoder encodeObject:_ref forKey:FBSDK_SHARE_MEDIA_CONTENT_REF_KEY];
|
||||||
|
[encoder encodeObject:_pageID forKey:FBSDK_SHARE_MEDIA_CONTENT_PAGE_ID_KEY];
|
||||||
|
[encoder encodeObject:_shareUUID forKey:FBSDK_SHARE_MEDIA_CONTENT_UUID_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareMediaContent *copy = [[FBSDKShareMediaContent alloc] init];
|
||||||
|
copy->_contentURL = [_contentURL copy];
|
||||||
|
copy->_hashtag = [_hashtag copy];
|
||||||
|
copy->_peopleIDs = [_peopleIDs copy];
|
||||||
|
copy->_media = [_media copy];
|
||||||
|
copy->_placeID = [_placeID copy];
|
||||||
|
copy->_ref = [_ref copy];
|
||||||
|
copy->_pageID = [_pageID copy];
|
||||||
|
copy->_shareUUID = [_shareUUID copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
34
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerActionButton.h
generated
Normal file
34
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerActionButton.h
generated
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A base interface for Messenger share action buttons.
|
||||||
|
*/
|
||||||
|
@protocol FBSDKShareMessengerActionButton <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The title displayed to the user for the button.
|
||||||
|
@return The title for the button.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *title;
|
||||||
|
|
||||||
|
@end
|
||||||
55
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateContent.h
generated
Normal file
55
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateContent.h
generated
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
@class FBSDKShareMessengerGenericTemplateElement;
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKShareMessengerGenericTemplateImageAspectRatio) {
|
||||||
|
FBSDKShareMessengerGenericTemplateImageAspectRatioHorizontal = 0,
|
||||||
|
FBSDKShareMessengerGenericTemplateImageAspectRatioSquare
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for sharing a generic template element to Messenger. This wrapper element allows
|
||||||
|
specifying whether or not the bubble is sharable and what aspect to render the images.
|
||||||
|
See https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic
|
||||||
|
for more details.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareMessengerGenericTemplateContent : NSObject <FBSDKSharingContent>
|
||||||
|
|
||||||
|
/**
|
||||||
|
This specifies whether or not this generic template message can be shared again after the
|
||||||
|
initial share. Defaults to false.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL isSharable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The aspect ratio for when the image is rendered in the generic template bubble after being
|
||||||
|
shared. Defaults to horizontal.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKShareMessengerGenericTemplateImageAspectRatio imageAspectRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A generic template element with a title, optional subtitle, optional image, etc. Required.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) FBSDKShareMessengerGenericTemplateElement *element;
|
||||||
|
|
||||||
|
@end
|
||||||
186
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateContent.m
generated
Normal file
186
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateContent.m
generated
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareMessengerGenericTemplateContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareMessengerContentUtility.h"
|
||||||
|
#import "FBSDKShareMessengerGenericTemplateElement.h"
|
||||||
|
#import "FBSDKShareMessengerURLActionButton.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
static NSString *const kGenericTemplatePageIDKey = @"pageID";
|
||||||
|
static NSString *const kGenericTemplateUUIDKey = @"UUID";
|
||||||
|
static NSString *const kGenericTemplateIsSharableKey = @"isSharable";
|
||||||
|
static NSString *const kGenericTemplateImageAspectRatioKey = @"imageAspectRatio";
|
||||||
|
static NSString *const kGenericTemplateElementKey = @"element";
|
||||||
|
|
||||||
|
static NSString *_ImageAspectRatioString(FBSDKShareMessengerGenericTemplateImageAspectRatio imageAspectRatio)
|
||||||
|
{
|
||||||
|
switch (imageAspectRatio) {
|
||||||
|
case FBSDKShareMessengerGenericTemplateImageAspectRatioSquare:
|
||||||
|
return @"square";
|
||||||
|
case FBSDKShareMessengerGenericTemplateImageAspectRatioHorizontal:
|
||||||
|
return @"horizontal";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray<NSDictionary<NSString *, id> *> *_SerializableGenericTemplateElementsFromElements(NSArray<FBSDKShareMessengerGenericTemplateElement *> *elements)
|
||||||
|
{
|
||||||
|
NSMutableArray<NSDictionary<NSString *, id> *> *serializableElements = [NSMutableArray array];
|
||||||
|
for (FBSDKShareMessengerGenericTemplateElement *element in elements) {
|
||||||
|
NSMutableDictionary<NSString *, id> *elementDictionary = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:elementDictionary setObject:element.title forKey:@"title"];
|
||||||
|
[FBSDKInternalUtility dictionary:elementDictionary setObject:element.subtitle forKey:@"subtitle"];
|
||||||
|
[FBSDKInternalUtility dictionary:elementDictionary setObject:element.imageURL.absoluteString forKey:@"image_url"];
|
||||||
|
[FBSDKInternalUtility dictionary:elementDictionary setObject:SerializableButtonsFromButton(element.button) forKey:kFBSDKShareMessengerButtonsKey];
|
||||||
|
if ([element.defaultAction isKindOfClass:[FBSDKShareMessengerURLActionButton class]]) {
|
||||||
|
[FBSDKInternalUtility dictionary:elementDictionary setObject:SerializableButtonFromURLButton(element.defaultAction, YES) forKey:@"default_action"];
|
||||||
|
}
|
||||||
|
|
||||||
|
[serializableElements addObject:elementDictionary];
|
||||||
|
}
|
||||||
|
|
||||||
|
return serializableElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation FBSDKShareMessengerGenericTemplateContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize contentURL = _contentURL;
|
||||||
|
@synthesize hashtag = _hashtag;
|
||||||
|
@synthesize peopleIDs = _peopleIDs;
|
||||||
|
@synthesize placeID = _placeID;
|
||||||
|
@synthesize ref = _ref;
|
||||||
|
@synthesize pageID = _pageID;
|
||||||
|
@synthesize shareUUID = _shareUUID;
|
||||||
|
|
||||||
|
#pragma mark - Initializer
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingContent
|
||||||
|
|
||||||
|
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
[parameters addEntriesFromDictionary:[self addParameters:parameters bridgeOptions:bridgeOptions]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, id> *updatedParameters = [NSMutableDictionary dictionaryWithDictionary:existingParameters];
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *payload = [NSMutableDictionary dictionary];
|
||||||
|
payload[kFBSDKShareMessengerTemplateTypeKey] = @"generic";
|
||||||
|
payload[@"sharable"] = @(_isSharable);
|
||||||
|
payload[@"image_aspect_ratio"] = _ImageAspectRatioString(_imageAspectRatio);
|
||||||
|
payload[kFBSDKShareMessengerElementsKey] = _SerializableGenericTemplateElementsFromElements(@[_element]);
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *attachment = [NSMutableDictionary dictionary];
|
||||||
|
attachment[kFBSDKShareMessengerTypeKey] = kFBSDKShareMessengerTemplateKey;
|
||||||
|
attachment[kFBSDKShareMessengerPayloadKey] = payload;
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *contentForShare = [NSMutableDictionary dictionary];
|
||||||
|
contentForShare[kFBSDKShareMessengerAttachmentKey] = attachment;
|
||||||
|
|
||||||
|
FBSDKShareMessengerGenericTemplateElement *firstElement = _element;
|
||||||
|
NSMutableDictionary<NSString *, id> *contentForPreview = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:@"DEFAULT" forKey:@"preview_type"];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:firstElement.title forKey:@"title"];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:firstElement.subtitle forKey:@"subtitle"];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:firstElement.imageURL.absoluteString forKey:@"image_url"];
|
||||||
|
if (firstElement.button) {
|
||||||
|
AddToContentPreviewDictionaryForButton(contentForPreview, firstElement.button);
|
||||||
|
} else {
|
||||||
|
AddToContentPreviewDictionaryForButton(contentForPreview, firstElement.defaultAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
[FBSDKShareMessengerContentUtility addToParameters:updatedParameters contentForShare:contentForShare contentForPreview:contentForPreview];
|
||||||
|
|
||||||
|
return updatedParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
return [FBSDKShareUtility validateRequiredValue:_element.title
|
||||||
|
name:@"element.title"
|
||||||
|
error:errorRef]
|
||||||
|
&& [FBSDKShareMessengerContentUtility validateMessengerActionButton:_element.defaultAction
|
||||||
|
isDefaultActionButton:YES
|
||||||
|
pageID:_pageID
|
||||||
|
error:errorRef]
|
||||||
|
&& [FBSDKShareMessengerContentUtility validateMessengerActionButton:_element.button
|
||||||
|
isDefaultActionButton:NO
|
||||||
|
pageID:_pageID
|
||||||
|
error:errorRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:kGenericTemplatePageIDKey];
|
||||||
|
_isSharable = [decoder decodeBoolForKey:kGenericTemplateIsSharableKey];
|
||||||
|
_imageAspectRatio = [[decoder decodeObjectOfClass:[NSNumber class] forKey:kGenericTemplateImageAspectRatioKey] unsignedIntegerValue];
|
||||||
|
_element = [decoder decodeObjectForKey:kGenericTemplateElementKey];
|
||||||
|
_shareUUID = [decoder decodeObjectOfClass:[NSString class] forKey:kGenericTemplateUUIDKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_pageID forKey:kGenericTemplatePageIDKey];
|
||||||
|
[encoder encodeBool:_isSharable forKey:kGenericTemplateIsSharableKey];
|
||||||
|
[encoder encodeObject:@(_imageAspectRatio) forKey:kGenericTemplateImageAspectRatioKey];
|
||||||
|
[encoder encodeObject:_element forKey:kGenericTemplateElementKey];
|
||||||
|
[encoder encodeObject:_shareUUID forKey:kGenericTemplateUUIDKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareMessengerGenericTemplateContent *copy = [[FBSDKShareMessengerGenericTemplateContent alloc] init];
|
||||||
|
copy->_pageID = [_pageID copy];
|
||||||
|
copy->_isSharable = _isSharable;
|
||||||
|
copy->_imageAspectRatio = _imageAspectRatio;
|
||||||
|
copy->_element = [_element copy];
|
||||||
|
copy->_shareUUID = [_shareUUID copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
56
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateElement.h
generated
Normal file
56
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateElement.h
generated
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for sharing a generic template element to Messenger. This allows specifying title, subtitle,
|
||||||
|
image, default action, and any other buttons. Title is required. See
|
||||||
|
https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic for more details.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareMessengerGenericTemplateElement : NSObject <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The rendered title for the shared generic template element. Required.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The rendered subtitle for the shared generic template element. Optional.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *subtitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The image url that will be downloaded and rendered at the top of the generic template. Optional.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *imageURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default action executed when this shared generic tempate is tapped. Title for this button is ignored. Optional.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> defaultAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This specifies what action button to show below the generic template. Optional.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> button;
|
||||||
|
|
||||||
|
@end
|
||||||
71
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateElement.m
generated
Normal file
71
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerGenericTemplateElement.m
generated
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareMessengerGenericTemplateElement.h"
|
||||||
|
|
||||||
|
static NSString *const kGenericTemplateTitleKey = @"title";
|
||||||
|
static NSString *const kGenericTemplateSubtitleKey = @"subtitle";
|
||||||
|
static NSString *const kGenericTemplateImageURLKey = @"imageURL";
|
||||||
|
static NSString *const kGenericTemplateDefaultActionKey = @"defaultAction";
|
||||||
|
static NSString *const kGenericTemplateButtonKey = @"button";
|
||||||
|
|
||||||
|
@implementation FBSDKShareMessengerGenericTemplateElement
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_title = [decoder decodeObjectOfClass:[NSString class] forKey:kGenericTemplateTitleKey];
|
||||||
|
_subtitle = [decoder decodeObjectOfClass:[NSString class] forKey:kGenericTemplateSubtitleKey];
|
||||||
|
_imageURL = [decoder decodeObjectOfClass:[NSURL class] forKey:kGenericTemplateImageURLKey];
|
||||||
|
_defaultAction = [decoder decodeObjectForKey:kGenericTemplateDefaultActionKey];
|
||||||
|
_button = [decoder decodeObjectForKey:kGenericTemplateButtonKey];
|
||||||
|
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_title forKey:kGenericTemplateTitleKey];
|
||||||
|
[encoder encodeObject:_subtitle forKey:kGenericTemplateSubtitleKey];
|
||||||
|
[encoder encodeObject:_imageURL forKey:kGenericTemplateImageURLKey];
|
||||||
|
[encoder encodeObject:_defaultAction forKey:kGenericTemplateDefaultActionKey];
|
||||||
|
[encoder encodeObject:_button forKey:kGenericTemplateButtonKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareMessengerGenericTemplateElement *copy = [[FBSDKShareMessengerGenericTemplateElement alloc] init];
|
||||||
|
copy->_title = [_title copy];
|
||||||
|
copy->_subtitle = [_subtitle copy];
|
||||||
|
copy->_imageURL = [_imageURL copy];
|
||||||
|
copy->_defaultAction = [_defaultAction copy];
|
||||||
|
copy->_button = [_button copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
69
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerMediaTemplateContent.h
generated
Normal file
69
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerMediaTemplateContent.h
generated
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKShareMessengerMediaTemplateMediaType) {
|
||||||
|
FBSDKShareMessengerMediaTemplateMediaTypeImage = 0,
|
||||||
|
FBSDKShareMessengerMediaTemplateMediaTypeVideo
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for sharing media template content. See
|
||||||
|
https://developers.facebook.com/docs/messenger-platform/send-messages/template/media for details.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareMessengerMediaTemplateContent : NSObject <FBSDKSharingContent>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The media type (image or video) for this content. This must match the media type specified in the
|
||||||
|
attachmentID/mediaURL to avoid an error when sharing. Defaults to image.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKShareMessengerMediaTemplateMediaType mediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The attachmentID of the item to share. Optional, but either attachmentID or mediaURL must be specified.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, readonly) NSString *attachmentID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The Facebook url for this piece of media. External urls will not work; this must be a Facebook url.
|
||||||
|
See https://developers.facebook.com/docs/messenger-platform/send-messages/template/media for details.
|
||||||
|
Optional, but either attachmentID or mediaURL must be specified.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy, readonly) NSURL *mediaURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This specifies what action button to show below the media. Optional.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> button;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Custom initializer to create media template share with attachment id.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithAttachmentID:(NSString *)attachmentID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Custom initializer to create media template share with media url. This must be a Facebook url
|
||||||
|
and cannot be an external url.
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithMediaURL:(NSURL *)mediaURL;
|
||||||
|
|
||||||
|
@end
|
||||||
216
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerMediaTemplateContent.m
generated
Normal file
216
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerMediaTemplateContent.m
generated
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareMessengerMediaTemplateContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKHashtag.h"
|
||||||
|
#import "FBSDKShareConstants.h"
|
||||||
|
#import "FBSDKShareMessengerContentUtility.h"
|
||||||
|
|
||||||
|
static NSString *const kMediaTemplatePageIDKey = @"pageID";
|
||||||
|
static NSString *const kMediaTemplateMediaTypeKey = @"mediaType";
|
||||||
|
static NSString *const kMediaTemplateAttachmentIDKey = @"attachmentID";
|
||||||
|
static NSString *const kMediaTemplateMediaURLKey = @"mediaURL";
|
||||||
|
static NSString *const kMediaTemplateButtonKey = @"button";
|
||||||
|
static NSString *const kMediaTemplateUUIDKey = @"uuid";
|
||||||
|
|
||||||
|
static BOOL _URLHasFacebookDomain(NSURL *URL)
|
||||||
|
{
|
||||||
|
NSString *urlHost = URL.host.lowercaseString;
|
||||||
|
NSArray<NSString *> *pathComponents = URL.pathComponents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check the following three different cases...
|
||||||
|
1. Check if host is facebook.com, such as in 'https://facebok.com/test'
|
||||||
|
2. Check if host is someprefix.facebook.com, such as in 'https://www.facebook.com/test'
|
||||||
|
3. Check if host is null, but the first path component is facebook.com
|
||||||
|
*/
|
||||||
|
return [urlHost isEqualToString:@"facebook.com"] ||
|
||||||
|
[urlHost hasSuffix:@".facebook.com"] ||
|
||||||
|
([pathComponents.firstObject.lowercaseString hasSuffix:@"facebook.com"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSString *_MediaTemplateURLSerializationKey(NSURL *mediaURL)
|
||||||
|
{
|
||||||
|
if (_URLHasFacebookDomain(mediaURL)) {
|
||||||
|
return @"facebook_media_url";
|
||||||
|
} else {
|
||||||
|
return @"image_url";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSString *_MediaTypeString(FBSDKShareMessengerMediaTemplateMediaType mediaType)
|
||||||
|
{
|
||||||
|
switch (mediaType) {
|
||||||
|
case FBSDKShareMessengerMediaTemplateMediaTypeImage:
|
||||||
|
return @"image";
|
||||||
|
case FBSDKShareMessengerMediaTemplateMediaTypeVideo:
|
||||||
|
return @"video";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray<NSDictionary<NSString *, id> *> *_SerializableMediaTemplateContentFromContent(FBSDKShareMessengerMediaTemplateContent *mediaTemplateContent)
|
||||||
|
{
|
||||||
|
NSMutableArray<NSDictionary<NSString *, id> *> *serializableMediaTemplateContent = [NSMutableArray array];
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *mediaTemplateContentDictionary = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:mediaTemplateContentDictionary setObject:_MediaTypeString(mediaTemplateContent.mediaType) forKey:@"media_type"];
|
||||||
|
[FBSDKInternalUtility dictionary:mediaTemplateContentDictionary setObject:mediaTemplateContent.mediaURL.absoluteString forKey:@"url"];
|
||||||
|
[FBSDKInternalUtility dictionary:mediaTemplateContentDictionary setObject:mediaTemplateContent.attachmentID forKey:@"attachment_id"];
|
||||||
|
[FBSDKInternalUtility dictionary:mediaTemplateContentDictionary setObject:SerializableButtonsFromButton(mediaTemplateContent.button) forKey:kFBSDKShareMessengerButtonsKey];
|
||||||
|
[serializableMediaTemplateContent addObject:mediaTemplateContentDictionary];
|
||||||
|
|
||||||
|
return serializableMediaTemplateContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation FBSDKShareMessengerMediaTemplateContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize contentURL = _contentURL;
|
||||||
|
@synthesize hashtag = _hashtag;
|
||||||
|
@synthesize peopleIDs = _peopleIDs;
|
||||||
|
@synthesize placeID = _placeID;
|
||||||
|
@synthesize ref = _ref;
|
||||||
|
@synthesize pageID = _pageID;
|
||||||
|
@synthesize shareUUID = _shareUUID;
|
||||||
|
|
||||||
|
#pragma mark - Initializer
|
||||||
|
|
||||||
|
- (instancetype)initWithAttachmentID:(NSString *)attachmentID
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_attachmentID = [attachmentID copy];
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithMediaURL:(NSURL *)mediaURL
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_mediaURL = [mediaURL copy];
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingContent
|
||||||
|
|
||||||
|
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
[parameters addEntriesFromDictionary:[self addParameters:parameters bridgeOptions:bridgeOptions]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, id> *updatedParameters = [NSMutableDictionary dictionaryWithDictionary:existingParameters];
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *payload = [NSMutableDictionary dictionary];
|
||||||
|
payload[kFBSDKShareMessengerTemplateTypeKey] = @"media";
|
||||||
|
payload[kFBSDKShareMessengerElementsKey] = _SerializableMediaTemplateContentFromContent(self);
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *attachment = [NSMutableDictionary dictionary];
|
||||||
|
attachment[kFBSDKShareMessengerTypeKey] = kFBSDKShareMessengerTemplateKey;
|
||||||
|
attachment[kFBSDKShareMessengerPayloadKey] = payload;
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *contentForShare = [NSMutableDictionary dictionary];
|
||||||
|
contentForShare[kFBSDKShareMessengerAttachmentKey] = attachment;
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *contentForPreview = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:@"DEFAULT" forKey:@"preview_type"];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:_attachmentID forKey:@"attachment_id"];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview
|
||||||
|
setObject:_mediaURL.absoluteString
|
||||||
|
forKey:_MediaTemplateURLSerializationKey(_mediaURL)];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:_MediaTypeString(_mediaType) forKey:@"media_type"];
|
||||||
|
AddToContentPreviewDictionaryForButton(contentForPreview, _button);
|
||||||
|
|
||||||
|
[FBSDKShareMessengerContentUtility addToParameters:updatedParameters contentForShare:contentForShare contentForPreview:contentForPreview];
|
||||||
|
|
||||||
|
return updatedParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
if (!_mediaURL && !_attachmentID) {
|
||||||
|
if (errorRef != NULL) {
|
||||||
|
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
|
||||||
|
name:@"attachmentID/mediaURL"
|
||||||
|
message:@"Must specify either attachmentID or mediaURL"];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [FBSDKShareMessengerContentUtility validateMessengerActionButton:_button
|
||||||
|
isDefaultActionButton:NO
|
||||||
|
pageID:_pageID
|
||||||
|
error:errorRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:kMediaTemplatePageIDKey];
|
||||||
|
_mediaType = [[decoder decodeObjectForKey:kMediaTemplateMediaTypeKey] unsignedIntegerValue];
|
||||||
|
_attachmentID = [decoder decodeObjectOfClass:[NSString class] forKey:kMediaTemplateAttachmentIDKey];
|
||||||
|
_mediaURL = [decoder decodeObjectOfClass:[NSURL class] forKey:kMediaTemplateMediaURLKey];
|
||||||
|
_button = [decoder decodeObjectForKey:kMediaTemplateButtonKey];
|
||||||
|
_shareUUID = [decoder decodeObjectOfClass:[NSString class] forKey:kMediaTemplateUUIDKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_pageID forKey:kMediaTemplatePageIDKey];
|
||||||
|
[encoder encodeObject:@(_mediaType) forKey:kMediaTemplateMediaTypeKey];
|
||||||
|
[encoder encodeObject:_attachmentID forKey:kMediaTemplateAttachmentIDKey];
|
||||||
|
[encoder encodeObject:_mediaURL forKey:kMediaTemplateMediaURLKey];
|
||||||
|
[encoder encodeObject:_button forKey:kMediaTemplateButtonKey];
|
||||||
|
[encoder encodeObject:_shareUUID forKey:kMediaTemplateUUIDKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareMessengerMediaTemplateContent *copy = [[FBSDKShareMessengerMediaTemplateContent alloc] init];
|
||||||
|
copy->_pageID = [_pageID copy];
|
||||||
|
copy->_mediaType = _mediaType;
|
||||||
|
copy->_attachmentID = [_attachmentID copy];
|
||||||
|
copy->_mediaURL = [_mediaURL copy];
|
||||||
|
copy->_button = [_button copy];
|
||||||
|
copy->_shareUUID = [_shareUUID copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKSharingContent.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
This share content allows sharing a bubble that plays songs with Open Graph music.
|
||||||
|
See https://developers.facebook.com/docs/messenger-platform/send-messages/template/open-graph
|
||||||
|
for details. Passing <FBSDKSharingContent> property pageID is required for this type of share.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareMessengerOpenGraphMusicTemplateContent : NSObject <FBSDKSharingContent>
|
||||||
|
|
||||||
|
/**
|
||||||
|
This must be an Open Graph music url. Required.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This specifies what action button to show below the open graph music bubble. Optional.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> button;
|
||||||
|
|
||||||
|
@end
|
||||||
@ -0,0 +1,149 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareMessengerOpenGraphMusicTemplateContent.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareMessengerContentUtility.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
static NSString *const kMusicTemplatePageIDKey = @"pageID";
|
||||||
|
static NSString *const kMusicTemplateURLKey = @"url";
|
||||||
|
static NSString *const kMusicTemplateButtonKey = @"button";
|
||||||
|
static NSString *const kMusicTemplateUUIDKey = @"uuid";
|
||||||
|
|
||||||
|
static NSArray<NSDictionary<NSString *, id> *> *_SerializableOpenGraphMusicTemplateContentFromContent(FBSDKShareMessengerOpenGraphMusicTemplateContent *openGraphMusicTemplateContent)
|
||||||
|
{
|
||||||
|
NSMutableArray<NSDictionary<NSString *, id> *> *serializableOpenGraphMusicTemplateContent = [NSMutableArray array];
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *openGraphMusicTemplateContentDictionary = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:openGraphMusicTemplateContentDictionary setObject:openGraphMusicTemplateContent.url.absoluteString forKey:@"url"];
|
||||||
|
[FBSDKInternalUtility dictionary:openGraphMusicTemplateContentDictionary setObject:SerializableButtonsFromButton(openGraphMusicTemplateContent.button) forKey:kFBSDKShareMessengerButtonsKey];
|
||||||
|
[serializableOpenGraphMusicTemplateContent addObject:openGraphMusicTemplateContentDictionary];
|
||||||
|
|
||||||
|
return serializableOpenGraphMusicTemplateContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation FBSDKShareMessengerOpenGraphMusicTemplateContent
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize contentURL = _contentURL;
|
||||||
|
@synthesize hashtag = _hashtag;
|
||||||
|
@synthesize peopleIDs = _peopleIDs;
|
||||||
|
@synthesize placeID = _placeID;
|
||||||
|
@synthesize ref = _ref;
|
||||||
|
@synthesize pageID = _pageID;
|
||||||
|
@synthesize shareUUID = _shareUUID;
|
||||||
|
|
||||||
|
#pragma mark - Initializer
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
_shareUUID = [NSUUID UUID].UUIDString;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingContent
|
||||||
|
|
||||||
|
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
[parameters addEntriesFromDictionary:[self addParameters:parameters bridgeOptions:bridgeOptions]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
|
||||||
|
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
|
||||||
|
{
|
||||||
|
NSMutableDictionary<NSString *, id> *updatedParameters = [NSMutableDictionary dictionaryWithDictionary:existingParameters];
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *payload = [NSMutableDictionary dictionary];
|
||||||
|
payload[kFBSDKShareMessengerTemplateTypeKey] = @"open_graph";
|
||||||
|
payload[kFBSDKShareMessengerElementsKey] = _SerializableOpenGraphMusicTemplateContentFromContent(self);
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *attachment = [NSMutableDictionary dictionary];
|
||||||
|
attachment[kFBSDKShareMessengerTypeKey] = kFBSDKShareMessengerTemplateKey;
|
||||||
|
attachment[kFBSDKShareMessengerPayloadKey] = payload;
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *contentForShare = [NSMutableDictionary dictionary];
|
||||||
|
contentForShare[kFBSDKShareMessengerAttachmentKey] = attachment;
|
||||||
|
|
||||||
|
NSMutableDictionary<NSString *, id> *contentForPreview = [NSMutableDictionary dictionary];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:@"OPEN_GRAPH" forKey:@"preview_type"];
|
||||||
|
[FBSDKInternalUtility dictionary:contentForPreview setObject:_url.absoluteString forKey:@"open_graph_url"];
|
||||||
|
AddToContentPreviewDictionaryForButton(contentForPreview, _button);
|
||||||
|
|
||||||
|
[FBSDKShareMessengerContentUtility addToParameters:updatedParameters contentForShare:contentForShare contentForPreview:contentForPreview];
|
||||||
|
|
||||||
|
return updatedParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - FBSDKSharingValidation
|
||||||
|
|
||||||
|
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef
|
||||||
|
{
|
||||||
|
return [FBSDKShareUtility validateRequiredValue:_url name:@"url" error:errorRef]
|
||||||
|
&& [FBSDKShareUtility validateRequiredValue:_pageID name:@"pageID" error:errorRef]
|
||||||
|
&& [FBSDKShareMessengerContentUtility validateMessengerActionButton:_button
|
||||||
|
isDefaultActionButton:NO
|
||||||
|
pageID:_pageID
|
||||||
|
error:errorRef];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:kMusicTemplatePageIDKey];
|
||||||
|
_url = [decoder decodeObjectOfClass:[NSURL class] forKey:kMusicTemplateURLKey];
|
||||||
|
_button = [decoder decodeObjectForKey:kMusicTemplateButtonKey];
|
||||||
|
_shareUUID = [decoder decodeObjectOfClass:[NSString class] forKey:kMusicTemplateUUIDKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_pageID forKey:kMusicTemplatePageIDKey];
|
||||||
|
[encoder encodeObject:_url forKey:kMusicTemplateURLKey];
|
||||||
|
[encoder encodeObject:_button forKey:kMusicTemplateButtonKey];
|
||||||
|
[encoder encodeObject:_shareUUID forKey:kMusicTemplateUUIDKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareMessengerOpenGraphMusicTemplateContent *copy = [[FBSDKShareMessengerOpenGraphMusicTemplateContent alloc] init];
|
||||||
|
copy->_pageID = [_pageID copy];
|
||||||
|
copy->_url = [_url copy];
|
||||||
|
copy->_button = [_button copy];
|
||||||
|
copy->_shareUUID = [_shareUUID copy];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
62
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerURLActionButton.h
generated
Normal file
62
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerURLActionButton.h
generated
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, FBSDKShareMessengerURLActionButtonWebviewHeightRatio) {
|
||||||
|
FBSDKShareMessengerURLActionButtonWebviewHeightRatioFull = 0,
|
||||||
|
FBSDKShareMessengerURLActionButtonWebviewHeightRatioTall,
|
||||||
|
FBSDKShareMessengerURLActionButtonWebviewHeightRatioCompact
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A model for a Messenger share URL action button.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareMessengerURLActionButton : NSObject <FBSDKShareMessengerActionButton>
|
||||||
|
|
||||||
|
/**
|
||||||
|
The url that this button should open when tapped. Required.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This controls the display height of the webview when shown in the Messenger app. Defaults to Full.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) FBSDKShareMessengerURLActionButtonWebviewHeightRatio webviewHeightRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This must be true if the url is a Messenger Extensions url. Defaults to NO.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL isMessengerExtensionURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is a fallback url for a Messenger Extensions enabled button. It is used on clients that do not support
|
||||||
|
Messenger Extensions. If this is not defined, the url will be used as a fallback. Optional, but ignored
|
||||||
|
unless isMessengerExtensionURL == YES.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSURL *fallbackURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This controls whether we want to hide the share button in the webview or not. It is useful to hide the share
|
||||||
|
button when the webview is user-specific and contains sensitive information. Defaults to NO.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) BOOL shouldHideWebviewShareButton;
|
||||||
|
|
||||||
|
@end
|
||||||
82
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerURLActionButton.m
generated
Normal file
82
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareMessengerURLActionButton.m
generated
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareMessengerURLActionButton.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareUtility.h"
|
||||||
|
|
||||||
|
static NSString *const kURLActionButtonTitleKey = @"title";
|
||||||
|
static NSString *const kURLActionButtonURLKey = @"url";
|
||||||
|
static NSString *const kURLActionButtonWebviewHeightRatioKey = @"webviewHeightRatio";
|
||||||
|
static NSString *const kURLActionButtonMessengerExtensionsKey = @"messengerExtensions";
|
||||||
|
static NSString *const kURLActionButtonFallbackURLKey = @"fallbackURL";
|
||||||
|
static NSString *const kURLActionButtonShouldHideWebviewShareButtonKey = @"shouldHideWebviewShareButton";
|
||||||
|
|
||||||
|
@implementation FBSDKShareMessengerURLActionButton
|
||||||
|
|
||||||
|
#pragma mark - Properties
|
||||||
|
|
||||||
|
@synthesize title = _title;
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [self init])) {
|
||||||
|
_title = [decoder decodeObjectOfClass:[NSString class] forKey:kURLActionButtonTitleKey];
|
||||||
|
_url = [decoder decodeObjectOfClass:[NSURL class] forKey:kURLActionButtonURLKey];
|
||||||
|
_webviewHeightRatio = [[decoder decodeObjectOfClass:[NSNumber class] forKey:kURLActionButtonWebviewHeightRatioKey] unsignedIntegerValue];
|
||||||
|
_isMessengerExtensionURL = [decoder decodeBoolForKey:kURLActionButtonMessengerExtensionsKey];
|
||||||
|
_fallbackURL = [decoder decodeObjectOfClass:[NSURL class] forKey:kURLActionButtonFallbackURLKey];
|
||||||
|
_shouldHideWebviewShareButton = [decoder decodeBoolForKey:kURLActionButtonShouldHideWebviewShareButtonKey];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[encoder encodeObject:_title forKey:kURLActionButtonTitleKey];
|
||||||
|
[encoder encodeObject:_url forKey:kURLActionButtonURLKey];
|
||||||
|
[encoder encodeObject:@(_webviewHeightRatio) forKey:kURLActionButtonWebviewHeightRatioKey];
|
||||||
|
[encoder encodeBool:_isMessengerExtensionURL forKey:kURLActionButtonMessengerExtensionsKey];
|
||||||
|
[encoder encodeObject:_fallbackURL forKey:kURLActionButtonFallbackURLKey];
|
||||||
|
[encoder encodeBool:_shouldHideWebviewShareButton forKey:kURLActionButtonShouldHideWebviewShareButtonKey];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareMessengerURLActionButton *copy = [[FBSDKShareMessengerURLActionButton alloc] init];
|
||||||
|
copy->_title = [_title copy];
|
||||||
|
copy->_url = [_url copy];
|
||||||
|
copy->_webviewHeightRatio = _webviewHeightRatio;
|
||||||
|
copy->_isMessengerExtensionURL = _isMessengerExtensionURL;
|
||||||
|
copy->_fallbackURL = [_fallbackURL copy];
|
||||||
|
copy->_shouldHideWebviewShareButton = _shouldHideWebviewShareButton;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
70
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareOpenGraphAction.h
generated
Normal file
70
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareOpenGraphAction.h
generated
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import <FBSDKCoreKit/FBSDKCopying.h>
|
||||||
|
|
||||||
|
#import <FBSDKShareKit/FBSDKShareOpenGraphObject.h>
|
||||||
|
#import <FBSDKShareKit/FBSDKShareOpenGraphValueContainer.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
An Open Graph Action for sharing.
|
||||||
|
|
||||||
|
The property keys MUST have namespaces specified on them, such as `og:image`.
|
||||||
|
*/
|
||||||
|
@interface FBSDKShareOpenGraphAction : FBSDKShareOpenGraphValueContainer <FBSDKCopying, NSSecureCoding>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to build a new action and set the object for the specified key.
|
||||||
|
@param actionType The action type of the receiver
|
||||||
|
@param object The Open Graph object represented by this action
|
||||||
|
@param key The key for the object
|
||||||
|
*/
|
||||||
|
+ (instancetype)actionWithType:(NSString *)actionType object:(FBSDKShareOpenGraphObject *)object key:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to build a new action and set the object for the specified key.
|
||||||
|
@param actionType The action type of the receiver
|
||||||
|
@param objectID The ID of an existing Open Graph object
|
||||||
|
@param key The key for the object
|
||||||
|
*/
|
||||||
|
+ (instancetype)actionWithType:(NSString *)actionType objectID:(NSString *)objectID key:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convenience method to build a new action and set the object for the specified key.
|
||||||
|
@param actionType The action type of the receiver
|
||||||
|
@param objectURL The URL to a page that defines the Open Graph object with meta tags
|
||||||
|
@param key The key for the object
|
||||||
|
*/
|
||||||
|
+ (instancetype)actionWithType:(NSString *)actionType objectURL:(NSURL *)objectURL key:(NSString *)key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the action type.
|
||||||
|
@return The action type
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *actionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compares the receiver to another Open Graph Action.
|
||||||
|
@param action The other action
|
||||||
|
@return YES if the receiver's values are equal to the other action's values; otherwise NO
|
||||||
|
*/
|
||||||
|
- (BOOL)isEqualToShareOpenGraphAction:(FBSDKShareOpenGraphAction *)action;
|
||||||
|
|
||||||
|
@end
|
||||||
117
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareOpenGraphAction.m
generated
Normal file
117
Example/Pods/FBSDKShareKit/FBSDKShareKit/FBSDKShareKit/FBSDKShareOpenGraphAction.m
generated
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
|
||||||
|
// copy, modify, and distribute this software in source code or binary form for use
|
||||||
|
// in connection with the web services and APIs provided by Facebook.
|
||||||
|
//
|
||||||
|
// As with any software that integrates with the Facebook platform, your use of
|
||||||
|
// this software is subject to the Facebook Developer Principles and Policies
|
||||||
|
// [http://developers.facebook.com/policy/]. This copyright notice shall be
|
||||||
|
// included in all copies or substantial portions of the software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "FBSDKShareOpenGraphAction.h"
|
||||||
|
|
||||||
|
#import "FBSDKCoreKit+Internal.h"
|
||||||
|
#import "FBSDKShareOpenGraphValueContainer+Internal.h"
|
||||||
|
|
||||||
|
#define FBSDK_SHARE_OPEN_GRAPH_ACTION_TYPE_KEY @"type"
|
||||||
|
|
||||||
|
@implementation FBSDKShareOpenGraphAction
|
||||||
|
|
||||||
|
#pragma mark - Class Methods
|
||||||
|
|
||||||
|
+ (instancetype)actionWithType:(NSString *)actionType object:(FBSDKShareOpenGraphObject *)object key:(NSString *)key
|
||||||
|
{
|
||||||
|
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
|
||||||
|
action.actionType = actionType;
|
||||||
|
[action setObject:object forKey:key];
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)actionWithType:(NSString *)actionType objectID:(NSString *)objectID key:(NSString *)key
|
||||||
|
{
|
||||||
|
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
|
||||||
|
action.actionType = actionType;
|
||||||
|
[action setString:objectID forKey:key];
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)actionWithType:(NSString *)actionType objectURL:(NSURL *)objectURL key:(NSString *)key
|
||||||
|
{
|
||||||
|
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
|
||||||
|
action.actionType = actionType;
|
||||||
|
[action setURL:objectURL forKey:key];
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Equality
|
||||||
|
|
||||||
|
- (NSUInteger)hash
|
||||||
|
{
|
||||||
|
return [FBSDKMath hashWithInteger:super.hash andInteger:_actionType.hash];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqual:(id)object
|
||||||
|
{
|
||||||
|
if (self == object) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if (![object isKindOfClass:[FBSDKShareOpenGraphAction class]]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [self isEqualToShareOpenGraphAction:(FBSDKShareOpenGraphAction *)object];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToShareOpenGraphAction:(FBSDKShareOpenGraphAction *)action
|
||||||
|
{
|
||||||
|
return (action &&
|
||||||
|
[FBSDKInternalUtility object:_actionType isEqualToObject:action.actionType] &&
|
||||||
|
[self isEqualToShareOpenGraphValueContainer:action]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
if ((self = [super initWithCoder:decoder])) {
|
||||||
|
_actionType = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_OPEN_GRAPH_ACTION_TYPE_KEY];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||||
|
{
|
||||||
|
[super encodeWithCoder:encoder];
|
||||||
|
[encoder encodeObject:_actionType forKey:FBSDK_SHARE_OPEN_GRAPH_ACTION_TYPE_KEY];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSCopying
|
||||||
|
|
||||||
|
- (id)copyWithZone:(NSZone *)zone
|
||||||
|
{
|
||||||
|
FBSDKShareOpenGraphAction *copy = [[FBSDKShareOpenGraphAction alloc] init];
|
||||||
|
copy->_actionType = [_actionType copy];
|
||||||
|
[copy parseProperties:[self allProperties]];
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Internal Methods
|
||||||
|
|
||||||
|
- (BOOL)requireKeyNamespace
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user