- Upgrade Libraries

This commit is contained in:
giuseppenuc committed 2019-10-23 01:07:16 +02:00
1 parent 060efc0c83
commit f84e3ef366
535 files changed
+14099 -19527

No files matched your search

@@ -1,100 +0,0 @@
// 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
@@ -1,191 +0,0 @@
// 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
@@ -20,6 +20,8 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
NS_ASSUME_NONNULL_BEGIN
/**
NS_ENUM(NSUInteger, FBSDKAppGroupPrivacy)
Specifies the privacy of a group.
@@ -30,16 +32,18 @@ typedef NS_ENUM(NSUInteger, FBSDKAppGroupPrivacy)
FBSDKAppGroupPrivacyOpen = 0,
/** Anyone can see the group and who's in it, but only members can see posts. */
FBSDKAppGroupPrivacyClosed,
};
} NS_SWIFT_NAME(AppGroupPrivacy);
/**
Converts an FBSDKAppGroupPrivacy to an NSString.
*/
FOUNDATION_EXPORT NSString *NSStringFromFBSDKAppGroupPrivacy(FBSDKAppGroupPrivacy privacy);
FOUNDATION_EXPORT NSString *NSStringFromFBSDKAppGroupPrivacy(FBSDKAppGroupPrivacy privacy)
NS_REFINED_FOR_SWIFT;
/**
A model for creating an app group.
*/
NS_SWIFT_NAME(AppGroupContent)
@interface FBSDKAppGroupContent : NSObject <FBSDKCopying, NSSecureCoding>
/**
@@ -65,3 +69,5 @@ FOUNDATION_EXPORT NSString *NSStringFromFBSDKAppGroupPrivacy(FBSDKAppGroupPrivac
- (BOOL)isEqualToAppGroupContent:(FBSDKAppGroupContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKAppGroupContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareUtility.h"
#define FBSDK_APP_GROUP_CONTENT_GROUP_DESCRIPTION_KEY @"groupDescription"
@@ -1,92 +0,0 @@
// 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
@@ -1,169 +0,0 @@
// 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
@@ -21,6 +21,8 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKSharingValidation.h>
NS_ASSUME_NONNULL_BEGIN
/**
NS_ENUM(NSUInteger, FBSDKAppInviteDestination)
Specifies the privacy of a group.
@@ -31,11 +33,12 @@ typedef NS_ENUM(NSUInteger, FBSDKAppInviteDestination)
FBSDKAppInviteDestinationFacebook = 0,
/** Deliver to Messenger. */
FBSDKAppInviteDestinationMessenger,
};
} NS_SWIFT_NAME(AppInviteDestination);
/**
A model for app invite.
*/
NS_SWIFT_NAME(AppInviteContent)
@interface FBSDKAppInviteContent : NSObject <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
/**
@@ -44,7 +47,7 @@ typedef NS_ENUM(NSUInteger, FBSDKAppInviteDestination)
This is optional. If you don't include it a fallback image will be used.
*/
@property (nonatomic, copy) NSURL *appInvitePreviewImageURL;
@property (nonatomic, copy, nullable) NSURL *appInvitePreviewImageURL;
/**
An app link target that will be used as a target when the user accept the invite.
@@ -54,13 +57,6 @@ typedef NS_ENUM(NSUInteger, FBSDKAppInviteDestination)
*/
@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.
@@ -68,7 +64,7 @@ DEPRECATED_MSG_ATTRIBUTE("use appInvitePreviewImageURL instead");
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;
@property (nonatomic, copy, nullable) NSString *promotionCode;
/**
Promotional text to be displayed while sending and receiving the invite.
@@ -77,7 +73,7 @@ DEPRECATED_MSG_ATTRIBUTE("use appInvitePreviewImageURL instead");
This is optional. This can be between 0 and 80 characters long and can contain
alphanumeric and spaces only.
*/
@property (nonatomic, copy) NSString *promotionText;
@property (nonatomic, copy, nullable) NSString *promotionText;
/**
Destination for the app invite.
@@ -85,7 +81,7 @@ DEPRECATED_MSG_ATTRIBUTE("use appInvitePreviewImageURL instead");
This is optional and for declaring destination of the invite.
*/
@property FBSDKAppInviteDestination destination;
@property (nonatomic, assign) FBSDKAppInviteDestination destination;
/**
Compares the receiver to another app invite content.
@@ -95,3 +91,5 @@ DEPRECATED_MSG_ATTRIBUTE("use appInvitePreviewImageURL instead");
- (BOOL)isEqualToAppInviteContent:(FBSDKAppInviteContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKAppInviteContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareUtility.h"
#define FBSDK_APP_INVITE_CONTENT_APP_LINK_URL_KEY @"appLinkURL"
@@ -59,28 +63,28 @@
// 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."];
*errorRef = [FBSDKError invalidArgumentErrorWithName:@"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."];
*errorRef = [FBSDKError invalidArgumentErrorWithName:@"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."];
*errorRef = [FBSDKError invalidArgumentErrorWithName:@"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."];
*errorRef = [FBSDKError invalidArgumentErrorWithName:@"promotionCode" value:_promotionCode message:@"Invalid value for promotionCode, promotionCode can contain only alphanumeric characters and spaces."];
}
return NO;
}
@@ -158,7 +162,7 @@
[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];
[encoder encodeInt:(int)_destination forKey:FBSDK_APP_INVITE_CONTENT_DESTINATION_KEY];
}
#pragma mark - NSCopying
@@ -1,118 +0,0 @@
// 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
@@ -1,85 +0,0 @@
// 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
@@ -20,10 +20,13 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
NS_ASSUME_NONNULL_BEGIN
/**
* A container of arguments for a camera effect.
* An argument is a NSString identified by a NSString key.
*/
NS_SWIFT_NAME(CameraEffectArguments)
@interface FBSDKCameraEffectArguments : NSObject <FBSDKCopying, NSSecureCoding>
/**
@@ -31,27 +34,31 @@
@param string The argument
@param key The key for the argument
*/
- (void)setString:(NSString *)string forKey:(NSString *)key;
- (void)setString:(nullable NSString *)string forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Gets a string argument from the container.
@param key The key for the argument
@return The string value or nil
*/
- (NSString *)stringForKey:(NSString *)key;
- (nullable 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;
- (void)setArray:(nullable NSArray<NSString *> *)array forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Gets an array argument from the container.
@param key The key for the argument
@return The array argument
*/
- (NSArray *)arrayForKey:(NSString *)key;
- (nullable NSArray<NSString *> *)arrayForKey:(NSString *)key;
@end
NS_ASSUME_NONNULL_END
@@ -18,14 +18,18 @@
#import "FBSDKCameraEffectArguments.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareUtility.h"
static NSString *const FBSDKCameraEffectArgumentsArgumentsKey = @"arguments";
@implementation FBSDKCameraEffectArguments
{
NSMutableDictionary *_arguments;
NSMutableDictionary<NSString *, id> *_arguments;
}
#pragma mark - Object Lifecycle
@@ -53,12 +57,12 @@ static NSString *const FBSDKCameraEffectArgumentsArgumentsKey = @"arguments";
[self _setValue:[array copy] forKey:key];
}
- (NSArray *)arrayForKey:(NSString *)key
- (NSArray<NSString *> *)arrayForKey:(NSString *)key
{
return [self _valueOfClass:[NSArray class] forKey:key];
}
- (NSDictionary *)allArguments
- (NSDictionary<NSString *, id> *)allArguments;
{
return _arguments;
}
@@ -20,10 +20,13 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
NS_ASSUME_NONNULL_BEGIN
/**
* A container of textures for a camera effect.
* A texture for a camera effect is an UIImages identified by a NSString key.
*/
NS_SWIFT_NAME(CameraEffectTextures)
@interface FBSDKCameraEffectTextures : NSObject <FBSDKCopying, NSSecureCoding>
/**
@@ -31,13 +34,16 @@
@param image The UIImage for the texture
@param key The key for the texture
*/
- (void)setImage:(UIImage *)image forKey:(NSString *)key;
- (void)setImage:(nullable UIImage *)image forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Gets the image for a texture key.
@param key The key for the texture
@return The texture UIImage or nil
*/
- (UIImage *)imageForKey:(NSString *)key;
- (nullable UIImage *)imageForKey:(NSString *)key;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKCameraEffectTextures.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareUtility.h"
static NSString *const FBSDKCameraEffectTexturesTexturesKey = @"textures";
@@ -21,6 +21,8 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKSharingValidation.h>
NS_ASSUME_NONNULL_BEGIN
/**
NS_ENUM(NSUInteger, FBSDKGameRequestActionType)
Additional context about the nature of the request.
@@ -35,7 +37,7 @@ typedef NS_ENUM(NSUInteger, FBSDKGameRequestActionType)
FBSDKGameRequestActionTypeAskFor,
/** Turn action type: It is the turn of the friends to play against the user in a match. (no object) */
FBSDKGameRequestActionTypeTurn,
};
} NS_SWIFT_NAME(GameRequestActionType);
/**
NS_ENUM(NSUInteger, FBSDKGameRequestFilters)
@@ -49,11 +51,12 @@ typedef NS_ENUM(NSUInteger, FBSDKGameRequestFilter)
FBSDKGameRequestFilterAppUsers,
/** Friends not using the app can be displayed. */
FBSDKGameRequestFilterAppNonUsers,
};
} NS_SWIFT_NAME(GameRequestFilter);
/**
A model for a game request.
*/
NS_SWIFT_NAME(GameRequestContent)
@interface FBSDKGameRequestContent : NSObject <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
/**
@@ -77,7 +80,7 @@ typedef NS_ENUM(NSUInteger, FBSDKGameRequestFilter)
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;
@property (nonatomic, copy, nullable) NSString *data;
/**
This controls the set of friends someone sees if a multi-friend selector is shown.
@@ -110,7 +113,7 @@ typedef NS_ENUM(NSUInteger, FBSDKGameRequestFilter)
This is equivalent to the "to" parameter when using the web game request dialog.
*/
@property (nonatomic, copy) NSArray *recipients;
@property (nonatomic, copy) NSArray<NSString *> *recipients;
/**
An array of user IDs that will be included in the dialog as the first suggested friends.
@@ -118,25 +121,13 @@ typedef NS_ENUM(NSUInteger, FBSDKGameRequestFilter)
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");
@property (nonatomic, copy) NSArray<NSString *> *recipientSuggestions;
/**
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
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKGameRequestContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareConstants.h"
#import "FBSDKShareUtility.h"
@@ -84,9 +88,9 @@
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];
*errorRef = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"objectID"
message:message];
}
return NO;
}
@@ -96,20 +100,20 @@
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];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain: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];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"recipients"
value:_recipients
message:message];
}
return NO;
}
@@ -117,10 +121,10 @@
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];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"recipientSuggestions"
value:_recipientSuggestions
message:message];
}
return NO;
}
@@ -128,10 +132,10 @@
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];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"data"
value:_data
message:message];
}
return NO;
}
@@ -20,24 +20,42 @@
#import <FBSDKShareKit/FBSDKGameRequestContent.h>
NS_ASSUME_NONNULL_BEGIN
@protocol FBSDKGameRequestDialogDelegate;
/**
A dialog for sending game requests.
*/
NS_SWIFT_NAME(GameRequestDialog)
@interface FBSDKGameRequestDialog : NSObject
- (instancetype)init NS_DESIGNATED_INITIALIZER
NS_SWIFT_UNAVAILABLE("Use init(content:delegate:) instead");
+ (instancetype)new NS_UNAVAILABLE;
/**
Convenience method to build up a game request with content and a delegate.
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;
+ (instancetype)dialogWithContent:(FBSDKGameRequestContent *)content
delegate:(nullable id<FBSDKGameRequestDialogDelegate>)delegate
NS_SWIFT_NAME(init(content:delegate:));
/**
Convenience method to build up and show 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:(nullable id<FBSDKGameRequestDialogDelegate>)delegate
NS_SWIFT_UNAVAILABLE("Use init(content:delegate:).show() instead");
/**
The receiver's delegate or nil if it doesn't have a delegate.
*/
@property (nonatomic, weak) id<FBSDKGameRequestDialogDelegate> delegate;
@property (nonatomic, weak, nullable) id<FBSDKGameRequestDialogDelegate> delegate;
/**
The content for game request.
@@ -47,7 +65,7 @@
/**
Specifies whether frictionless requests are enabled.
*/
@property (nonatomic, assign) BOOL frictionlessRequestsEnabled;
@property (nonatomic, assign, getter=isFrictionlessRequestsEnabled) BOOL frictionlessRequestsEnabled;
/**
A Boolean value that indicates whether the receiver can initiate a game request.
@@ -83,6 +101,7 @@
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.
*/
NS_SWIFT_NAME(GameRequestDialogDelegate)
@protocol FBSDKGameRequestDialogDelegate <NSObject>
/**
@@ -90,7 +109,7 @@
@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;
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didCompleteWithResults:(NSDictionary<NSString *, id> *)results;
/**
Sent to the delegate when the game request encounters an error.
@@ -106,3 +125,5 @@
- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKGameRequestDialog.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKGameRequestFrictionlessRecipientCache.h"
#import "FBSDKShareConstants.h"
#import "FBSDKShareUtility.h"
@@ -45,11 +49,17 @@ static FBSDKGameRequestFrictionlessRecipientCache *_recipientCache = nil;
}
}
+ (instancetype)showWithContent:(FBSDKGameRequestContent *)content delegate:(id<FBSDKGameRequestDialogDelegate>)delegate
+ (instancetype)dialogWithContent:(FBSDKGameRequestContent *)content delegate:(id<FBSDKGameRequestDialogDelegate>)delegate
{
FBSDKGameRequestDialog *dialog = [[self alloc] init];
dialog.content = content;
dialog.delegate = delegate;
return dialog;
}
+ (instancetype)showWithContent:(FBSDKGameRequestContent *)content delegate:(id<FBSDKGameRequestDialogDelegate>)delegate
{
FBSDKGameRequestDialog *dialog = [self dialogWithContent:content delegate:delegate];
[dialog show];
return dialog;
}
@@ -82,9 +92,9 @@ static FBSDKGameRequestFrictionlessRecipientCache *_recipientCache = nil;
{
NSError *error;
if (!self.canShow) {
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Game request dialog is not available."];
error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Game request dialog is not available."];
[_delegate gameRequestDialog:self didFailWithError:error];
return NO;
}
@@ -100,14 +110,14 @@ static FBSDKGameRequestFrictionlessRecipientCache *_recipientCache = nil;
}
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"];
[FBSDKBasicUtility dictionary:parameters setObject:[content.recipients componentsJoinedByString:@","] forKey:@"to"];
[FBSDKBasicUtility dictionary:parameters setObject:content.message forKey:@"message"];
[FBSDKBasicUtility dictionary:parameters setObject:[self _actionTypeNameForActionType:content.actionType] forKey:@"action_type"];
[FBSDKBasicUtility dictionary:parameters setObject:content.objectID forKey:@"object_id"];
[FBSDKBasicUtility dictionary:parameters setObject:[self _filtersNameForFilters:content.filters] forKey:@"filters"];
[FBSDKBasicUtility dictionary:parameters setObject:[content.recipientSuggestions componentsJoinedByString:@","] forKey:@"suggestions"];
[FBSDKBasicUtility dictionary:parameters setObject:content.data forKey:@"data"];
[FBSDKBasicUtility 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
@@ -139,10 +149,10 @@ static FBSDKGameRequestFrictionlessRecipientCache *_recipientCache = nil;
return [self.content validateWithOptions:FBSDKShareBridgeOptionsDefault error:errorRef];
}
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"content"
value:self.content
message:nil];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"content"
value:self.content
message:nil];
}
return NO;
}
@@ -159,7 +169,7 @@ static FBSDKGameRequestFrictionlessRecipientCache *_recipientCache = nil;
}
[self _cleanUp];
NSError *error = [NSError fbErrorWithCode:[FBSDKTypeUtility unsignedIntegerValue:results[@"error_code"]]
NSError *error = [FBSDKError errorWithCode:[FBSDKTypeUtility unsignedIntegerValue:results[@"error_code"]]
message:[FBSDKTypeUtility stringValue:results[@"error_message"]]];
if (!error.code) {
// reformat "to[x]" keys into an array.
@@ -20,9 +20,12 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
NS_ASSUME_NONNULL_BEGIN
/**
Represents a single hashtag that can be used with the share dialog.
*/
NS_SWIFT_NAME(Hashtag)
@interface FBSDKHashtag : NSObject <FBSDKCopying, NSSecureCoding>
/**
@@ -30,7 +33,8 @@
`stringRepresentation` property.
@param hashtagString The hashtag string.
*/
+ (instancetype)hashtagWithString:(NSString *)hashtagString;
+ (instancetype)hashtagWithString:(NSString *)hashtagString
NS_SWIFT_NAME(init(_:));
/**
The hashtag string.
@@ -59,3 +63,5 @@
- (BOOL)isEqualToHashtag:(FBSDKHashtag *)hashtag;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKHashtag.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#define FBSDK_HASHTAG_STRING_KEY @"hashtag"
@@ -1,45 +0,0 @@
// 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
@@ -1,294 +0,0 @@
// 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
@@ -1,142 +0,0 @@
// 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
@@ -1,664 +0,0 @@
// 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
@@ -18,6 +18,8 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
NS_ENUM (NSUInteger, FBSDKLikeObjectType)
Specifies the type of object referenced by the objectID for likes.
@@ -30,9 +32,12 @@ typedef NS_ENUM(NSUInteger, FBSDKLikeObjectType)
FBSDKLikeObjectTypeOpenGraph,
/** The objectID refers to an Page object. */
FBSDKLikeObjectTypePage,
};
} NS_SWIFT_NAME(LikeObjectType);
/**
Converts an FBLikeControlObjectType to an NSString.
*/
FOUNDATION_EXPORT NSString *NSStringFromFBSDKLikeObjectType(FBSDKLikeObjectType objectType);
FOUNDATION_EXPORT NSString *NSStringFromFBSDKLikeObjectType(FBSDKLikeObjectType objectType)
NS_REFINED_FOR_SWIFT;
NS_ASSUME_NONNULL_END
@@ -18,6 +18,10 @@
#import <Foundation/Foundation.h>
#import "FBSDKLikeObjectType.h"
NS_ASSUME_NONNULL_BEGIN
/**
The common interface for components that initiate liking.
@@ -25,6 +29,7 @@
@see FBSDKLikeControl
*/
NS_SWIFT_NAME(Liking)
@protocol FBSDKLiking <NSObject>
/**
@@ -32,7 +37,7 @@
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.
Open Graph object. The objects may be public objects, like pages, or objects that are defined by your application.
*/
@property (nonatomic, copy) NSString *objectID;
@@ -47,3 +52,5 @@
@property (nonatomic, assign) FBSDKLikeObjectType objectType;
@end
NS_ASSUME_NONNULL_END
@@ -19,6 +19,9 @@
#import <Foundation/Foundation.h>
#import <FBSDKShareKit/FBSDKSharing.h>
#import <FBSDKShareKit/FBSDKShareConstants.h>
NS_ASSUME_NONNULL_BEGIN
/**
A dialog for sharing content through Messenger.
@@ -35,13 +38,28 @@
- FBSDKShareVideoContent
- Any other types that are not one of the four supported types listed above
*/
NS_SWIFT_NAME(MessageDialog)
DEPRECATED_FOR_MESSENGER
@interface FBSDKMessageDialog : NSObject <FBSDKSharingDialog>
/**
Convenience method to return a Message Share Dialog with content and a delegate.
@param content The content to be shared.
@param delegate The receiver's delegate.
*/
+ (instancetype)dialogWithContent:(id<FBSDKSharingContent>)content
delegate:(nullable id<FBSDKSharingDelegate>)delegate
NS_SWIFT_NAME(init(content:delegate:));
/**
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;
+ (instancetype)showWithContent:(id<FBSDKSharingContent>)content
delegate:(nullable id<FBSDKSharingDelegate>)delegate
NS_SWIFT_UNAVAILABLE("Use init(content:delegate:).show() instead");
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKMessageDialog.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareCameraEffectContent.h"
#import "FBSDKShareConstants.h"
#import "FBSDKShareDefines.h"
@@ -31,7 +35,10 @@
#define FBSDK_MESSAGE_DIALOG_APP_SCHEME @"fb-messenger-share-api"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKMessageDialog
#pragma clang diagnostic pop
#pragma mark - Class Methods
@@ -43,11 +50,18 @@
}
}
+ (instancetype)showWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
+ (instancetype)dialogWithContent:(id<FBSDKSharingContent>)content
delegate:(nullable id<FBSDKSharingDelegate>)delegate
{
FBSDKMessageDialog *dialog = [[self alloc] init];
dialog.shareContent = content;
dialog.delegate = delegate;
return dialog;
}
+ (instancetype)showWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
{
FBSDKMessageDialog *dialog = [self dialogWithContent:content delegate:delegate];
[dialog show];
return dialog;
}
@@ -69,9 +83,9 @@
{
NSError *error;
if (!self.canShow) {
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Message dialog is not available."];
error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Message dialog is not available."];
[self _invokeDelegateDidFailWithError:error];
return NO;
}
@@ -84,7 +98,7 @@
NSDictionary *parameters = [FBSDKShareUtility parametersForShareContent:shareContent
bridgeOptions:FBSDKShareBridgeOptionsDefault
shouldFailOnDataError:self.shouldFailOnDataError];
NSString *methodName = ([shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]] ?
NSString *methodName = ([shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")] ?
FBSDK_SHARE_OPEN_GRAPH_METHOD_NAME :
FBSDK_SHARE_METHOD_NAME);
FBSDKBridgeAPIRequest *request;
@@ -96,11 +110,11 @@
userInfo:nil];
FBSDKServerConfiguration *configuration = [FBSDKServerConfigurationManager cachedServerConfiguration];
BOOL useSafariViewController = [configuration useSafariViewControllerForDialogName:FBSDKDialogConfigurationNameMessage];
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
FBSDKBridgeAPIResponseBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
[self _handleCompletionWithDialogResults:response.responseParameters response:response];
[FBSDKInternalUtility unregisterTransientObject:self];
};
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:request
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:request
useSafariViewController:useSafariViewController
fromViewController:nil
completionBlock:completionBlock];
@@ -121,9 +135,9 @@
if (errorRef != NULL) {
NSString *message = [NSString stringWithFormat:@"Message dialog does not support %@.",
NSStringFromClass(self.shareContent.class)];
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
message:message];
*errorRef = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
message:message];
}
return NO;
}
@@ -161,9 +175,9 @@
FBSDKAppEventParameterDialogOutcome : FBSDKAppEventsDialogOutcomeValue_Cancelled,
};
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
if (!_delegate) {
@@ -179,9 +193,9 @@
FBSDKAppEventParameterDialogOutcome : FBSDKAppEventsDialogOutcomeValue_Completed,
};
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
if (!_delegate) {
@@ -198,9 +212,9 @@
parameters[FBSDKAppEventParameterDialogErrorMessage] = [NSString stringWithFormat:@"%@", error];
}
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogResult
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
if (!_delegate) {
@@ -213,7 +227,7 @@
- (void)_logDialogShow
{
NSString *contentType;
if([self.shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
if([self.shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
contentType = FBSDKAppEventsDialogShareContentTypeOpenGraph;
} else if ([self.shareContent isKindOfClass:[FBSDKShareLinkContent class]]) {
contentType = FBSDKAppEventsDialogShareContentTypeStatus;
@@ -235,9 +249,9 @@
FBSDKAppEventParameterDialogShareContentUUID : self.shareContent.shareUUID ?: [NSNull null],
FBSDKAppEventParameterDialogShareContentPageID : self.shareContent.pageID ?: [NSNull null]};
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogShow
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventMessengerShareDialogShow
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
}
@@ -20,14 +20,21 @@
#import <FBSDKCoreKit/FBSDKButton.h>
#import <FBSDKShareKit/FBSDKShareConstants.h>
#import <FBSDKShareKit/FBSDKSharingButton.h>
NS_ASSUME_NONNULL_BEGIN
/**
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.
*/
DEPRECATED_FOR_MESSENGER
NS_SWIFT_NAME(FBSendButton)
@interface FBSDKSendButton : FBSDKButton <FBSDKSharingButton>
@end
NS_ASSUME_NONNULL_END
@@ -18,14 +18,21 @@
#import "FBSDKSendButton.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKMessageDialog.h"
#import "FBSDKMessengerIcon.h"
@interface FBSDKSendButton () <FBSDKButtonImpressionTracking>
@end
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKSendButton
#pragma clang diagnostic pop
{
FBSDKMessageDialog *_dialog;
}
@@ -23,6 +23,8 @@
#import <FBSDKShareKit/FBSDKShareOpenGraphObject.h>
#import <FBSDKShareKit/FBSDKSharing.h>
NS_ASSUME_NONNULL_BEGIN
/**
A utility class for sharing through the graph API. Using this class requires an access token that
has been granted the "publish_actions" permission.
@@ -31,19 +33,35 @@
If you want to use FBSDKShareAPI in a background thread, you must manage the run loop
yourself.
*/
NS_SWIFT_NAME(ShareAPI)
@interface FBSDKShareAPI : NSObject <FBSDKSharing>
- (instancetype)init NS_DESIGNATED_INITIALIZER
NS_SWIFT_UNAVAILABLE("Use init(content:delegate:) instead");
+ (instancetype)new NS_UNAVAILABLE;
/**
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;
+ (instancetype)apiWithContent:(id<FBSDKSharingContent>)content
delegate:(nullable id<FBSDKSharingDelegate>)delegate
NS_SWIFT_NAME(init(content:delegate:));
/**
Convenience method to build up and share 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:(nullable id<FBSDKSharingDelegate>)delegate
NS_SWIFT_UNAVAILABLE("Use init(content:delegate:).share() instead");
/**
The message the person has provided through the custom dialog that will accompany the share content.
*/
@property (nonatomic, copy) NSString *message;
@property (nonatomic, copy, nullable) NSString *message;
/**
The graph node to which content should be shared.
@@ -57,7 +75,7 @@
Defaults to [FBSDKAccessToken currentAccessToken]. Setting this to nil will revert the access token to
[FBSDKAccessToken currentAccessToken].
*/
@property (nonatomic, strong) FBSDKAccessToken *accessToken;
@property (nonatomic, strong, nullable) FBSDKAccessToken *accessToken;
/**
A Boolean value that indicates whether the receiver can send the share.
@@ -92,3 +110,5 @@
- (BOOL)share;
@end
NS_ASSUME_NONNULL_END
@@ -18,14 +18,18 @@
#import "FBSDKShareAPI.h"
#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
#import <AssetsLibrary/AssetsLibrary.h>
#endif
#import <FBSDKCoreKit/FBSDKGraphRequest.h>
#import <FBSDKCoreKit/FBSDKGraphRequestDataAttachment.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareConstants.h"
#import "FBSDKShareDefines.h"
#import "FBSDKShareLinkContent.h"
@@ -49,18 +53,24 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
@implementation FBSDKShareAPI {
NSFileHandle *_fileHandle;
#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
ALAssetRepresentation *_assetRepresentation;
#endif
}
#pragma mark - Class Methods
+ (instancetype)shareWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
+ (instancetype)apiWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
{
FBSDKShareAPI *API = [[self alloc] init];
API.shareContent = content;
API.delegate = delegate;
return API;
}
+ (instancetype)shareWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate
{
FBSDKShareAPI *API = [self apiWithContent:content delegate:delegate];
[API share];
return API;
}
@@ -74,7 +84,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
#pragma mark - Object Lifecycle
#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
+ (ALAssetsLibrary *)defaultAssetsLibrary {
static dispatch_once_t pred = 0;
static ALAssetsLibrary *library = nil;
@@ -112,9 +122,9 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
NSError *error;
if (!self.canShare) {
NSString *message = @"Share API is not available; verify 'canShare' returns YES";
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:message];
error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:message];
[_delegate sharer:self didFailWithError:error];
return NO;
}
@@ -123,9 +133,9 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors logEntry:message];
}
if (!openGraphObject) {
error = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"openGraphObject"
message:nil];
error = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"openGraphObject"
message:nil];
[_delegate sharer:self didFailWithError:error];
return NO;
}
@@ -149,9 +159,9 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
NSError *error;
if (!self.canShare) {
NSString *message = @"Share API is not available; verify 'canShare' returns YES";
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:message];
error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:message];
[_delegate sharer:self didFailWithError:error];
return NO;
}
@@ -171,8 +181,11 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
return [self _sharePhotoContent:(FBSDKSharePhotoContent *)shareContent];
} else if ([shareContent isKindOfClass:[FBSDKShareVideoContent class]]) {
return [self _shareVideoContent:(FBSDKShareVideoContent *)shareContent];
} else if ([shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
} else if ([shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return [self _shareOpenGraphContent:(FBSDKShareOpenGraphContent *)shareContent];
#pragma GCC diagnostic pop
} else {
return NO;
}
@@ -183,28 +196,28 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
id<FBSDKSharingContent> shareContent = self.shareContent;
if (!shareContent) {
if (errorRef != NULL) {
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
message:@"Share content cannot be null."];
*errorRef = [FBSDKError requiredArgumentErrorWithDomain: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."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain: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."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"placeID"
value:shareContent.placeID
message:@"Cannot specify place ID with FBSDKShareVideoContent."];
}
return NO;
}
@@ -248,10 +261,10 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
} else {
tags = [content.peopleIDs componentsJoinedByString:@","];
}
[FBSDKInternalUtility dictionary:parameters setObject:tags forKey:@"tags"];
[FBSDKBasicUtility dictionary:parameters setObject:tags forKey:@"tags"];
}
[FBSDKInternalUtility dictionary:parameters setObject:content.placeID forKey:@"place"];
[FBSDKInternalUtility dictionary:parameters setObject:content.ref forKey:@"ref"];
[FBSDKBasicUtility dictionary:parameters setObject:content.placeID forKey:@"place"];
[FBSDKBasicUtility dictionary:parameters setObject:content.ref forKey:@"ref"];
}
- (BOOL)_hasPublishActions
@@ -261,7 +274,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
- (BOOL)_shareLinkContent:(FBSDKShareLinkContent *)linkContent
{
FBSDKGraphRequestHandler completionHandler = ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
FBSDKGraphRequestBlock completionHandler = ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!self->_delegate) {
return;
}
@@ -270,23 +283,17 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
} 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];
[FBSDKBasicUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST
forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
[FBSDKBasicUtility 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
[FBSDKBasicUtility dictionary:parameters setObject:self.message forKey:@"message"];
[FBSDKBasicUtility dictionary:parameters setObject:linkContent.contentURL forKey:@"link"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:[self _graphPathWithSuffix:@"feed", nil]
parameters:parameters
tokenString:self.accessToken.tokenString
@@ -295,6 +302,8 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
return YES;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (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
@@ -306,26 +315,26 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
void(^stagingHandler)(NSDictionary *) = ^(NSDictionary *stagedContainer) {
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:stagedContainer];
[self _addCommonParameters:parameters content:openGraphContent];
[FBSDKInternalUtility dictionary:parameters setObject:self.message forKey:@"message"];
[FBSDKBasicUtility dictionary:parameters setObject:self.message forKey:@"message"];
FBSDKGraphRequestHandler requestHandler = ^(FBSDKGraphRequestConnection *requestConnection,
FBSDKGraphRequestBlock 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];
NSError *error = [FBSDKError errorWithDomain: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];
[FBSDKBasicUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST
forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
[FBSDKBasicUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:result[@"id"]]
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
[self->_delegate sharer:self didCompleteWithResults:shareResults];
}
};
@@ -343,6 +352,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
}
return YES;
}
#pragma GCC diagnostic pop
- (BOOL)_sharePhotoContent:(FBSDKSharePhotoContent *)photoContent
{
@@ -358,7 +368,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[self _addCommonParameters:parameters content:photoContent];
NSString *caption = photo.caption ?: self.message;
[FBSDKInternalUtility dictionary:parameters setObject:caption forKey:@"caption"];
[FBSDKBasicUtility dictionary:parameters setObject:caption forKey:@"caption"];
parameters[@"picture"] = image;
[requests addObject:[[FBSDKGraphRequest alloc] initWithGraphPath:graphPath
parameters:parameters
@@ -371,10 +381,10 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
NSMutableArray *results = [[NSMutableArray alloc] init];
NSMutableArray *errors = [[NSMutableArray alloc] init];
__block NSUInteger completedCount = 0;
FBSDKGraphRequestHandler completionHandler = ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
FBSDKGraphRequestBlock completionHandler = ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
result = [FBSDKTypeUtility dictionaryValue:result];
[FBSDKInternalUtility array:results addObject:result];
[FBSDKInternalUtility array:errors addObject:error];
[FBSDKBasicUtility array:results addObject:result];
[FBSDKBasicUtility array:errors addObject:error];
if (++completedCount != requestCount) {
return;
}
@@ -387,12 +397,12 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
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];
[FBSDKBasicUtility 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];
[FBSDKBasicUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:firstResult[@"post_id"]]
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
[FBSDKBasicUtility dictionary:shareResults setObject:individualPhotoIDs forKey:FBSDK_SHARE_RESULT_PHOTO_IDS_KEY];
[self->_delegate sharer:self didCompleteWithResults:shareResults];
}
};
@@ -406,17 +416,14 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[self _addCommonParameters:parameters content:videoContent];
[FBSDKInternalUtility dictionary:parameters setObject:self.message forKey:@"description"];
[FBSDKBasicUtility 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
FBSDKSharePhoto *photo = videoContent.video.previewPhoto;
UIImage *image = photo.image;
if (!image && photo.imageURL.fileURL) {
image = [UIImage imageWithContentsOfFile:photo.imageURL.path];
}
[FBSDKInternalUtility dictionary:parameters setObject:image forKey:@"thumb"];
[FBSDKBasicUtility dictionary:parameters setObject:image forKey:@"thumb"];
}
FBSDKShareVideo *video = videoContent.video;
NSURL *videoURL = video.videoURL;
@@ -438,7 +445,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
[videoUploader start];
return YES;
} else if (videoURL) {
#if TARGET_OS_TV
#if TARGET_OS_TV || TARGET_OS_MACCATALYST
return NO;
#else
if (![self _addToPendingShareAPI]) {
@@ -498,10 +505,10 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
}
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:key
value:value
message:nil];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:key
value:value
message:nil];
}
return NO;
}
@@ -539,10 +546,10 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
stagedArray[idx] = stagedValue;
itemDidSucceed();
} else {
NSError *error = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"value"
value:item
message:@"Error staging object."];
NSError *error = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"value"
value:item
message:@"Error staging object."];
[self->_delegate sharer:self didFailWithError:error];
itemDidFail();
*stop = YES;
@@ -569,17 +576,17 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
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];
NSError *error = [FBSDKError requiredArgumentErrorWithDomain: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];
NSString *objectString = [FBSDKBasicUtility JSONStringForObject:stagedContainer
error:&JSONError
invalidObjectHandler:NULL];
if (!objectString) {
[self->_delegate sharer:self didFailWithError:JSONError];
return;
@@ -591,7 +598,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
tokenString:self.accessToken.tokenString
version:nil
HTTPMethod:@"POST"];
FBSDKGraphRequestHandler requestCompletionHandler = ^(FBSDKGraphRequestConnection *requestConnection,
FBSDKGraphRequestBlock requestCompletionHandler = ^(FBSDKGraphRequestConnection *requestConnection,
id result,
NSError *requestError) {
if (!self->_delegate) {
@@ -600,10 +607,10 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
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];
NSError *error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorOpenGraph
message:message
underlyingError:requestError];
[self->_delegate sharer:self didFailWithError:error];
} else if (completionHandler != NULL) {
completionHandler([FBSDKTypeUtility dictionaryValue:result]);
@@ -690,7 +697,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
@"url": photo.imageURL.absoluteString,
@"user_generated": @(photo.userGenerated),
}];
[FBSDKInternalUtility dictionary:stagedPhoto setObject:photo.caption forKey:@"caption"];
[FBSDKBasicUtility dictionary:stagedPhoto setObject:photo.caption forKey:@"caption"];
if (stagingHandler) {
stagingHandler(stagedPhoto);
}
@@ -703,32 +710,32 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
tokenString:self.accessToken.tokenString
version:nil
HTTPMethod:@"POST"];
FBSDKGraphRequestHandler completionHandler = ^(FBSDKGraphRequestConnection *requestConnection,
FBSDKGraphRequestBlock 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];
NSError *error = [FBSDKError errorWithDomain: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"];
[FBSDKBasicUtility 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."];
NSError *error = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photo"
value:photo
message:@"Photos must have an imageURL or image."];
[self->_delegate sharer:self didFailWithError:error];
return NO;
}
@@ -759,10 +766,10 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
} 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."];
NSError *error = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"value"
value:value
message:@"Invalid value type found in Open Graph object."];
[_delegate sharer:self didFailWithError:error];
return NO;
}
@@ -770,7 +777,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
- (NSString *)_connection:(FBSDKGraphRequestConnection *)connection
addRequest:(FBSDKGraphRequest *)request
completionHandler:(FBSDKGraphRequestHandler)completionHandler
completionHandler:(FBSDKGraphRequestBlock)completionHandler
{
NSUInteger requestCount = connection.requests.count;
NSString *batchEntryName = [[NSString alloc] initWithFormat:@"request_%lu", (unsigned long)requestCount];
@@ -795,7 +802,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
@synchronized(g_pendingFBSDKShareAPI) {
[g_pendingFBSDKShareAPI removeObject:self];
_fileHandle = nil;
#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
_assetRepresentation = nil;
#endif
}
@@ -814,7 +821,7 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
}
return videoChunkData;
}
#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_MACCATALYST
else if (_assetRepresentation) {
NSMutableData *data = [NSMutableData dataWithLength:chunkSize];
NSError *error;
@@ -832,8 +839,8 @@ static NSMutableArray *g_pendingFBSDKShareAPI;
{
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];
[FBSDKBasicUtility dictionary:shareResults setObject:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_VALUE_POST forKey:FBSDK_SHARE_RESULT_COMPLETION_GESTURE_KEY];
[FBSDKBasicUtility dictionary:shareResults setObject:[FBSDKTypeUtility stringValue:results[FBSDK_SHARE_VIDEO_ID]] forKey:FBSDK_SHARE_VIDEO_ID];
[_delegate sharer:self didCompleteWithResults:shareResults];
[self _removeFromPendingShareAPI];
}
@@ -22,12 +22,17 @@
#import <FBSDKShareKit/FBSDKSharingButton.h>
NS_ASSUME_NONNULL_BEGIN
/**
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.
*/
NS_SWIFT_NAME(FBShareButton)
@interface FBSDKShareButton : FBSDKButton <FBSDKSharingButton>
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareButton.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareDialog.h"
@implementation FBSDKShareButton
@@ -23,9 +23,12 @@
#import <FBSDKShareKit/FBSDKSharingContent.h>
#import <FBSDKShareKit/FBSDKSharingScheme.h>
NS_ASSUME_NONNULL_BEGIN
/**
A model for content to share with a Facebook camera effect.
*/
NS_SWIFT_NAME(ShareCameraEffectContent)
@interface FBSDKShareCameraEffectContent : NSObject <FBSDKSharingContent, FBSDKSharingScheme>
/**
@@ -51,3 +54,5 @@
- (BOOL)isEqualToShareCameraEffectContent:(FBSDKShareCameraEffectContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -20,7 +20,11 @@
#import "FBSDKCameraEffectArguments+Internal.h"
#import "FBSDKCameraEffectTextures+Internal.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKHashtag.h"
#import "FBSDKShareUtility.h"
@@ -63,29 +67,23 @@ static NSString *const kFBSDKShareCameraEffectContentUUIDKey = @"uuid";
#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"];
[FBSDKBasicUtility dictionary:updatedParameters
setObject:_effectID
forKey:@"effect_id"];
NSString *effectArgumentsJSON;
if (_effectArguments) {
effectArgumentsJSON = [FBSDKInternalUtility JSONStringForObject:[_effectArguments allArguments]
error:NULL
invalidObjectHandler:NULL];
effectArgumentsJSON = [FBSDKBasicUtility JSONStringForObject:[_effectArguments allArguments]
error:NULL
invalidObjectHandler:NULL];
}
[FBSDKInternalUtility dictionary:updatedParameters
setObject:effectArgumentsJSON
forKey:@"effect_arguments"];
[FBSDKBasicUtility dictionary:updatedParameters
setObject:effectArgumentsJSON
forKey:@"effect_arguments"];
NSData *effectTexturesData;
if (_effectTextures) {
@@ -102,9 +100,9 @@ static NSString *const kFBSDKShareCameraEffectContentUUIDKey = @"uuid";
}];
effectTexturesData = [NSKeyedArchiver archivedDataWithRootObject:texturesDataDict];
}
[FBSDKInternalUtility dictionary:updatedParameters
setObject:effectTexturesData
forKey:@"effect_textures"];
[FBSDKBasicUtility dictionary:updatedParameters
setObject:effectTexturesData
forKey:@"effect_textures"];
return updatedParameters;
}
@@ -130,9 +128,9 @@ static NSString *const kFBSDKShareCameraEffectContentUUIDKey = @"uuid";
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."];
*errorRef = [FBSDKError invalidArgumentErrorWithName:@"effectID"
value:_effectID
message:@"Invalid value for effectID, effectID can contain only numerical characters."];
}
return NO;
}
@@ -18,6 +18,12 @@
#import <Foundation/Foundation.h>
#ifndef DEPRECATED_FOR_MESSENGER
#define DEPRECATED_FOR_MESSENGER DEPRECATED_MSG_ATTRIBUTE("Sharing to Messenger via the SDK is unsupported. https://developers.facebook.com/docs/messenger-platform/changelog/#20190610. Sharing should be performed by the native share sheet.")
#endif
NS_ASSUME_NONNULL_BEGIN
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
@@ -25,7 +31,8 @@
Error codes from the SDK in the range 200-299 are reserved for this domain.
*/
FOUNDATION_EXPORT NSErrorDomain const FBSDKShareErrorDomain;
FOUNDATION_EXPORT NSErrorDomain const FBSDKShareErrorDomain
NS_SWIFT_NAME(ShareErrorDomain);
#else
@@ -34,7 +41,8 @@ FOUNDATION_EXPORT NSErrorDomain const FBSDKShareErrorDomain;
Error codes from the SDK in the range 200-299 are reserved for this domain.
*/
FOUNDATION_EXPORT NSString *const FBSDKShareErrorDomain;
FOUNDATION_EXPORT NSString *const FBSDKShareErrorDomain
NS_SWIFT_NAME(ShareErrorDomain);
#endif
@@ -71,15 +79,6 @@ typedef NS_ERROR_ENUM(FBSDKShareErrorDomain, FBSDKShareError)
@The error code for unknown errors.
*/
FBSDKShareErrorUnknown,
};
} NS_SWIFT_NAME(ShareError);
/**
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");
NS_ASSUME_NONNULL_END
@@ -22,20 +22,35 @@
#import <FBSDKShareKit/FBSDKSharing.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
A dialog for sharing content on Facebook.
*/
NS_SWIFT_NAME(ShareDialog)
@interface FBSDKShareDialog : NSObject <FBSDKSharingDialog>
/**
Convenience method to show an FBSDKShareDialog with a fromViewController, content and a delegate.
Convenience method to create a 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)dialogWithViewController:(nullable UIViewController *)viewController
withContent:(id<FBSDKSharingContent>)content
delegate:(nullable id<FBSDKSharingDelegate>)delegate
NS_SWIFT_NAME(init(fromViewController:content:delegate:));
/**
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;
delegate:(nullable id<FBSDKSharingDelegate>)delegate
NS_SWIFT_UNAVAILABLE("Use init(fromViewController:content:delegate:).show() instead");
/**
A UIViewController to present the dialog from.
@@ -52,3 +67,5 @@
@property (nonatomic, assign) FBSDKShareDialogMode mode;
@end
NS_ASSUME_NONNULL_END
@@ -20,7 +20,11 @@
#import <Social/Social.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareCameraEffectContent.h"
#import "FBSDKShareConstants.h"
#import "FBSDKShareDefines.h"
@@ -83,14 +87,24 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
}
}
+ (instancetype)showFromViewController:(UIViewController *)viewController
withContent:(id<FBSDKSharingContent>)content
delegate:(id<FBSDKSharingDelegate>)delegate
+ (instancetype)dialogWithViewController:(nullable UIViewController *)viewController
withContent:(id<FBSDKSharingContent>)content
delegate:(nullable id<FBSDKSharingDelegate>)delegate
{
FBSDKShareDialog *dialog = [[self alloc] init];
dialog.fromViewController = viewController;
dialog.shareContent = content;
dialog.delegate = delegate;
return dialog;
}
+ (instancetype)showFromViewController:(UIViewController *)viewController
withContent:(id<FBSDKSharingContent>)content
delegate:(id<FBSDKSharingDelegate>)delegate
{
FBSDKShareDialog *dialog = [self dialogWithViewController:viewController
withContent:content
delegate:delegate];
[dialog show];
return dialog;
}
@@ -207,13 +221,13 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if (errorCode == 4201) {
[self _invokeDelegateDidCancel];
} else if (errorCode != 0) {
NSError *error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorUnknown
userInfo:@{
FBSDKGraphRequestErrorGraphErrorCodeKey : @(errorCode)
NSError *error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorUnknown
userInfo:@{
FBSDKGraphRequestErrorGraphErrorCodeKey : @(errorCode)
}
message:results[@"error_message"]
underlyingError:nil];
message:results[@"error_message"]
underlyingError:nil];
[self _handleWebResponseParameters:nil error:error cancelled: NO];
} else {
// not all web dialogs report cancellation, so assume that the share has completed with no additional information
@@ -253,6 +267,8 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
return [configuration.defaultShareMode isEqualToString:@"share_sheet"];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (BOOL)_isOpenGraphURLShare:(FBSDKShareOpenGraphContent *)shareContent
{
__block BOOL hasOGURL = NO;
@@ -263,6 +279,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
}];
return hasOGURL;
}
#pragma clang diagnostic pop
-(BOOL)_showAutomatic:(NSError **)errorRef
{
@@ -296,7 +313,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
// for an app that can handle the native share dialog
NSString *methodName = nil;
NSString *methodVersion = nil;
if ([shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
if ([shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
methodName = FBSDK_SHARE_OPEN_GRAPH_METHOD_NAME;
BOOL containsMedia = NO;
[FBSDKShareUtility testShareContent:shareContent containsMedia:&containsMedia containsPhotos:NULL containsVideos:NULL];
@@ -503,9 +520,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
// not all web dialogs report cancellation, so assume that the share has completed with no additional information
NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
// the web response comes back with a different payload, so we need to translate it
[FBSDKInternalUtility dictionary:results
setObject:webResponseParameters[FBSDK_SHARE_WEB_PARAM_POST_ID_KEY]
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
[FBSDKBasicUtility dictionary:results
setObject:webResponseParameters[FBSDK_SHARE_WEB_PARAM_POST_ID_KEY]
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
[self _invokeDelegateDidCompleteWithResults:results];
}
}
@@ -530,7 +547,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if ([shareContent isKindOfClass:[FBSDKSharePhotoContent class]] && [self _photoContentHasAtLeastOneImage:(FBSDKSharePhotoContent *)shareContent]) {
void(^completion)(BOOL, NSString *, NSDictionary *) = ^(BOOL successfullyBuilt, NSString *cMethodName, NSDictionary *cParameters) {
if (successfullyBuilt) {
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
FBSDKBridgeAPIResponseBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
[self _handleWebResponseParameters:response.responseParameters error:response.error cancelled: response.isCancelled];
[FBSDKInternalUtility unregisterTransientObject:self];
};
@@ -541,7 +558,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
methodVersion:nil
parameters:cParameters
userInfo:nil];
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:request
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:request
useSafariViewController:[self _useSafariViewController]
fromViewController:self.fromViewController
completionBlock:completionBlock];
@@ -559,7 +576,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
error:errorRef]) {
return NO;
}
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
FBSDKBridgeAPIResponseBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
[self _handleWebResponseParameters:response.responseParameters error:response.error cancelled: response.isCancelled];
[FBSDKInternalUtility unregisterTransientObject:self];
};
@@ -570,7 +587,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
methodVersion:nil
parameters:parameters
userInfo:nil];
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:request
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:request
useSafariViewController:[self _useSafariViewController]
fromViewController:self.fromViewController
completionBlock:completionBlock];
@@ -585,7 +602,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
}
id<FBSDKSharingContent> shareContent = self.shareContent;
NSDictionary *parameters = [FBSDKShareUtility feedShareDictionaryForContent:shareContent];
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
FBSDKBridgeAPIResponseBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
[self _handleWebResponseParameters:response.responseParameters error:response.error cancelled:response.isCancelled];
[FBSDKInternalUtility unregisterTransientObject:self];
};
@@ -596,7 +613,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
methodVersion:nil
parameters:parameters
userInfo:nil];
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:request
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:request
useSafariViewController:[self _useSafariViewController]
fromViewController:self.fromViewController
completionBlock:completionBlock];
@@ -620,9 +637,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
{
if (![self _canShowNative]) {
if (canShowErrorRef != NULL) {
*canShowErrorRef = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Native share dialog is not available."];
*canShowErrorRef = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Native share dialog is not available."];
}
return NO;
}
@@ -649,7 +666,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
methodVersion:methodVersion
parameters:parameters
userInfo:nil];
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
FBSDKBridgeAPIResponseBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
if (response.error.code == FBSDKErrorAppVersionUnsupported) {
NSError *fallbackError;
if ([self _showShareSheetWithCanShowError:NULL validationError:&fallbackError] ||
@@ -666,14 +683,14 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
[self _invokeDelegateDidFailWithError:response.error];
} else {
NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
[FBSDKInternalUtility dictionary:results
setObject:responseParameters[FBSDK_SHARE_RESULT_POST_ID_KEY]
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
[FBSDKBasicUtility dictionary:results
setObject:responseParameters[FBSDK_SHARE_RESULT_POST_ID_KEY]
forKey:FBSDK_SHARE_RESULT_POST_ID_KEY];
[self _invokeDelegateDidCompleteWithResults:results];
}
[FBSDKInternalUtility unregisterTransientObject:self];
};
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:request
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:request
useSafariViewController:[self _useSafariViewController]
fromViewController:self.fromViewController
completionBlock:completionBlock];
@@ -684,9 +701,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
{
if (![self _canShowShareSheet]) {
if (canShowErrorRef != NULL) {
*canShowErrorRef = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Share sheet is not available."];
*canShowErrorRef = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Share sheet is not available."];
}
return NO;
}
@@ -696,9 +713,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
UIViewController *fromViewController = self.fromViewController;
if (!fromViewController) {
if (validationErrorRef != NULL) {
*validationErrorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"fromViewController"
message:nil];
*validationErrorRef = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"fromViewController"
message:nil];
}
return NO;
}
@@ -713,9 +730,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if (!composeViewController) {
if (canShowErrorRef != NULL) {
*canShowErrorRef = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Error creating SLComposeViewController."];
*canShowErrorRef = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Error creating SLComposeViewController."];
}
return NO;
}
@@ -801,16 +818,16 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if ([self.shareContent isKindOfClass:[FBSDKShareCameraEffectContent class]] ||
[self.shareContent isKindOfClass:[FBSDKShareLinkContent class]] ||
[self.shareContent isKindOfClass:[FBSDKShareMediaContent class]] ||
[self.shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]] ||
[self.shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")] ||
[self.shareContent isKindOfClass:[FBSDKSharePhotoContent class]] ||
[self.shareContent isKindOfClass:[FBSDKShareVideoContent class]]) {
} else {
if (errorRef != NULL) {
NSString *message = [NSString stringWithFormat:@"Share dialog does not support %@.",
NSStringFromClass(self.shareContent.class)];
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
message:message];
*errorRef = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
message:message];
}
return NO;
}
@@ -848,10 +865,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
}
}
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"FBSDKShareDialogMode"
value:@(self.mode)
message:nil];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"FBSDKShareDialogMode"
value:@(self.mode)
message:nil];
}
return NO;
}
@@ -877,10 +894,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
self.mode == FBSDKShareDialogModeShareSheet &&
![self _canUseQuoteInShareSheet]) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareLinkContent
message:@"Quotes are only supported if Facebook for iOS version 52 and above is installed"];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareLinkContent
message:@"Quotes are only supported if Facebook for iOS version 52 and above is installed"];
}
return NO;
}
@@ -896,20 +913,20 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
FBSDKShareLinkContent *const linkContent = shareContent;
if (!linkContent.contentURL) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"FBSDKShareLinkContent contentURL is required."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"FBSDKShareLinkContent contentURL is required."];
}
return NO;
}
}
if ([shareContent isKindOfClass:[FBSDKShareCameraEffectContent class]]) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Camera Content must be shared in `Native` mode."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Camera Content must be shared in `Native` mode."];
}
return NO;
}
@@ -920,10 +937,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if (containsPhotos) {
if ([FBSDKAccessToken currentAccessToken] == nil) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"The web share dialog needs a valid access token to stage photos."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"The web share dialog needs a valid access token to stage photos."];
}
return NO;
}
@@ -933,10 +950,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
}
} else {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Web share dialogs cannot include photos."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Web share dialogs cannot include photos."];
}
return NO;
}
@@ -944,10 +961,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if (containsVideos) {
if ([FBSDKAccessToken currentAccessToken] == nil) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"The web share dialog needs a valid access token to stage videos."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"The web share dialog needs a valid access token to stage videos."];
}
return NO;
}
@@ -960,10 +977,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if (containsMedia) {
if (bridgeOptions & FBSDKShareBridgeOptionsPhotoImageURL) { // a web-based URL is required
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Web share dialogs cannot include local media."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Web share dialogs cannot include local media."];
}
return NO;
}
@@ -979,19 +996,19 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
FBSDKShareLinkContent *const linkContent = shareContent;
if (!linkContent.contentURL) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"FBSDKShareLinkContent contentURL is required."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"FBSDKShareLinkContent contentURL is required."];
}
return NO;
}
} else {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Feed share dialogs support FBSDKShareLinkContent."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Feed share dialogs support FBSDKShareLinkContent."];
}
return NO;
}
@@ -1004,10 +1021,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if ([shareContent isKindOfClass:[FBSDKShareMediaContent class]]) {
if ([FBSDKShareUtility shareMediaContentContainsPhotosAndVideos:(FBSDKShareMediaContent *)shareContent]) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Multimedia Content is only available for mode `ShareSheet`"];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Multimedia Content is only available for mode `ShareSheet`"];
}
return NO;
}
@@ -1029,10 +1046,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
} else {
if ((errorRef != NULL) && !*errorRef) {
NSString *message = @"Share photo content must have UIImage photos in order to share with the share sheet";
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:message];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:message];
}
return NO;
}
@@ -1043,7 +1060,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
return ([self _canUseFBShareSheet] &&
[self _validateShareMediaContentAvailability:shareContent error:errorRef] &&
[(FBSDKShareMediaContent *)shareContent validateWithOptions:FBSDKShareBridgeOptionsDefault error:errorRef]);
} else if ([shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
} else if ([shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
FBSDKShareOpenGraphContent *ogContent = (FBSDKShareOpenGraphContent *)shareContent;
BOOL isOGURLShare = [self _isOpenGraphURLShare:ogContent];
@@ -1053,12 +1072,13 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if (!isValidOGShare) {
if ((errorRef != NULL) && !*errorRef) {
NSString *message = @"Share content must include an URL in the action, an action type, and a preview property name in order to share with the share sheet.";
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:message];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:message];
}
}
#pragma GCC diagnostic pop
return isValidOGShare;
} else if ([shareContent isKindOfClass:[FBSDKShareLinkContent class]]) {
return YES;
@@ -1066,10 +1086,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
if ((errorRef != NULL) && !*errorRef) {
NSString *message = [NSString stringWithFormat:@"Share sheet does not support %@.",
NSStringFromClass(shareContent.class)];
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:message];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:message];
}
return NO;
}
@@ -1083,10 +1103,10 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
self.mode == FBSDKShareDialogModeShareSheet &&
![self _canUseMMPInShareSheet]) {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Multimedia content (photos + videos) is only supported if Facebook for iOS version 52 and above is installed"];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"shareContent"
value:shareContent
message:@"Multimedia content (photos + videos) is only supported if Facebook for iOS version 52 and above is installed"];
}
return NO;
}
@@ -1099,9 +1119,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
FBSDKAppEventParameterDialogOutcome : FBSDKAppEventsDialogOutcomeValue_Cancelled,
};
[FBSDKAppEvents logImplicitEvent:FBSDLAppEventNameFBSDKEventShareDialogResult
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventShareDialogResult
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
[_delegate sharerDidCancel:self];
@@ -1113,9 +1133,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
FBSDKAppEventParameterDialogOutcome : FBSDKAppEventsDialogOutcomeValue_Completed
};
[FBSDKAppEvents logImplicitEvent:FBSDLAppEventNameFBSDKEventShareDialogResult
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventShareDialogResult
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
[_delegate sharer:self didCompleteWithResults:[results copy]];
@@ -1128,9 +1148,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
FBSDKAppEventParameterDialogErrorMessage : [NSString stringWithFormat:@"%@", error]
};
[FBSDKAppEvents logImplicitEvent:FBSDLAppEventNameFBSDKEventShareDialogResult
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventShareDialogResult
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
[_delegate sharer:self didFailWithError:error];
@@ -1141,7 +1161,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
NSString *shareMode = NSStringFromFBSDKShareDialogMode(self.mode);
NSString *contentType;
if([self.shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
if([self.shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
contentType = FBSDKAppEventsDialogShareContentTypeOpenGraph;
} else if ([self.shareContent isKindOfClass:[FBSDKShareLinkContent class]]) {
contentType = FBSDKAppEventsDialogShareContentTypeStatus;
@@ -1161,9 +1181,9 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
};
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKEventShareDialogShow
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKEventShareDialogShow
parameters:parameters
isImplicitlyLogged:YES
accessToken:[FBSDKAccessToken currentAccessToken]];
}
@@ -1186,7 +1206,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
parameters[FBSDKShareExtensionParamQuotes] = @[quote];
}
}
if ([self.shareContent isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
if ([self.shareContent isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
NSDictionary<NSString *, id> *const ogData = [FBSDKShareUtility parametersForShareContent:self.shareContent
bridgeOptions:FBSDKShareBridgeOptionsDefault
shouldFailOnDataError:self.shouldFailOnDataError];
@@ -1194,7 +1214,7 @@ static inline void FBSDKShareDialogValidateShareExtensionSchemeRegisteredForCanO
}
NSError *error = nil;
NSString *const jsonString = [FBSDKInternalUtility JSONStringForObject:parameters error:&error invalidObjectHandler:NULL];
NSString *const jsonString = [FBSDKBasicUtility JSONStringForObject:parameters error:&error invalidObjectHandler:NULL];
if (error != nil) {
return nil;
}
@@ -18,6 +18,8 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
NS_ENUM(NSUInteger, FBSDKShareDialogMode)
Modes for the FBSDKShareDialog.
@@ -44,7 +46,7 @@ typedef NS_ENUM(NSUInteger, FBSDKShareDialogMode)
*/
FBSDKShareDialogModeBrowser,
/**
@Displays the dialog in a UIWebView within the app.
@Displays the dialog in a WKWebView within the app.
*/
FBSDKShareDialogModeWeb,
/**
@@ -52,12 +54,15 @@ typedef NS_ENUM(NSUInteger, FBSDKShareDialogMode)
*/
FBSDKShareDialogModeFeedBrowser,
/**
@Displays the feed dialog in a UIWebView within the app.
@Displays the feed dialog in a WKWebView within the app.
*/
FBSDKShareDialogModeFeedWeb,
};
} NS_SWIFT_NAME(ShareDialog.Mode);
/**
Converts an FBSDKShareDialogMode to an NSString.
*/
FOUNDATION_EXPORT NSString *NSStringFromFBSDKShareDialogMode(FBSDKShareDialogMode dialogMode);
FOUNDATION_EXPORT NSString *NSStringFromFBSDKShareDialogMode(FBSDKShareDialogMode dialogMode)
NS_REFINED_FOR_SWIFT;
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareDialogMode.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
NSString *NSStringFromFBSDKShareDialogMode(FBSDKShareDialogMode dialogMode)
{
@@ -40,15 +40,11 @@
#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/FBSDKLiking.h>
#import <FBSDKShareKit/FBSDKLikeObjectType.h>
#import <FBSDKShareKit/FBSDKMessageDialog.h>
#import <FBSDKShareKit/FBSDKShareButton.h>
@@ -20,53 +20,21 @@
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
A model for status and link content to be shared.
*/
NS_SWIFT_NAME(ShareLinkContent)
@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;
@property (nonatomic, copy, nullable) NSString *quote;
/**
Compares the receiver to another link content.
@@ -76,3 +44,5 @@
- (BOOL)isEqualToShareLinkContent:(FBSDKShareLinkContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -16,23 +16,23 @@
// 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 "FBSDKShareLinkContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#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
@@ -45,7 +45,6 @@
@synthesize placeID = _placeID;
@synthesize ref = _ref;
@synthesize pageID = _pageID;
@synthesize feedParameters = _feedParameters;
@synthesize quote = _quote;
@synthesize shareUUID = _shareUUID;
@@ -62,7 +61,7 @@
#pragma mark - Setters
- (void)setPeopleIDs:(NSArray *)peopleIDs
- (void)setPeopleIDs:(NSArray<NSString *> *)peopleIDs
{
[FBSDKShareUtility assertCollection:peopleIDs ofClass:[NSString class] name:@"peopleIDs"];
if (![FBSDKInternalUtility object:_peopleIDs isEqualToObject:peopleIDs]) {
@@ -70,41 +69,21 @@
}
}
- (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"];
[FBSDKBasicUtility dictionary:updatedParameters setObject:_contentURL forKey:@"link"];
[FBSDKBasicUtility 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"];
[FBSDKBasicUtility dictionary:updatedParameters setObject:_contentURL forKey:@"messenger_link"];
return updatedParameters;
}
@@ -113,11 +92,7 @@
- (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
return [FBSDKShareUtility validateNetworkURL:_contentURL name:@"contentURL" error:errorRef];
}
#pragma mark - Equality
@@ -125,16 +100,12 @@
- (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,
};
@@ -154,22 +125,15 @@
- (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
@@ -182,13 +146,8 @@
- (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];
@@ -201,12 +160,8 @@
- (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];
@@ -220,12 +175,8 @@
- (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];
@@ -20,16 +20,27 @@
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
A protocol for media content (photo or video) to be shared.
*/
NS_SWIFT_NAME(ShareMedia)
@protocol FBSDKShareMedia <NSObject>
@end
/**
A model for media content (photo or video) to be shared.
*/
NS_SWIFT_NAME(ShareMediaContent)
@interface FBSDKShareMediaContent : NSObject <FBSDKSharingContent>
/**
Media to be shared.
@return Array of the media (FBSDKSharePhoto or FBSDKShareVideo)
*/
@property (nonatomic, copy) NSArray *media;
@property (nonatomic, copy) NSArray<id<FBSDKShareMedia>> *media;
/**
Compares the receiver to another media content.
@@ -39,3 +50,5 @@
- (BOOL)isEqualToShareMediaContent:(FBSDKShareMediaContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareMediaContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKHashtag.h"
#import "FBSDKShareConstants.h"
#import "FBSDKSharePhoto.h"
@@ -67,7 +71,7 @@
}
}
- (void)setMedia:(NSArray *)media
- (void)setMedia:(NSArray<id<FBSDKShareMedia>> *)media
{
[FBSDKShareUtility assertCollection:media ofClassStrings:@[NSStringFromClass([FBSDKSharePhoto class]), NSStringFromClass([FBSDKShareVideo class])] name:@"media"];
if (![FBSDKInternalUtility object:_media isEqualToObject:media]) {
@@ -77,12 +81,6 @@
#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
{
@@ -103,20 +101,20 @@
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"];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain: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"];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"media"
value:media
message:@"Only 1 video is allowed"];
return NO;
}
}
@@ -131,10 +129,10 @@
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"media"
value:media
message:@"Only FBSDKSharePhoto and FBSDKShareVideo are allowed in `media` property"];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"media"
value:media
message:@"Only FBSDKSharePhoto and FBSDKShareVideo are allowed in `media` property"];
}
return NO;
}
@@ -19,10 +19,15 @@
#import <Foundation/Foundation.h>
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKShareConstants.h>
NS_ASSUME_NONNULL_BEGIN
/**
A base interface for Messenger share action buttons.
*/
DEPRECATED_FOR_MESSENGER
NS_SWIFT_NAME(ShareMessengerActionButton)
@protocol FBSDKShareMessengerActionButton <FBSDKCopying, NSSecureCoding>
/**
@@ -32,3 +37,5 @@
@property (nonatomic, copy) NSString *title;
@end
NS_ASSUME_NONNULL_END
@@ -19,13 +19,17 @@
#import <Foundation/Foundation.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
#import <FBSDKShareKit/FBSDKShareConstants.h>
NS_ASSUME_NONNULL_BEGIN
@class FBSDKShareMessengerGenericTemplateElement;
DEPRECATED_FOR_MESSENGER
typedef NS_ENUM(NSUInteger, FBSDKShareMessengerGenericTemplateImageAspectRatio) {
FBSDKShareMessengerGenericTemplateImageAspectRatioHorizontal = 0,
FBSDKShareMessengerGenericTemplateImageAspectRatioSquare
};
} NS_SWIFT_NAME(ShareMessengerGenericTemplateImageAspectRatio);
/**
A model for sharing a generic template element to Messenger. This wrapper element allows
@@ -33,6 +37,8 @@ typedef NS_ENUM(NSUInteger, FBSDKShareMessengerGenericTemplateImageAspectRatio)
See https://developers.facebook.com/docs/messenger-platform/send-messages/template/generic
for more details.
*/
DEPRECATED_FOR_MESSENGER
NS_SWIFT_NAME(ShareMessengerGenericTemplateContent)
@interface FBSDKShareMessengerGenericTemplateContent : NSObject <FBSDKSharingContent>
/**
@@ -53,3 +59,5 @@ typedef NS_ENUM(NSUInteger, FBSDKShareMessengerGenericTemplateImageAspectRatio)
@property (nonatomic, copy) FBSDKShareMessengerGenericTemplateElement *element;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareMessengerGenericTemplateContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareMessengerContentUtility.h"
#import "FBSDKShareMessengerGenericTemplateElement.h"
#import "FBSDKShareMessengerURLActionButton.h"
@@ -30,6 +34,7 @@ static NSString *const kGenericTemplateIsSharableKey = @"isSharable";
static NSString *const kGenericTemplateImageAspectRatioKey = @"imageAspectRatio";
static NSString *const kGenericTemplateElementKey = @"element";
DEPRECATED_FOR_MESSENGER
static NSString *_ImageAspectRatioString(FBSDKShareMessengerGenericTemplateImageAspectRatio imageAspectRatio)
{
switch (imageAspectRatio) {
@@ -40,17 +45,18 @@ static NSString *_ImageAspectRatioString(FBSDKShareMessengerGenericTemplateImage
}
}
DEPRECATED_FOR_MESSENGER
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];
[FBSDKBasicUtility dictionary:elementDictionary setObject:element.title forKey:@"title"];
[FBSDKBasicUtility dictionary:elementDictionary setObject:element.subtitle forKey:@"subtitle"];
[FBSDKBasicUtility dictionary:elementDictionary setObject:element.imageURL.absoluteString forKey:@"image_url"];
[FBSDKBasicUtility 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"];
[FBSDKBasicUtility dictionary:elementDictionary setObject:SerializableButtonFromURLButton(element.defaultAction, YES) forKey:@"default_action"];
}
[serializableElements addObject:elementDictionary];
@@ -59,7 +65,10 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableGenericTemplateElem
return serializableElements;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareMessengerGenericTemplateContent
#pragma clang diagnostic pop
#pragma mark - Properties
@@ -84,12 +93,6 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableGenericTemplateElem
#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
{
@@ -110,10 +113,10 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableGenericTemplateElem
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"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:@"DEFAULT" forKey:@"preview_type"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:firstElement.title forKey:@"title"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:firstElement.subtitle forKey:@"subtitle"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:firstElement.imageURL.absoluteString forKey:@"image_url"];
if (firstElement.button) {
AddToContentPreviewDictionaryForButton(contentForPreview, firstElement.button);
} else {
@@ -21,11 +21,15 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
NS_ASSUME_NONNULL_BEGIN
/**
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.
*/
NS_SWIFT_NAME(ShareMessengerGenericTemplateElement)
DEPRECATED_FOR_MESSENGER
@interface FBSDKShareMessengerGenericTemplateElement : NSObject <FBSDKCopying, NSSecureCoding>
/**
@@ -36,21 +40,23 @@
/**
The rendered subtitle for the shared generic template element. Optional.
*/
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, copy, nullable) NSString *subtitle;
/**
The image url that will be downloaded and rendered at the top of the generic template. Optional.
*/
@property (nonatomic, copy) NSURL *imageURL;
@property (nonatomic, copy, nullable) 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;
@property (nonatomic, copy, nullable) id<FBSDKShareMessengerActionButton> defaultAction;
/**
This specifies what action button to show below the generic template. Optional.
*/
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> button;
@property (nonatomic, copy, nullable) id<FBSDKShareMessengerActionButton> button;
@end
NS_ASSUME_NONNULL_END
@@ -24,7 +24,10 @@ static NSString *const kGenericTemplateImageURLKey = @"imageURL";
static NSString *const kGenericTemplateDefaultActionKey = @"defaultAction";
static NSString *const kGenericTemplateButtonKey = @"button";
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareMessengerGenericTemplateElement
#pragma clang diagnostic pop
#pragma mark - NSCoding
@@ -21,17 +21,25 @@
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
DEPRECATED_FOR_MESSENGER
typedef NS_ENUM(NSUInteger, FBSDKShareMessengerMediaTemplateMediaType) {
FBSDKShareMessengerMediaTemplateMediaTypeImage = 0,
FBSDKShareMessengerMediaTemplateMediaTypeVideo
};
} NS_SWIFT_NAME(ShareMessengerMediaTemplateMediaType);
/**
A model for sharing media template content. See
https://developers.facebook.com/docs/messenger-platform/send-messages/template/media for details.
*/
NS_SWIFT_NAME(ShareMessengerMediaTemplateContent)
DEPRECATED_FOR_MESSENGER
@interface FBSDKShareMessengerMediaTemplateContent : NSObject <FBSDKSharingContent>
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
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.
@@ -41,19 +49,19 @@ typedef NS_ENUM(NSUInteger, FBSDKShareMessengerMediaTemplateMediaType) {
/**
The attachmentID of the item to share. Optional, but either attachmentID or mediaURL must be specified.
*/
@property (nonatomic, copy, readonly) NSString *attachmentID;
@property (nonatomic, copy, readonly, nullable) 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;
@property (nonatomic, copy, readonly, nullable) NSURL *mediaURL;
/**
This specifies what action button to show below the media. Optional.
*/
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> button;
@property (nonatomic, copy, nullable) id<FBSDKShareMessengerActionButton> button;
/**
Custom initializer to create media template share with attachment id.
@@ -67,3 +75,5 @@ typedef NS_ENUM(NSUInteger, FBSDKShareMessengerMediaTemplateMediaType) {
- (instancetype)initWithMediaURL:(NSURL *)mediaURL;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareMessengerMediaTemplateContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKHashtag.h"
#import "FBSDKShareConstants.h"
#import "FBSDKShareMessengerContentUtility.h"
@@ -55,6 +59,7 @@ static NSString *_MediaTemplateURLSerializationKey(NSURL *mediaURL)
}
}
DEPRECATED_FOR_MESSENGER
static NSString *_MediaTypeString(FBSDKShareMessengerMediaTemplateMediaType mediaType)
{
switch (mediaType) {
@@ -65,21 +70,25 @@ static NSString *_MediaTypeString(FBSDKShareMessengerMediaTemplateMediaType medi
}
}
DEPRECATED_FOR_MESSENGER
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];
[FBSDKBasicUtility dictionary:mediaTemplateContentDictionary setObject:_MediaTypeString(mediaTemplateContent.mediaType) forKey:@"media_type"];
[FBSDKBasicUtility dictionary:mediaTemplateContentDictionary setObject:mediaTemplateContent.mediaURL.absoluteString forKey:@"url"];
[FBSDKBasicUtility dictionary:mediaTemplateContentDictionary setObject:mediaTemplateContent.attachmentID forKey:@"attachment_id"];
[FBSDKBasicUtility dictionary:mediaTemplateContentDictionary setObject:SerializableButtonsFromButton(mediaTemplateContent.button) forKey:kFBSDKShareMessengerButtonsKey];
[serializableMediaTemplateContent addObject:mediaTemplateContentDictionary];
return serializableMediaTemplateContent;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareMessengerMediaTemplateContent
#pragma clang diagnostic pop
#pragma mark - Properties
@@ -115,12 +124,6 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableMediaTemplateConten
#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
{
@@ -138,12 +141,12 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableMediaTemplateConten
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"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:@"DEFAULT" forKey:@"preview_type"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:_attachmentID forKey:@"attachment_id"];
[FBSDKBasicUtility dictionary:contentForPreview
setObject:_mediaURL.absoluteString
forKey:_MediaTemplateURLSerializationKey(_mediaURL)];
[FBSDKBasicUtility dictionary:contentForPreview setObject:_MediaTypeString(_mediaType) forKey:@"media_type"];
AddToContentPreviewDictionaryForButton(contentForPreview, _button);
[FBSDKShareMessengerContentUtility addToParameters:updatedParameters contentForShare:contentForShare contentForPreview:contentForPreview];
@@ -157,9 +160,9 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableMediaTemplateConten
{
if (!_mediaURL && !_attachmentID) {
if (errorRef != NULL) {
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"attachmentID/mediaURL"
message:@"Must specify either attachmentID or mediaURL"];
*errorRef = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"attachmentID/mediaURL"
message:@"Must specify either attachmentID or mediaURL"];
}
return NO;
}
@@ -178,7 +181,7 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableMediaTemplateConten
- (instancetype)initWithCoder:(NSCoder *)decoder
{
if ((self = [self init])) {
if (self = [self initWithAttachmentID:@""]) {
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:kMediaTemplatePageIDKey];
_mediaType = [[decoder decodeObjectForKey:kMediaTemplateMediaTypeKey] unsignedIntegerValue];
_attachmentID = [decoder decodeObjectOfClass:[NSString class] forKey:kMediaTemplateAttachmentIDKey];
@@ -203,7 +206,8 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableMediaTemplateConten
- (id)copyWithZone:(NSZone *)zone
{
FBSDKShareMessengerMediaTemplateContent *copy = [[FBSDKShareMessengerMediaTemplateContent alloc] init];
FBSDKShareMessengerMediaTemplateContent *copy =
[[FBSDKShareMessengerMediaTemplateContent alloc] initWithAttachmentID:@""];
copy->_pageID = [_pageID copy];
copy->_mediaType = _mediaType;
copy->_attachmentID = [_attachmentID copy];
@@ -21,11 +21,15 @@
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
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.
*/
DEPRECATED_FOR_MESSENGER
NS_SWIFT_NAME(ShareMessengerOpenGraphMusicTemplateContent)
@interface FBSDKShareMessengerOpenGraphMusicTemplateContent : NSObject <FBSDKSharingContent>
/**
@@ -36,6 +40,8 @@
/**
This specifies what action button to show below the open graph music bubble. Optional.
*/
@property (nonatomic, copy) id<FBSDKShareMessengerActionButton> button;
@property (nonatomic, copy, nullable) id<FBSDKShareMessengerActionButton> button;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareMessengerOpenGraphMusicTemplateContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareMessengerContentUtility.h"
#import "FBSDKShareUtility.h"
@@ -27,19 +31,24 @@ static NSString *const kMusicTemplateURLKey = @"url";
static NSString *const kMusicTemplateButtonKey = @"button";
static NSString *const kMusicTemplateUUIDKey = @"uuid";
DEPRECATED_FOR_MESSENGER
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];
[FBSDKBasicUtility dictionary:openGraphMusicTemplateContentDictionary setObject:openGraphMusicTemplateContent.url.absoluteString forKey:@"url"];
[FBSDKBasicUtility dictionary:openGraphMusicTemplateContentDictionary setObject:SerializableButtonsFromButton(openGraphMusicTemplateContent.button) forKey:kFBSDKShareMessengerButtonsKey];
[serializableOpenGraphMusicTemplateContent addObject:openGraphMusicTemplateContentDictionary];
return serializableOpenGraphMusicTemplateContent;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareMessengerOpenGraphMusicTemplateContent
#pragma clang diagnostic pop
#pragma mark - Properties
@@ -64,12 +73,6 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableOpenGraphMusicTempl
#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
{
@@ -87,8 +90,8 @@ static NSArray<NSDictionary<NSString *, id> *> *_SerializableOpenGraphMusicTempl
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"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:@"OPEN_GRAPH" forKey:@"preview_type"];
[FBSDKBasicUtility dictionary:contentForPreview setObject:_url.absoluteString forKey:@"open_graph_url"];
AddToContentPreviewDictionaryForButton(contentForPreview, _button);
[FBSDKShareMessengerContentUtility addToParameters:updatedParameters contentForShare:contentForShare contentForPreview:contentForPreview];
@@ -20,15 +20,19 @@
#import <FBSDKShareKit/FBSDKShareMessengerActionButton.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, FBSDKShareMessengerURLActionButtonWebviewHeightRatio) {
FBSDKShareMessengerURLActionButtonWebviewHeightRatioFull = 0,
FBSDKShareMessengerURLActionButtonWebviewHeightRatioTall,
FBSDKShareMessengerURLActionButtonWebviewHeightRatioCompact
};
} NS_SWIFT_NAME(ShareMessengerURLActionButton.WebviewHeightRatio);
/**
A model for a Messenger share URL action button.
*/
DEPRECATED_FOR_MESSENGER
NS_SWIFT_NAME(ShareMessengerURLActionButton)
@interface FBSDKShareMessengerURLActionButton : NSObject <FBSDKShareMessengerActionButton>
/**
@@ -51,7 +55,7 @@ typedef NS_ENUM(NSUInteger, FBSDKShareMessengerURLActionButtonWebviewHeightRatio
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;
@property (nonatomic, copy, nullable) NSURL *fallbackURL;
/**
This controls whether we want to hide the share button in the webview or not. It is useful to hide the share
@@ -60,3 +64,5 @@ typedef NS_ENUM(NSUInteger, FBSDKShareMessengerURLActionButtonWebviewHeightRatio
@property (nonatomic, assign) BOOL shouldHideWebviewShareButton;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareMessengerURLActionButton.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareUtility.h"
static NSString *const kURLActionButtonTitleKey = @"title";
@@ -28,7 +32,10 @@ static NSString *const kURLActionButtonMessengerExtensionsKey = @"messengerExten
static NSString *const kURLActionButtonFallbackURLKey = @"fallbackURL";
static NSString *const kURLActionButtonShouldHideWebviewShareButtonKey = @"shouldHideWebviewShareButton";
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareMessengerURLActionButton
#pragma clang diagnostic pop
#pragma mark - Properties
@@ -23,13 +23,26 @@
#import <FBSDKShareKit/FBSDKShareOpenGraphObject.h>
#import <FBSDKShareKit/FBSDKShareOpenGraphValueContainer.h>
NS_ASSUME_NONNULL_BEGIN
/**
An Open Graph Action for sharing.
The property keys MUST have namespaces specified on them, such as `og:image`.
*/
NS_SWIFT_NAME(ShareOpenGraphAction)
@interface FBSDKShareOpenGraphAction : FBSDKShareOpenGraphValueContainer <FBSDKCopying, NSSecureCoding>
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
Designated initializer to build a new action and set the object for the specified key.
@param actionType The action type of the receiver
*/
- (instancetype)initWithActionType:(NSString *)actionType
NS_SWIFT_NAME(init(type:));
/**
Convenience method to build a new action and set the object for the specified key.
@param actionType The action type of the receiver
@@ -68,3 +81,5 @@
- (BOOL)isEqualToShareOpenGraphAction:(FBSDKShareOpenGraphAction *)action;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareOpenGraphAction.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareOpenGraphValueContainer+Internal.h"
#define FBSDK_SHARE_OPEN_GRAPH_ACTION_TYPE_KEY @"type"
@@ -29,15 +33,14 @@
+ (instancetype)actionWithType:(NSString *)actionType object:(FBSDKShareOpenGraphObject *)object key:(NSString *)key
{
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = actionType;
FBSDKShareOpenGraphAction *action = [[self alloc] initWithActionType:actionType];
[action setObject:object forKey:key];
return action;
}
+ (instancetype)actionWithType:(NSString *)actionType objectID:(NSString *)objectID key:(NSString *)key
{
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
FBSDKShareOpenGraphAction *action = [[self alloc] initWithActionType:actionType];
action.actionType = actionType;
[action setString:objectID forKey:key];
return action;
@@ -45,7 +48,7 @@
+ (instancetype)actionWithType:(NSString *)actionType objectURL:(NSURL *)objectURL key:(NSString *)key
{
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
FBSDKShareOpenGraphAction *action = [[self alloc] initWithActionType:actionType];
action.actionType = actionType;
[action setURL:objectURL forKey:key];
return action;
@@ -83,6 +86,15 @@
return YES;
}
- (instancetype)initWithActionType:(NSString *)actionType
{
if (self = [super init]) {
self.actionType = actionType;
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)decoder
{
if ((self = [super initWithCoder:decoder])) {
@@ -101,8 +113,7 @@
- (id)copyWithZone:(NSZone *)zone
{
FBSDKShareOpenGraphAction *copy = [[FBSDKShareOpenGraphAction alloc] init];
copy->_actionType = [_actionType copy];
FBSDKShareOpenGraphAction *copy = [[FBSDKShareOpenGraphAction alloc] initWithActionType:[_actionType copy]];
[copy parseProperties:[self allProperties]];
return copy;
}
@@ -21,9 +21,13 @@
#import <FBSDKShareKit/FBSDKShareOpenGraphAction.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
A model for Open Graph content to be shared.
*/
NS_SWIFT_NAME(ShareOpenGraphContent)
DEPRECATED_MSG_ATTRIBUTE("Open Graph no longer available; use FBSDKShareLinkContent instead.")
@interface FBSDKShareOpenGraphContent : NSObject <FBSDKSharingContent>
/**
@@ -36,7 +40,6 @@
Property name that points to the primary Open Graph Object in the action.
The value that this action points to will be use for rendering the preview for the share.
@return The property name for the Open Graph Object in the action
*/
@property (nonatomic, copy) NSString *previewPropertyName;
@@ -48,3 +51,5 @@
- (BOOL)isEqualToShareOpenGraphContent:(FBSDKShareOpenGraphContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareOpenGraphContent.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKHashtag.h"
#import "FBSDKSharePhoto.h"
#import "FBSDKShareUtility.h"
@@ -33,8 +37,11 @@
#define FBSDK_SHARE_OPEN_GRAPH_CONTENT_PAGE_ID_KEY @"pageID"
#define FBSDK_SHARE_OPEN_GRAPH_CONTENT_UUID_KEY @"uuid"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareOpenGraphContent
#pragma mark - Properties
@synthesize contentURL = _contentURL;
@@ -68,25 +75,19 @@
#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];
NSString *previewPropertyName = [FBSDKShareUtility getOpenGraphNameAndNamespaceFromFullName:_previewPropertyName namespace:nil];
[FBSDKInternalUtility dictionary:updatedParameters
setObject:previewPropertyName
forKey:@"previewPropertyName"];
[FBSDKInternalUtility dictionary:updatedParameters setObject:_action.actionType forKey:@"actionType"];
[FBSDKInternalUtility dictionary:updatedParameters
setObject:[FBSDKShareUtility convertOpenGraphValueContainer:_action requireNamespace:NO]
forKey:@"action"];
[FBSDKBasicUtility dictionary:updatedParameters
setObject:previewPropertyName
forKey:@"previewPropertyName"];
[FBSDKBasicUtility dictionary:updatedParameters setObject:_action.actionType forKey:@"actionType"];
[FBSDKBasicUtility dictionary:updatedParameters
setObject:[FBSDKShareUtility convertOpenGraphValueContainer:_action requireNamespace:NO]
forKey:@"action"];
return updatedParameters;
}
@@ -123,7 +124,7 @@
if (self == object) {
return YES;
}
if (![object isKindOfClass:[FBSDKShareOpenGraphContent class]]) {
if (![object isKindOfClass:NSClassFromString(@"FBSDKShareOpenGraphContent")]) {
return NO;
}
return [self isEqualToShareOpenGraphContent:(FBSDKShareOpenGraphContent *)object];
@@ -199,3 +200,4 @@
}
@end
#pragma clang diagnostic pop
@@ -22,6 +22,8 @@
#import <FBSDKShareKit/FBSDKShareOpenGraphValueContainer.h>
NS_ASSUME_NONNULL_BEGIN
/**
An Open Graph Object for sharing.
@@ -41,13 +43,14 @@
@"fitness:metrics:location:longitude": @"2.17403",
}];
*/
NS_SWIFT_NAME(ShareOpenGraphObject)
@interface FBSDKShareOpenGraphObject : FBSDKShareOpenGraphValueContainer <FBSDKCopying, NSSecureCoding>
/**
Convenience method to build a new action and set the object for the specified key.
@param properties Properties for the Open Graph object, which will be parsed into the proper models
*/
+ (instancetype)objectWithProperties:(NSDictionary *)properties;
+ (instancetype)objectWithProperties:(NSDictionary<NSString *, id> *)properties;
/**
Compares the receiver to another Open Graph Object.
@@ -57,3 +60,5 @@
- (BOOL)isEqualToShareOpenGraphObject:(FBSDKShareOpenGraphObject *)object;
@end
NS_ASSUME_NONNULL_END
@@ -18,74 +18,106 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class FBSDKShareOpenGraphObject;
@class FBSDKSharePhoto;
/**
Enumeration Block
*/
typedef void (^FBSDKEnumerationBlock)(NSString *key, id object, BOOL *stop)
NS_SWIFT_NAME(EnumerationBlock)
NS_SWIFT_UNAVAILABLE("");
/**
Protocol defining operations on open graph actions and objects.
The property keys MUST have namespaces specified on them, such as `og:image`.
*/
NS_SWIFT_NAME(ShareOpenGraphValueContaining)
@protocol FBSDKShareOpenGraphValueContaining <NSObject, NSSecureCoding>
/**
Returns a dictionary of all the objects that lets you access each key/object in the receiver.
*/
@property (nonatomic, readonly, strong) NSDictionary<NSString *, id> *allProperties;
/**
Returns an enumerator object that lets you access each key in the receiver.
@return An enumerator object that lets you access each key in the receiver
*/
@property (nonatomic, readonly, strong) NSEnumerator *keyEnumerator
NS_SWIFT_UNAVAILABLE("");
/**
Returns an enumerator object that lets you access each value in the receiver.
@return An enumerator object that lets you access each value in the receiver
*/
@property (nonatomic, readonly, strong) NSEnumerator *objectEnumerator
NS_SWIFT_UNAVAILABLE("");
/**
Gets an NSArray out of the receiver.
@param key The key for the value
@return The NSArray value or nil
*/
- (NSArray *)arrayForKey:(NSString *)key;
- (nullable NSArray<id> *)arrayForKey:(NSString *)key;
/**
Applies a given block object to the entries of the receiver.
@param block A block object to operate on entries in the receiver
*/
- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(NSString *key, id object, BOOL *stop))block;
/**
Returns an enumerator object that lets you access each key in the receiver.
@return An enumerator object that lets you access each key in the receiver
*/
- (NSEnumerator *)keyEnumerator;
- (void)enumerateKeysAndObjectsUsingBlock:(FBSDKEnumerationBlock)block
NS_SWIFT_UNAVAILABLE("");
/**
Gets an NSNumber out of the receiver.
@param key The key for the value
@return The NSNumber value or nil
*/
- (NSNumber *)numberForKey:(NSString *)key;
- (nullable NSNumber *)numberForKey:(NSString *)key;
/**
Returns an enumerator object that lets you access each value in the receiver.
@return An enumerator object that lets you access each value in the receiver
Gets an NSString out of the receiver.
@param key The key for the value
@return The NSString value or nil
*/
- (NSEnumerator *)objectEnumerator;
- (nullable NSString *)stringForKey:(NSString *)key;
/**
Gets an NSURL out of the receiver.
@param key The key for the value
@return The NSURL value or nil
*/
- (nullable NSURL *)URLForKey:(NSString *)key;
/**
Gets an FBSDKShareOpenGraphObject out of the receiver.
@param key The key for the value
@return The FBSDKShareOpenGraphObject value or nil
*/
- (FBSDKShareOpenGraphObject *)objectForKey:(NSString *)key;
- (nullable FBSDKShareOpenGraphObject *)objectForKey:(NSString *)key;
/**
Enables subscript access to the values in the receiver.
@param key The key for the value
@return The value
*/
- (id)objectForKeyedSubscript:(NSString *)key;
- (nullable id)objectForKeyedSubscript:(NSString *)key;
/**
Parses properties out of a dictionary into the receiver.
@param properties The properties to parse.
*/
- (void)parseProperties:(NSDictionary *)properties;
- (void)parseProperties:(NSDictionary<NSString *, id> *)properties;
/**
Gets an FBSDKSharePhoto out of the receiver.
@param key The key for the value
@return The FBSDKSharePhoto value or nil
*/
- (FBSDKSharePhoto *)photoForKey:(NSString *)key;
- (nullable FBSDKSharePhoto *)photoForKey:(NSString *)key;
/**
Removes a value from the receiver for the specified key.
@@ -101,62 +133,57 @@
@param array The NSArray value
@param key The key for the value
*/
- (void)setArray:(NSArray *)array forKey:(NSString *)key;
- (void)setArray:(nullable NSArray<id> *)array forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Sets an NSNumber on the receiver.
@param number The NSNumber value
@param key The key for the value
*/
- (void)setNumber:(NSNumber *)number forKey:(NSString *)key;
- (void)setNumber:(nullable NSNumber *)number forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Sets an FBSDKShareOpenGraphObject on the receiver.
@param object The FBSDKShareOpenGraphObject value
@param key The key for the value
*/
- (void)setObject:(FBSDKShareOpenGraphObject *)object forKey:(NSString *)key;
- (void)setObject:(nullable FBSDKShareOpenGraphObject *)object forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Sets an FBSDKSharePhoto on the receiver.
@param photo The FBSDKSharePhoto value
@param key The key for the value
*/
- (void)setPhoto:(FBSDKSharePhoto *)photo forKey:(NSString *)key;
- (void)setPhoto:(nullable FBSDKSharePhoto *)photo forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Sets an NSString on the receiver.
@param string The NSString value
@param key The key for the value
*/
- (void)setString:(NSString *)string forKey:(NSString *)key;
- (void)setString:(nullable NSString *)string forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
/**
Sets an NSURL on the receiver.
@param URL The NSURL value
@param key The key for the value
*/
- (void)setURL:(NSURL *)URL forKey:(NSString *)key;
/**
Gets an NSString out of the receiver.
@param key The key for the value
@return The NSString value or nil
*/
- (NSString *)stringForKey:(NSString *)key;
/**
Gets an NSURL out of the receiver.
@param key The key for the value
@return The NSURL value or nil
*/
- (NSURL *)URLForKey:(NSString *)key;
- (void)setURL:(nullable NSURL *)URL forKey:(NSString *)key
NS_SWIFT_NAME(set(_:forKey:));
@end
/**
A base class to container Open Graph values.
*/
NS_SWIFT_NAME(ShareOpenGraphValueContainer)
@interface FBSDKShareOpenGraphValueContainer : NSObject <FBSDKShareOpenGraphValueContaining>
@end
NS_ASSUME_NONNULL_END
@@ -19,7 +19,11 @@
#import "FBSDKShareOpenGraphValueContainer.h"
#import "FBSDKShareOpenGraphValueContainer+Internal.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareOpenGraphObject.h"
#import "FBSDKSharePhoto.h"
#import "FBSDKShareUtility.h"
@@ -28,7 +32,7 @@
@implementation FBSDKShareOpenGraphValueContainer
{
NSMutableDictionary *_properties;
NSMutableDictionary<NSString *, id> *_properties;
}
#pragma mark - Object Lifecycle
@@ -53,7 +57,7 @@
return [self _valueOfClass:[NSArray class] forKey:key];
}
- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(NSString *key, id object, BOOL *stop))block
- (void)enumerateKeysAndObjectsUsingBlock:(FBSDKEnumerationBlock)block
{
[_properties enumerateKeysAndObjectsUsingBlock:block];
}
@@ -83,7 +87,7 @@
return [self _valueForKey:key];
}
- (void)parseProperties:(NSDictionary *)properties
- (void)parseProperties:(NSDictionary<NSString *, id> *)properties
{
[FBSDKShareUtility assertOpenGraphValues:properties requireKeyNamespace:[self requireKeyNamespace]];
[_properties addEntriesFromDictionary:[FBSDKShareUtility convertOpenGraphValues:properties]];
@@ -145,7 +149,7 @@
#pragma mark - Internal Methods
- (NSDictionary *)allProperties
- (NSDictionary<NSString *, id> *)allProperties
{
return _properties;
}
@@ -19,14 +19,18 @@
#import <UIKit/UIKit.h>
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKShareMediaContent.h>
#import <FBSDKShareKit/FBSDKSharingValidation.h>
NS_ASSUME_NONNULL_BEGIN
@class PHAsset;
/**
A photo for sharing.
*/
@interface FBSDKSharePhoto : NSObject <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
NS_SWIFT_NAME(SharePhoto)
@interface FBSDKSharePhoto : NSObject <NSSecureCoding, FBSDKCopying, FBSDKShareMedia, FBSDKSharingValidation>
/**
Convenience method to build a new photo object with an image.
@@ -60,19 +64,19 @@
If the photo is resident in memory, this method supplies the data.
@return UIImage representation of the photo
*/
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong, nullable) UIImage *image;
/**
The URL to the photo.
@return URL that points to a network location or the location of the photo on disk
*/
@property (nonatomic, copy) NSURL *imageURL;
@property (nonatomic, copy, nullable) NSURL *imageURL;
/**
The representation of the photo in the Photos library.
- Returns: PHAsset that represents the photo in the Photos library.
*/
@property (nonatomic, copy) PHAsset *photoAsset;
@property (nonatomic, copy, nullable) PHAsset *photoAsset;
/**
Specifies whether the photo represented by the receiver was generated by the user or by the application.
@@ -80,6 +84,13 @@
*/
@property (nonatomic, assign, getter=isUserGenerated) BOOL userGenerated;
/**
The user generated caption for the photo. Note that the 'caption' must come from
* the user, as pre-filled content is forbidden by the Platform Policies (2.3).
@return the Photo's caption if exists else returns null.
*/
@property (nonatomic, copy, nullable) NSString *caption;
/**
Compares the receiver to another photo.
@param photo The other photo
@@ -87,12 +98,7 @@
*/
- (BOOL)isEqualToSharePhoto:(FBSDKSharePhoto *)photo;
/**
The user generated caption for the photo. Note that the 'caption' must come from
* the user, as pre-filled content is forbidden by the Platform Policies (2.3).
@return the Photo's caption if exists else returns null.
*/
@property (nonatomic, copy) NSString *caption;
@end
NS_ASSUME_NONNULL_END
@@ -20,7 +20,11 @@
#import <Photos/Photos.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareConstants.h"
NSString *const kFBSDKSharePhotoAssetKey = @"photoAsset";
@@ -123,10 +127,10 @@ NSString *const kFBSDKSharePhotoCaptionKey = @"caption";
if (_imageURL) {
if (_imageURL.isFileURL) {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"imageURL"
value:_imageURL
message:@"Cannot refer to a local file resource."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"imageURL"
value:_imageURL
message:@"Cannot refer to a local file resource."];
}
return NO;
} else {
@@ -134,10 +138,10 @@ NSString *const kFBSDKSharePhotoCaptionKey = @"caption";
}
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photo"
value:self
message:@"imageURL is required."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photo"
value:self
message:@"imageURL is required."];
}
return NO;
}
@@ -150,10 +154,10 @@ NSString *const kFBSDKSharePhotoCaptionKey = @"caption";
}
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photoAsset"
value:_photoAsset
message:@"Must refer to a photo or other static image."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photoAsset"
value:_photoAsset
message:@"Must refer to a photo or other static image."];
}
return NO;
}
@@ -162,10 +166,10 @@ NSString *const kFBSDKSharePhotoCaptionKey = @"caption";
return YES; // will load the contents of the file and bridge the image
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"imageURL"
value:_imageURL
message:@"Must refer to a local file resource."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"imageURL"
value:_imageURL
message:@"Must refer to a local file resource."];
}
return NO;
}
@@ -173,10 +177,10 @@ NSString *const kFBSDKSharePhotoCaptionKey = @"caption";
return YES; // will bridge the image
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photo"
value:self
message:@"Must have an asset, image, or imageURL value."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"photo"
value:self
message:@"Must have an asset, image, or imageURL value."];
}
return NO;
}
@@ -20,16 +20,21 @@
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
@class FBSDKSharePhoto;
/**
A model for photo content to be shared.
*/
NS_SWIFT_NAME(SharePhotoContent)
@interface FBSDKSharePhotoContent : NSObject <FBSDKSharingContent>
/**
Photos to be shared.
@return Array of the photos (FBSDKSharePhoto)
*/
@property (nonatomic, copy) NSArray *photos;
@property (nonatomic, copy) NSArray<FBSDKSharePhoto *> *photos;
/**
Compares the receiver to another photo content.
@@ -39,3 +44,5 @@
- (BOOL)isEqualToSharePhotoContent:(FBSDKSharePhotoContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -20,7 +20,11 @@
#import <Photos/Photos.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKHashtag.h"
#import "FBSDKSharePhoto.h"
#import "FBSDKShareUtility.h"
@@ -77,12 +81,6 @@
#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
{
@@ -120,9 +118,9 @@
}
}
if (images.count > 0) {
[FBSDKInternalUtility dictionary:updatedParameters
setObject:images
forKey:@"photos"];
[FBSDKBasicUtility dictionary:updatedParameters
setObject:images
forKey:@"photos"];
}
return updatedParameters;
@@ -20,15 +20,19 @@
#import <UIKit/UIKit.h>
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKShareMediaContent.h>
#import <FBSDKShareKit/FBSDKSharingValidation.h>
NS_ASSUME_NONNULL_BEGIN
@class FBSDKSharePhoto;
@class PHAsset;
/**
A video for sharing.
*/
@interface FBSDKShareVideo : NSObject <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
NS_SWIFT_NAME(ShareVideo)
@interface FBSDKShareVideo : NSObject <NSSecureCoding, FBSDKCopying, FBSDKShareMedia, FBSDKSharingValidation>
/**
Convenience method to build a new video object from raw data.
@@ -73,25 +77,25 @@
The raw video data.
- Returns: The video data.
*/
@property (nonatomic, strong) NSData *data;
@property (nonatomic, strong, nullable) NSData *data;
/**
The representation of the video in the Photos library.
@return PHAsset that represents the video in the Photos library.
*/
@property (nonatomic, copy) PHAsset *videoAsset;
@property (nonatomic, copy, nullable) PHAsset *videoAsset;
/**
The file URL to the video.
@return URL that points to the location of the video on disk
*/
@property (nonatomic, copy) NSURL *videoURL;
@property (nonatomic, copy, nullable) NSURL *videoURL;
/**
The photo that represents the video.
@return The photo
*/
@property (nonatomic, copy) FBSDKSharePhoto *previewPhoto;
@property (nonatomic, copy, nullable) FBSDKSharePhoto *previewPhoto;
/**
Compares the receiver to another video.
@@ -107,3 +111,5 @@
@property (nonatomic, copy, readonly) NSURL *videoURL;
@end
NS_ASSUME_NONNULL_END
@@ -18,7 +18,11 @@
#import "FBSDKShareVideo.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareConstants.h"
#import "FBSDKSharePhoto.h"
#import "FBSDKShareUtility.h"
@@ -148,10 +152,10 @@ NSString *const kFBSDKShareVideoURLKey = @"videoURL";
}
}
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"data"
value:data
message:@"Cannot share video data."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"data"
value:data
message:@"Cannot share video data."];
}
return NO;
}
@@ -169,10 +173,10 @@ NSString *const kFBSDKShareVideoURLKey = @"videoURL";
}
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"videoAsset"
value:videoAsset
message:@"Must refer to a video file."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"videoAsset"
value:videoAsset
message:@"Must refer to a video file."];
}
return NO;
}
@@ -194,10 +198,10 @@ NSString *const kFBSDKShareVideoURLKey = @"videoURL";
}
}
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:kFBSDKShareVideoURLKey
value:videoURL
message:@"Must refer to an asset file."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:kFBSDKShareVideoURLKey
value:videoURL
message:@"Must refer to an asset file."];
}
return NO;
}
@@ -214,10 +218,10 @@ NSString *const kFBSDKShareVideoURLKey = @"videoURL";
return [self _validateVideoURL:_videoURL withOptions:bridgeOptions error:errorRef];
} else {
if ((errorRef != NULL) && !*errorRef) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"video"
value:self
message:@"Must have an asset, data, or videoURL value."];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"video"
value:self
message:@"Must have an asset, data, or videoURL value."];
}
return NO;
}
@@ -22,18 +22,14 @@
#import <FBSDKShareKit/FBSDKShareVideo.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
A model for video content to be shared.
*/
NS_SWIFT_NAME(ShareVideoContent)
@interface FBSDKShareVideoContent : NSObject <FBSDKSharingContent>
/**
The photo that represents the video.
@return The photo
*/
@property (nonatomic, copy) FBSDKSharePhoto *previewPhoto
DEPRECATED_MSG_ATTRIBUTE("Use `video.previewPhoto`");
/**
The video to be shared.
@return The video
@@ -48,3 +44,5 @@ DEPRECATED_MSG_ATTRIBUTE("Use `video.previewPhoto`");
- (BOOL)isEqualToShareVideoContent:(FBSDKShareVideoContent *)content;
@end
NS_ASSUME_NONNULL_END
@@ -20,7 +20,11 @@
#import <Photos/Photos.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKHashtag.h"
#import "FBSDKShareUtility.h"
@@ -69,12 +73,6 @@
#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
{
@@ -84,45 +82,48 @@
if (_video.videoAsset) {
if (bridgeOptions & FBSDKShareBridgeOptionsVideoAsset) {
// bridge the PHAsset.localIdentifier
[FBSDKInternalUtility dictionary:videoParameters
setObject:_video.videoAsset.localIdentifier
forKey:@"assetIdentifier"];
[FBSDKBasicUtility dictionary:videoParameters
setObject:_video.videoAsset.localIdentifier
forKey:@"assetIdentifier"];
} else {
// bridge the legacy "assets-library" URL from AVAsset
[FBSDKInternalUtility dictionary:videoParameters
setObject:_video.videoAsset.videoURL
forKey:@"assetURL"];
[FBSDKBasicUtility dictionary:videoParameters
setObject:_video.videoAsset.videoURL
forKey:@"assetURL"];
}
} else if (_video.data) {
if (bridgeOptions & FBSDKShareBridgeOptionsVideoData) {
// bridge the data
[FBSDKInternalUtility dictionary:videoParameters
setObject:_video.data
forKey:@"data"];
[FBSDKBasicUtility dictionary:videoParameters
setObject:_video.data
forKey:@"data"];
}
} else if (_video.videoURL) {
if ([_video.videoURL.scheme.lowercaseString isEqualToString:@"assets-library"]) {
// bridge the legacy "assets-library" URL
[FBSDKInternalUtility dictionary:videoParameters
setObject:_video.videoURL
forKey:@"assetURL"];
[FBSDKBasicUtility dictionary:videoParameters
setObject:_video.videoURL
forKey:@"assetURL"];
} else if (_video.videoURL.isFileURL) {
if (bridgeOptions & FBSDKShareBridgeOptionsVideoData) {
// load the contents of the file and bridge the data
NSData *data = [NSData dataWithContentsOfURL:_video.videoURL options:NSDataReadingMappedIfSafe error:NULL];
[FBSDKInternalUtility dictionary:videoParameters
setObject:data
forKey:@"data"];
[FBSDKBasicUtility dictionary:videoParameters
setObject:data
forKey:@"data"];
}
}
}
[FBSDKInternalUtility dictionary:videoParameters
setObject:[FBSDKShareUtility convertPhoto:_previewPhoto]
forKey:@"previewPhoto"];
[FBSDKInternalUtility dictionary:updatedParameters
setObject:videoParameters
forKey:@"video"];
if (_video.previewPhoto) {
[FBSDKBasicUtility dictionary:videoParameters
setObject:[FBSDKShareUtility convertPhoto:_video.previewPhoto]
forKey:@"previewPhoto"];
}
[FBSDKBasicUtility dictionary:updatedParameters
setObject:videoParameters
forKey:@"video"];
return updatedParameters;
}
@@ -146,7 +147,6 @@
_hashtag.hash,
_peopleIDs.hash,
_placeID.hash,
_previewPhoto.hash,
_ref.hash,
_pageID.hash,
_video.hash,
@@ -173,10 +173,6 @@
[FBSDKInternalUtility object:_hashtag isEqualToObject:content.hashtag] &&
[FBSDKInternalUtility object:_peopleIDs isEqualToObject:content.peopleIDs] &&
[FBSDKInternalUtility object:_placeID isEqualToObject:content.placeID] &&
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[FBSDKInternalUtility object:_previewPhoto isEqualToObject:content.previewPhoto] &&
#pragma clang diagnostic pop
[FBSDKInternalUtility object:_ref isEqualToObject:content.ref] &&
[FBSDKInternalUtility object:_pageID isEqualToObject:content.pageID] &&
[FBSDKInternalUtility object:_shareUUID isEqualToObject:content.shareUUID] &&
@@ -197,8 +193,6 @@
_hashtag = [decoder decodeObjectOfClass:[FBSDKHashtag class] forKey:FBSDK_SHARE_VIDEO_CONTENT_HASHTAG_KEY];
_peopleIDs = [decoder decodeObjectOfClass:[NSArray class] forKey:FBSDK_SHARE_VIDEO_CONTENT_PEOPLE_IDS_KEY];
_placeID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_VIDEO_CONTENT_PLACE_ID_KEY];
_previewPhoto = [decoder decodeObjectOfClass:[FBSDKSharePhoto class]
forKey:FBSDK_SHARE_VIDEO_CONTENT_PREVIEW_PHOTO_KEY];
_ref = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_VIDEO_CONTENT_REF_KEY];
_pageID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SHARE_VIDEO_CONTENT_PAGE_ID_KEY];
_video = [decoder decodeObjectOfClass:[FBSDKShareVideo class] forKey:FBSDK_SHARE_VIDEO_CONTENT_VIDEO_KEY];
@@ -213,7 +207,6 @@
[encoder encodeObject:_hashtag forKey:FBSDK_SHARE_VIDEO_CONTENT_HASHTAG_KEY];
[encoder encodeObject:_peopleIDs forKey:FBSDK_SHARE_VIDEO_CONTENT_PEOPLE_IDS_KEY];
[encoder encodeObject:_placeID forKey:FBSDK_SHARE_VIDEO_CONTENT_PLACE_ID_KEY];
[encoder encodeObject:_previewPhoto forKey:FBSDK_SHARE_VIDEO_CONTENT_PREVIEW_PHOTO_KEY];
[encoder encodeObject:_ref forKey:FBSDK_SHARE_VIDEO_CONTENT_REF_KEY];
[encoder encodeObject:_pageID forKey:FBSDK_SHARE_VIDEO_CONTENT_PAGE_ID_KEY];
[encoder encodeObject:_video forKey:FBSDK_SHARE_VIDEO_CONTENT_VIDEO_KEY];
@@ -229,7 +222,6 @@
copy->_hashtag = [_hashtag copy];
copy->_peopleIDs = [_peopleIDs copy];
copy->_placeID = [_placeID copy];
copy->_previewPhoto = [_previewPhoto copy];
copy->_ref = [_ref copy];
copy->_pageID = [_pageID copy];
copy->_video = [_video copy];
@@ -20,6 +20,8 @@
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
@protocol FBSDKSharingDelegate;
/**
@@ -31,6 +33,7 @@
@see FBSDKShareAPI
*/
NS_SWIFT_NAME(Sharing)
@protocol FBSDKSharing <NSObject>
/**
@@ -63,6 +66,7 @@
/**
The common interface for dialogs that initiate sharing.
*/
NS_SWIFT_NAME(SharingDialog)
@protocol FBSDKSharingDialog <FBSDKSharing>
/**
@@ -92,6 +96,7 @@
receive the information. For example, if the person is not signed into the containing app, the sharer may not be able
to distinguish between completion of a share and cancellation.
*/
NS_SWIFT_NAME(SharingDelegate)
@protocol FBSDKSharingDelegate <NSObject>
/**
@@ -99,7 +104,7 @@
@param sharer The FBSDKSharing that completed.
@param results The results from the sharer. This may be nil or empty.
*/
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results;
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary<NSString *, id> *)results;
/**
Sent to the delegate when the sharer encounters an error.
@@ -115,3 +120,5 @@
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer;
@end
NS_ASSUME_NONNULL_END
@@ -20,6 +20,8 @@
#import <FBSDKShareKit/FBSDKSharingContent.h>
NS_ASSUME_NONNULL_BEGIN
/**
The common interface for sharing buttons.
@@ -27,11 +29,14 @@
@see FBSDKShareButton
*/
NS_SWIFT_NAME(SharingButton)
@protocol FBSDKSharingButton <NSObject>
/**
The content to be shared.
*/
@property (nonatomic, copy) id<FBSDKSharingContent> shareContent;
@property (nonatomic, copy, nullable) id<FBSDKSharingContent> shareContent;
@end
NS_ASSUME_NONNULL_END
@@ -21,11 +21,14 @@
#import <FBSDKCoreKit/FBSDKCopying.h>
#import <FBSDKShareKit/FBSDKSharingValidation.h>
NS_ASSUME_NONNULL_BEGIN
@class FBSDKHashtag;
/**
A base interface for content to be shared.
*/
NS_SWIFT_NAME(SharingContent)
@protocol FBSDKSharingContent <FBSDKCopying, FBSDKSharingValidation, NSSecureCoding>
/**
@@ -41,7 +44,7 @@
Hashtag for the content being shared.
@return The hashtag for the content being shared.
*/
@property (nonatomic, copy) FBSDKHashtag *hashtag;
@property (nonatomic, copy, nullable) FBSDKHashtag *hashtag;
/**
List of IDs for taggable people to tag with this content.
@@ -49,31 +52,31 @@
(https://developers.facebook.com/docs/graph-api/reference/user/taggable_friends)
@return Array of IDs for people to tag (NSString)
*/
@property (nonatomic, copy) NSArray *peopleIDs;
@property (nonatomic, copy) NSArray<NSString *> *peopleIDs;
/**
The ID for a place to tag with this content.
@return The ID for the place to tag
*/
@property (nonatomic, copy) NSString *placeID;
@property (nonatomic, copy, nullable) NSString *placeID;
/**
A value to be added to the referrer URL when a person follows a link from this shared content on feed.
@return The ref for the content.
*/
@property (nonatomic, copy) NSString *ref;
@property (nonatomic, copy, nullable) NSString *ref;
/**
For shares into Messenger, this pageID will be used to map the app to page and attach attribution to the share.
@return The ID of the Facebok page this share is associated with.
@return The ID of the Facebook page this share is associated with.
*/
@property (nonatomic, copy) NSString *pageID;
@property (nonatomic, copy, nullable) NSString *pageID;
/**
A unique identifier for a share involving this content, useful for tracking purposes.
@return A unique string identifying this share data.
*/
@property (nonatomic, copy, readonly) NSString *shareUUID;
@property (nonatomic, copy, readonly, nullable) NSString *shareUUID;
/**
Adds content to an existing dictionary as key/value pairs and returns the
@@ -83,16 +86,9 @@
@return A new dictionary with the modified contents
*/
- (NSDictionary<NSString *, id> *)addParameters:(NSDictionary<NSString *, id> *)existingParameters
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions;
/**
Adds content to a dictionary as key/value pairs.
@param parameters A mutable dictionary that may be appended with key/value pairs of content.
@param bridgeOptions The options for bridging
*/
- (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
DEPRECATED_MSG_ATTRIBUTE("`addToParameters` is deprecated. Use `addParameters`");
bridgeOptions:(FBSDKShareBridgeOptions)bridgeOptions
NS_SWIFT_NAME(addParameters(_:options:));
@end
NS_ASSUME_NONNULL_END
@@ -18,16 +18,21 @@
#import "FBSDKShareDialogMode.h"
NS_ASSUME_NONNULL_BEGIN
/**
A base interface for indicating a custom URL scheme
*/
NS_SWIFT_NAME(SharingScheme)
@protocol FBSDKSharingScheme
/**
Asks the receiver to provide a custom scheme.
- Parameter mode: The intended dialog mode for sharing the content.
- Returns: A custom URL scheme to use for the specified mode, or nil.
@param mode The intended dialog mode for sharing the content.
@return A custom URL scheme to use for the specified mode, or nil.
*/
- (nullable NSString *)schemeForMode:(FBSDKShareDialogMode)mode;
@end
NS_ASSUME_NONNULL_END
@@ -18,6 +18,8 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
Flags to indicate support for newer bridge options beyond the initial 20130410 implementation.
*/
@@ -29,11 +31,12 @@ typedef NS_OPTIONS(NSUInteger, FBSDKShareBridgeOptions)
FBSDKShareBridgeOptionsVideoAsset = 1 << 2,
FBSDKShareBridgeOptionsVideoData = 1 << 3,
FBSDKShareBridgeOptionsWebHashtag = 1 << 4, // if set, pass the hashtag as a string value, not an array of one string
};
} NS_SWIFT_NAME(ShareBridgeOptions);
/**
A base interface for validation of content and media.
*/
NS_SWIFT_NAME(SharingValidation)
@protocol FBSDKSharingValidation
/**
@@ -44,3 +47,5 @@ typedef NS_OPTIONS(NSUInteger, FBSDKShareBridgeOptions)
- (BOOL)validateWithOptions:(FBSDKShareBridgeOptions)bridgeOptions error:(NSError *__autoreleasing *)errorRef;
@end
NS_ASSUME_NONNULL_END
@@ -20,6 +20,6 @@
@interface FBSDKCameraEffectArguments ()
- (NSDictionary *)allArguments;
- (NSDictionary<NSString *, id> *)allArguments;
@end
@@ -18,8 +18,13 @@
#import <UIKit/UIKit.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
NS_SWIFT_NAME(CheckmarkIcon)
@interface FBSDKCheckmarkIcon : FBSDKIcon
@end
@@ -18,6 +18,7 @@
#import <Foundation/Foundation.h>
NS_SWIFT_NAME(GameRequestFrictionlessRecipientCache)
@interface FBSDKGameRequestFrictionlessRecipientCache : NSObject
- (BOOL)recipientsAreFrictionless:(id)recipients;
@@ -20,7 +20,11 @@
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
@implementation FBSDKGameRequestFrictionlessRecipientCache
{
@@ -37,6 +37,7 @@ FOUNDATION_EXPORT NSString *const FBSDKLikeActionControllerDidUpdateNotification
FOUNDATION_EXPORT NSString *const FBSDKLikeActionControllerAnimatedKey;
NS_SWIFT_NAME(LikeActionController)
@interface FBSDKLikeActionController : NSObject <NSDiscardableContent, NSSecureCoding>
+ (BOOL)isDisabled;
@@ -52,6 +53,5 @@ FOUNDATION_EXPORT NSString *const FBSDKLikeActionControllerAnimatedKey;
@property (nonatomic, copy, readonly) NSString *socialSentence;
- (void)refresh;
- (void)toggleLikeWithSoundEnabled:(BOOL)soundEnabled analyticsParameters:(NSDictionary *)analyticsParameters fromViewController:(UIViewController *)fromViewController;
@end
@@ -22,9 +22,12 @@
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKLikeActionControllerCache.h"
#import "FBSDKLikeButtonPopWAV.h"
#import "FBSDKLikeDialog.h"
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
@@ -306,69 +309,6 @@ static FBSDKLikeActionControllerCache *_cache = nil;
[self _refreshWithMode:FBSDKLikeActionControllerRefreshModeForce];
}
- (void)toggleLikeWithSoundEnabled:(BOOL)soundEnabled analyticsParameters:(NSDictionary *)analyticsParameters fromViewController:(UIViewController *)fromViewController
{
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKLikeControlDidTap
valueToSum:nil
parameters:analyticsParameters
accessToken:_accessToken];
[self _setExecuting:YES forKey:FBSDK_LIKE_ACTION_CONTROLLER_LIKE_PROPERTY_KEY];
BOOL useOGLike = [self _useOGLike];
BOOL deferred = !useOGLike;
fbsdk_like_action_block updateBlock = ^(FBSDKTriStateBOOL objectIsLiked,
NSString *likeCountStringWithLike,
NSString *likeCountStringWithoutLike,
NSString *socialSentenceWithLike,
NSString *socialSentenceWithoutLike,
NSString *unlikeToken,
BOOL likeStateChanged,
BOOL animated){
[self _updateWithObjectIsLiked:objectIsLiked
likeCountStringWithLike:likeCountStringWithLike
likeCountStringWithoutLike:likeCountStringWithoutLike
socialSentenceWithLike:socialSentenceWithLike
socialSentenceWithoutLike:socialSentenceWithoutLike
unlikeToken:unlikeToken
soundEnabled:soundEnabled && likeStateChanged
animated:animated && likeStateChanged
deferred:deferred];
};
BOOL objectIsLiked = !_objectIsLiked;
// optimistically update if using og.like (FAS will defer the update)
if (useOGLike) {
updateBlock(FBSDKTriStateBOOLFromBOOL(objectIsLiked),
_likeCountStringWithLike,
_likeCountStringWithoutLike,
_socialSentenceWithLike,
_socialSentenceWithoutLike,
_unlikeToken,
YES,
YES);
if (_objectIsLikedIsPending) {
return;
}
}
if (objectIsLiked) {
if (useOGLike) {
[self _publishLikeWithUpdateBlock:updateBlock analyticsParameters:analyticsParameters fromViewController:fromViewController];
} else {
[self _presentLikeDialogWithUpdateBlock:updateBlock analyticsParameters:analyticsParameters fromViewController:fromViewController];
}
} else {
if (useOGLike && _unlikeToken) {
[self _publishUnlikeWithUpdateBlock:updateBlock analyticsParameters:analyticsParameters fromViewController:fromViewController];
} else {
[self _presentLikeDialogWithUpdateBlock:updateBlock analyticsParameters:analyticsParameters fromViewController:fromViewController];
}
}
}
#pragma mark - NSDiscardableContent
- (BOOL)beginContentAccess
@@ -429,9 +369,9 @@ static FBSDKLikeActionControllerCache *_cache = nil;
if ([error.userInfo[@"error_reason"] isEqualToString:@"dialog_disabled"]) {
_fbsdkLikeActionControllerDisabled = YES;
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKLikeControlDidDisable
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKLikeControlDidDisable
parameters:[_dialogToAnalyticsParametersMap objectForKey:likeDialog]
isImplicitlyLogged:YES
accessToken:_accessToken];
[[NSNotificationCenter defaultCenter] postNotificationName:FBSDKLikeActionControllerDidDisableNotification
@@ -469,12 +409,12 @@ static void FBSDKLikeActionControllerLogError(NSString *currentAction,
@"current_action": currentAction,
@"error": error.description ?: @"",
};
NSString *eventName = (error.isNetworkError ?
NSString *eventName = ([FBSDKError isNetworkError:error] ?
FBSDKAppEventNameFBSDKLikeControlNetworkUnavailable :
FBSDKAppEventNameFBSDKLikeControlError);
[FBSDKAppEvents logImplicitEvent:eventName
valueToSum:nil
[FBSDKAppEvents logInternalEvent:eventName
parameters:parameters
isImplicitlyLogged:YES
accessToken:accessToken];
}
@@ -672,7 +612,7 @@ static void FBSDKLikeActionControllerAddPublishUnlikeRequest(FBSDKAccessToken *a
fbsdk_like_action_controller_publish_unlike_completion_block completionHandler)
{
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:unlikeToken
parameters:nil
parameters:@{}
tokenString:accessToken.tokenString
version:nil
HTTPMethod:@"DELETE"];
@@ -797,9 +737,9 @@ static void FBSDKLikeActionControllerAddRefreshRequests(FBSDKAccessToken *access
analyticsParameters:(NSDictionary *)analyticsParameters
fromViewController:(UIViewController *)fromViewController
{
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKLikeControlDidPresentDialog
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKLikeControlDidPresentDialog
parameters:analyticsParameters
isImplicitlyLogged:YES
accessToken:_accessToken];
FBSDKLikeDialog *dialog = [[FBSDKLikeDialog alloc] init];
dialog.objectID = _objectID;
@@ -839,9 +779,9 @@ static void FBSDKLikeActionControllerAddRefreshRequests(FBSDKAccessToken *access
NSString *unlikeToken) {
self->_objectIsLikedIsPending = NO;
if (success) {
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKLikeControlDidLike
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKLikeControlDidLike
parameters:analyticsParameters
isImplicitlyLogged:YES
accessToken:self->_accessToken];
self->_objectIsLikedOnServer = YES;
self->_unlikeToken = [unlikeToken copy];
@@ -879,9 +819,9 @@ static void FBSDKLikeActionControllerAddRefreshRequests(FBSDKAccessToken *access
fbsdk_like_action_controller_publish_unlike_completion_block completionHandler = ^(BOOL success) {
self->_objectIsLikedIsPending = NO;
if (success) {
[FBSDKAppEvents logImplicitEvent:FBSDKAppEventNameFBSDKLikeControlDidUnlike
valueToSum:nil
[FBSDKAppEvents logInternalEvent:FBSDKAppEventNameFBSDKLikeControlDidUnlike
parameters:analyticsParameters
isImplicitlyLogged:YES
accessToken:self->_accessToken];
self->_objectIsLikedOnServer = NO;
self->_unlikeToken = nil;
@@ -956,7 +896,6 @@ static void FBSDKLikeActionControllerAddRefreshRequests(FBSDKAccessToken *access
socialSentenceWithLike:socialSentenceWithLike
socialSentenceWithoutLike:socialSentenceWithoutLike
unlikeToken:unlikeToken
soundEnabled:NO
animated:NO
deferred:NO];
[self _setExecuting:NO forKey:FBSDK_LIKE_ACTION_CONTROLLER_REFRESH_PROPERTY_KEY];
@@ -994,7 +933,6 @@ static void FBSDKLikeActionControllerAddRefreshRequests(FBSDKAccessToken *access
socialSentenceWithLike:(NSString *)socialSentenceWithLike
socialSentenceWithoutLike:(NSString *)socialSentenceWithoutLike
unlikeToken:(NSString *)unlikeToken
soundEnabled:(BOOL)soundEnabled
animated:(BOOL)animated
deferred:(BOOL)deferred
{
@@ -1040,16 +978,7 @@ static void FBSDKLikeActionControllerAddRefreshRequests(FBSDKAccessToken *access
self->_unlikeToken = [unlikeToken copy];
}
// if only meta data changed, don't play the sound
FBSDKLikeButtonPopWAV *likeSound = (objectIsLikedChanged && objectIsLiked && soundEnabled ? [FBSDKLikeButtonPopWAV sharedLoader] : nil);
void(^notificationBlock)(void) = ^{
if (likeSound) {
dispatch_time_t soundPopTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FBSDK_LIKE_ACTION_CONTROLLER_SOUND_DELAY * NSEC_PER_SEC));
dispatch_after(soundPopTime, dispatch_get_main_queue(), ^(void){
[likeSound playSound];
});
}
NSDictionary *userInfo = @{FBSDKLikeActionControllerAnimatedKey: @(animated)};
[[NSNotificationCenter defaultCenter] postNotificationName:FBSDKLikeActionControllerDidUpdateNotification
object:self
@@ -18,6 +18,7 @@
#import <Foundation/Foundation.h>
NS_SWIFT_NAME(LikeActionControllerCache)
@interface FBSDKLikeActionControllerCache : NSObject <NSSecureCoding>
- (instancetype)init NS_UNAVAILABLE;
@@ -20,6 +20,7 @@
#import "FBSDKLikeBoxView.h"
NS_SWIFT_NAME(FBLikeBoxBorderView)
@interface FBSDKLikeBoxBorderView : UIView
@property (nonatomic, assign) CGFloat borderCornerRadius;
@@ -18,7 +18,11 @@
#import "FBSDKLikeBoxBorderView.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#define FBSDK_LIKE_BOX_BORDER_CARET_WIDTH 6.0
#define FBSDK_LIKE_BOX_BORDER_CARET_HEIGHT 3.0
@@ -33,8 +33,9 @@ typedef NS_ENUM(NSUInteger, FBSDKLikeBoxCaretPosition)
FBSDKLikeBoxCaretPositionBottom,
/** The caret is on the right of the box. */
FBSDKLikeBoxCaretPositionRight,
};
} NS_SWIFT_NAME(LikeBoxCaretPosition);
NS_SWIFT_NAME(FBLikeBoxView)
@interface FBSDKLikeBoxView : UIView
@property (nonatomic, assign) FBSDKLikeBoxCaretPosition caretPosition;
@@ -18,7 +18,11 @@
#import "FBSDKLikeBoxView.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKLikeBoxBorderView.h"
@implementation FBSDKLikeBoxView
@@ -18,7 +18,8 @@
#import <Foundation/Foundation.h>
#import "FBSDKCoreKit+Internal.h"
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#import "FBSDKLikeActionController.h"
#import "FBSDKLikeButton.h"
@@ -1,24 +0,0 @@
// 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+Internal.h"
@interface FBSDKLikeButtonPopWAV : FBSDKAudioResourceLoader
@end
@@ -1,36 +0,0 @@
// 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 "FBSDKLikeButtonPopWAV.h"
@implementation FBSDKLikeButtonPopWAV
+ (NSString *)name
{
return @"FBSDKLikeButtonPop.wav";
}
+ (NSData *)data
{
const Byte bytes[] = {
0x52, 0x49, 0x46, 0x46, 0xfc, 0x57, 0x02, 0x00, 0x57, 0x41, 0x56, 0x45, 0x4a, 0x55, 0x4e, 0x4b, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x65, 0x78, 0x74, 0x5a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x72, 0x6f, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x68, 0x72, 0x72, 0x48, 0x37, 0x38, 0x21, 0x54, 0x66, 0x61, 0x61, 0x61, 0x61, 0x47, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x30, 0x31, 0x34, 0x2d, 0x30, 0x31, 0x2d, 0x31, 0x00, 0x31, 0x35, 0x3a, 0x32, 0x38, 0x3a, 0x30, 0x31, 0xf7, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6d, 0x74, 0x20, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x80, 0xbb, 0x00, 0x00, 0x00, 0xee, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x69, 0x6e, 0x66, 0x10, 0x00, 0x00, 0x00, 0x70, 0xe2, 0xe6, 0xc4, 0xdb, 0x13, 0xcf, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x6c, 0x6d, 0x31, 0xd6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0Line truncated
NSUInteger length = sizeof(bytes) / sizeof(Byte);
return [NSData dataWithBytesNoCopy:(void *)bytes length:length freeWhenDone:NO];
}
@end
@@ -1,27 +0,0 @@
// 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 "FBSDKLikeControl.h"
@interface FBSDKLikeControl ()
- (NSDictionary *)analyticsParameters;
@end
@@ -23,6 +23,7 @@
@protocol FBSDKLikeDialogDelegate;
NS_SWIFT_NAME(LikeDialog)
@interface FBSDKLikeDialog : NSObject
+ (instancetype)likeWithObjectID:(NSString *)objectID
@@ -41,9 +42,10 @@
@end
NS_SWIFT_NAME(LikeDialogDelegate)
@protocol FBSDKLikeDialogDelegate <NSObject>
- (void)likeDialog:(FBSDKLikeDialog *)likeDialog didCompleteWithResults:(NSDictionary *)results;
- (void)likeDialog:(FBSDKLikeDialog *)likeDialog didCompleteWithResults:(NSDictionary<NSString *, id> *)results;
- (void)likeDialog:(FBSDKLikeDialog *)likeDialog didFailWithError:(NSError *)error;
@end
@@ -18,7 +18,11 @@
#import "FBSDKLikeDialog.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareConstants.h"
#import "FBSDKShareDefines.h"
@@ -61,9 +65,9 @@
{
NSError *error;
if (![self canLike]) {
error = [NSError fbErrorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Like dialog is not available."];
error = [FBSDKError errorWithDomain:FBSDKShareErrorDomain
code:FBSDKShareErrorDialogNotAvailable
message:@"Like dialog is not available."];
[_delegate likeDialog:self didFailWithError:error];
return NO;
}
@@ -73,17 +77,17 @@
}
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[FBSDKInternalUtility dictionary:parameters setObject:self.objectID forKey:@"object_id"];
[FBSDKInternalUtility dictionary:parameters
setObject:NSStringFromFBSDKLikeObjectType(self.objectType)
forKey:@"object_type"];
[FBSDKBasicUtility dictionary:parameters setObject:self.objectID forKey:@"object_id"];
[FBSDKBasicUtility dictionary:parameters
setObject:NSStringFromFBSDKLikeObjectType(self.objectType)
forKey:@"object_type"];
FBSDKBridgeAPIRequest * webRequest = [FBSDKBridgeAPIRequest bridgeAPIRequestWithProtocolType:FBSDKBridgeAPIProtocolTypeWeb
scheme:FBSDK_SHARE_JS_DIALOG_SCHEME
methodName:FBSDK_LIKE_METHOD_NAME
methodVersion:nil
parameters:parameters
userInfo:nil];
FBSDKBridgeAPICallbackBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
FBSDKBridgeAPIResponseBlock completionBlock = ^(FBSDKBridgeAPIResponse *response) {
[self _handleCompletionWithDialogResults:response.responseParameters error:response.error];
};
@@ -98,7 +102,7 @@
userInfo:nil];
void (^networkCompletionBlock)(FBSDKBridgeAPIResponse *) = ^(FBSDKBridgeAPIResponse *response) {
if (response.error.code == FBSDKErrorAppVersionUnsupported) {
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:webRequest
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:webRequest
useSafariViewController:useSafariViewController
fromViewController:self.fromViewController
completionBlock:completionBlock];
@@ -106,12 +110,12 @@
completionBlock(response);
}
};
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:nativeRequest
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:nativeRequest
useSafariViewController:useSafariViewController
fromViewController:self.fromViewController
completionBlock:networkCompletionBlock];
} else {
[[FBSDKApplicationDelegate sharedInstance] openBridgeAPIRequest:webRequest
[[FBSDKBridgeAPI sharedInstance] openBridgeAPIRequest:webRequest
useSafariViewController:useSafariViewController
fromViewController:self.fromViewController
completionBlock:completionBlock];
@@ -124,9 +128,9 @@
{
if (!self.objectID.length) {
if (errorRef != NULL) {
*errorRef = [NSError fbRequiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"objectID"
message:nil];
*errorRef = [FBSDKError requiredArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"objectID"
message:nil];
}
return NO;
}
@@ -18,8 +18,13 @@
#import <UIKit/UIKit.h>
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
NS_SWIFT_NAME(MessengerIcon)
@interface FBSDKMessengerIcon : FBSDKIcon
@end
@@ -1,26 +0,0 @@
// 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.h"
@interface FBSDKShareLinkContent ()
// Deprecated parameters for Feed Dialog - for usage with Unity only.
@property (nonatomic, copy) NSDictionary *feedParameters;
@end
@@ -17,24 +17,37 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#import <Foundation/Foundation.h>
#import <FBSDKShareKit/FBSDKShareConstants.h>
@class FBSDKShareMessengerURLActionButton;
@protocol FBSDKShareMessengerActionButton;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerTemplateTypeKey;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerTemplateKey;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerPayloadKey;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerTypeKey;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerAttachmentKey;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerElementsKey;
DEPRECATED_FOR_MESSENGER
FOUNDATION_EXPORT NSString *const kFBSDKShareMessengerButtonsKey;
DEPRECATED_FOR_MESSENGER
void AddToContentPreviewDictionaryForButton(NSMutableDictionary<NSString *, id> *dictionary,
id<FBSDKShareMessengerActionButton> button);
NSDictionary<NSString *, id> *SerializableButtonFromURLButton(FBSDKShareMessengerURLActionButton *button, BOOL isDefaultAction);
DEPRECATED_FOR_MESSENGER
NSArray<NSDictionary<NSString *, id> *> *SerializableButtonsFromButton(id<FBSDKShareMessengerActionButton> button);
DEPRECATED_FOR_MESSENGER
NS_SWIFT_NAME(ShareMessengerContentUtility)
@interface FBSDKShareMessengerContentUtility : NSObject
+ (void)addToParameters:(NSMutableDictionary<NSString *, id> *)parameters
@@ -18,7 +18,11 @@
#import "FBSDKShareMessengerContentUtility.h"
#ifdef COCOAPODS
#import <FBSDKCoreKit/FBSDKCoreKit+Internal.h>
#else
#import "FBSDKCoreKit+Internal.h"
#endif
#import "FBSDKShareConstants.h"
#import "FBSDKShareMessengerGenericTemplateContent.h"
#import "FBSDKShareMessengerGenericTemplateElement.h"
@@ -35,6 +39,7 @@ NSString *const kFBSDKShareMessengerAttachmentKey = @"attachment";
NSString *const kFBSDKShareMessengerElementsKey = @"elements";
NSString *const kFBSDKShareMessengerButtonsKey = @"buttons";
DEPRECATED_FOR_MESSENGER
static void _AddToContentPreviewDictionaryForURLButton(NSMutableDictionary<NSString *, id> *dictionary,
FBSDKShareMessengerURLActionButton *urlButton)
{
@@ -47,8 +52,8 @@ static void _AddToContentPreviewDictionaryForURLButton(NSMutableDictionary<NSStr
}
NSString *previewString = urlButton.title.length > 0 ? [NSString stringWithFormat:@"%@ - %@", urlButton.title, shortURLString] : shortURLString;
[FBSDKInternalUtility dictionary:dictionary setObject:previewString forKey:@"target_display"];
[FBSDKInternalUtility dictionary:dictionary setObject:urlButton.url.absoluteString forKey:@"item_url"];
[FBSDKBasicUtility dictionary:dictionary setObject:previewString forKey:@"target_display"];
[FBSDKBasicUtility dictionary:dictionary setObject:urlButton.url.absoluteString forKey:@"item_url"];
}
void AddToContentPreviewDictionaryForButton(NSMutableDictionary<NSString *, id> *dictionary,
@@ -59,7 +64,10 @@ void AddToContentPreviewDictionaryForButton(NSMutableDictionary<NSString *, id>
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FBSDKShareMessengerContentUtility
#pragma clang diagnostic pop
static NSString *_WebviewHeightRatioString(FBSDKShareMessengerURLActionButtonWebviewHeightRatio heightRatio) {
switch (heightRatio) {
@@ -82,15 +90,15 @@ NSDictionary<NSString *, id> *SerializableButtonFromURLButton(FBSDKShareMessenge
// Strip out title for default action
if (!isDefaultAction) {
[FBSDKInternalUtility dictionary:serializableButton setObject:button.title forKey:@"title"];
[FBSDKBasicUtility dictionary:serializableButton setObject:button.title forKey:@"title"];
}
[FBSDKInternalUtility dictionary:serializableButton setObject:@"web_url" forKey:@"type"];
[FBSDKInternalUtility dictionary:serializableButton setObject:button.url.absoluteString forKey:@"url"];
[FBSDKInternalUtility dictionary:serializableButton setObject:_WebviewHeightRatioString(button.webviewHeightRatio) forKey:@"webview_height_ratio"];
[FBSDKInternalUtility dictionary:serializableButton setObject:@(button.isMessengerExtensionURL) forKey:@"messenger_extensions"];
[FBSDKInternalUtility dictionary:serializableButton setObject:button.fallbackURL.absoluteString forKey:@"fallback_url"];
[FBSDKInternalUtility dictionary:serializableButton setObject:_WebviewShareButtonString(button.shouldHideWebviewShareButton) forKey:@"webview_share_button"];
[FBSDKBasicUtility dictionary:serializableButton setObject:@"web_url" forKey:@"type"];
[FBSDKBasicUtility dictionary:serializableButton setObject:button.url.absoluteString forKey:@"url"];
[FBSDKBasicUtility dictionary:serializableButton setObject:_WebviewHeightRatioString(button.webviewHeightRatio) forKey:@"webview_height_ratio"];
[FBSDKBasicUtility dictionary:serializableButton setObject:@(button.isMessengerExtensionURL) forKey:@"messenger_extensions"];
[FBSDKBasicUtility dictionary:serializableButton setObject:button.fallbackURL.absoluteString forKey:@"fallback_url"];
[FBSDKBasicUtility dictionary:serializableButton setObject:_WebviewShareButtonString(button.shouldHideWebviewShareButton) forKey:@"webview_share_button"];
return serializableButton;
}
@@ -99,7 +107,7 @@ NSArray<NSDictionary<NSString *, id> *> *SerializableButtonsFromButton(id<FBSDKS
// Return NSArray even though there is just one button to match proper json structure
NSMutableArray<NSDictionary<NSString *, id> *> *serializableButtons = [NSMutableArray array];
if ([button isKindOfClass:[FBSDKShareMessengerURLActionButton class]]) {
[FBSDKInternalUtility array:serializableButtons addObject:SerializableButtonFromURLButton(button, NO)];
[FBSDKBasicUtility array:serializableButtons addObject:SerializableButtonFromURLButton(button, NO)];
}
return serializableButtons;
@@ -115,9 +123,9 @@ NSArray<NSDictionary<NSString *, id> *> *SerializableButtonsFromButton(id<FBSDKS
NSString *contentForShareDataString = [[NSString alloc] initWithData:contentForShareData encoding:NSUTF8StringEncoding];
NSMutableDictionary<NSString *, id> *messengerShareContent = [NSMutableDictionary dictionary];
[FBSDKInternalUtility dictionary:messengerShareContent setObject:contentForShareDataString forKey:@"content_for_share"];
[FBSDKInternalUtility dictionary:messengerShareContent setObject:contentForPreview forKey:@"content_for_preview"];
[FBSDKInternalUtility dictionary:parameters setObject:messengerShareContent forKey:@"messenger_share_content"];
[FBSDKBasicUtility dictionary:messengerShareContent setObject:contentForShareDataString forKey:@"content_for_share"];
[FBSDKBasicUtility dictionary:messengerShareContent setObject:contentForPreview forKey:@"content_for_preview"];
[FBSDKBasicUtility dictionary:parameters setObject:messengerShareContent forKey:@"messenger_share_content"];
}
}
@@ -136,10 +144,10 @@ NSArray<NSDictionary<NSString *, id> *> *SerializableButtonsFromButton(id<FBSDKS
(urlActionButton.isMessengerExtensionURL ? [FBSDKShareUtility validateRequiredValue:pageID name:@"content pageID" error:errorRef] : YES);
} else {
if (errorRef != NULL) {
*errorRef = [NSError fbInvalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"buttons"
value:button
message:nil];
*errorRef = [FBSDKError invalidArgumentErrorWithDomain:FBSDKShareErrorDomain
name:@"buttons"
value:button
message:nil];
}
return NO;
}
@@ -22,8 +22,8 @@
@interface FBSDKShareOpenGraphValueContainer ()
- (NSDictionary *)allProperties;
@property (nonatomic, readonly) BOOL requireKeyNamespace;
- (BOOL)isEqualToShareOpenGraphValueContainer:(FBSDKShareOpenGraphValueContainer *)object;
- (BOOL)requireKeyNamespace;
@end
@@ -25,6 +25,13 @@
#import <FBSDKShareKit/FBSDKShareVideoContent.h>
#import <FBSDKShareKit/FBSDKSharingContent.h>
/**
Web Share Block
*/
typedef void (^FBSDKWebPhotoContentBlock)(BOOL, NSString *, NSDictionary<NSString *, id> *)
NS_SWIFT_NAME(WebPhotoContentBlock);
NS_SWIFT_NAME(ShareUtility)
@interface FBSDKShareUtility : NSObject
- (instancetype)init NS_UNAVAILABLE;
@@ -42,7 +49,7 @@
error:(NSError *__autoreleasing *)errorRef;
+ (NSString *)buildWebShareTags:(NSArray<NSString *> *)peopleIDs;
+ (void)buildAsyncWebPhotoContent:(FBSDKSharePhotoContent *)content
completionHandler:(void(^)(BOOL, NSString *, NSDictionary *))completion;
completionHandler:(FBSDKWebPhotoContentBlock)completion;
+ (id)convertOpenGraphValue:(id)value;
+ (NSDictionary<NSString *, id> *)convertOpenGraphValueContainer:(FBSDKShareOpenGraphValueContainer *)container
requireNamespace:(BOOL)requireNamespace;
Loaded 100 of 535 files, more files were not shown because too many files have changed in this diff. Show more