I am sharing my post on Facebook. I am sharing Image, Content URL, Description. I am using this code for sharing:
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = APP_NAME;
content.contentDescription = text;
content.imageURL = [NSURL URLWithString:[[arrAllEvents valueForKey:#"flyer_image"]objectAtIndex:0]];
content.contentURL = url;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeFeedWeb;
[dialog show];
I have enable Deep Linking (News Feed links launch this app) option for https://developers.facebook.com.
I have added my Fbid and URLShema Like this
<key>CFBundleURLSchemes</key>
<array>
<string>abcevent://</string>
<string>fb1......</string>
</array>
and add code in appdelegate.m for the same like this
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url,NSError *error){
if([[url scheme] isEqualToString:#"abcevent"])
{
[self callNewsletter:url];
}
}];
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[FBSDKAppEvents activateApp];
}
Now if I am sharing my post on fb via application. That post click is not opening my app in iPhone Deep linking is not working.
Can anyone tell what other things I am missing with this?
The fetchDeferredAppLink method only works with ads. It never worked with links shared organically on the News Feed. You can read about more limitations of deep linking from Facebook in this blog post, but there are two core things to know:
Facebook has never supported deferred deep linking for non-paid content.
Facebook's App Links standard at one point supported normal deep linking (meaning if the app is already installed), but this has been broken on iOS for a long time.
If you want this sort of functionality, you'll need a separate solution like Branch.io (full disclosure: I'm on the Branch team).
Related
I have been using code like this to share videos to Facebook:
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = assetURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = vc;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeShareSheet;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) { dialog.mode = FBSDKShareDialogModeAutomatic; }
}
[dialog show]
where the delegate conforms to FBSDKSharingDelegate and implements these methods to track the result:
-(void)sharer:(id<FBSDKSharing>)sharerdidCompleteWithResults:(NSDictionary*)results;
-(void)sharer:(id<FBSDKSharing>)sharerdidFailWithError:(NSError*)error;
-(void)sharerDidCancel:(id<FBSDKSharing>)sharer;
I observe these callbacks working on iOS 10 for FBSDKShareDialogModeShareSheet, but in an otherwise identical implementation they are not called when using other dialog modes (for example) FBSDKShareDialogModeNative. In iOS 11, it doesn't appear that the share sheet mode is available anymore (presumably due to the Social Framework changes).
I don't have Facebook login in my app (nor any login), nor do I do anything to request FB permissions other than expect the user to authenticate within the native FB app. Is it expected that these callbacks will not execute in these other dialog modes, or is there something special I should do to get it them to work in this case?
The FB docs state
The delegate is notified with the results of the sharer as long as the
application has permissions to 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.
We are obviously passing the user to the native Facebook app in which they are authenticated - I'm not sure why this would work for one dialog mode and not for another. I'd rather not have to request the user login, as the whole point is to use the native FB app and let FB manage their own business internally.
Any help would be much appreciated. Thank you!
I'm trying to share a link object to a Facebook group using the share dialog. No one seems to have answered this question satisfactorily yet.
The SDK documentation clearly states that you can use the share dialog to share to your own timeline or groups, yet I can't figure out how to do it. I also don't see any other apps that do it. Using the web share dialogue on a desktop you can see the option, but on a mobile website you don't! This screenshot of the iOS Facebook app shows what I'm talking about:
I'm trying to get the functionality in where it says 'tap to change' at the top.
It appears you have to use an instance of FBSDKShareDialog, and set the mode to FBSDKShareDialogModeNative.
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = viewController;
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://www.test.com"];
content.contentTitle = productItem.productTitle;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeWeb;
}
dialog.delegate = self;
[dialog show];
Google plus SDK has been integrated in one of my apps for sharing the app content.
For this user has to login into Google plus account on the app and then use this sharing feature.
But, in the Google developer site it says that Google Plus login is deprecated and we need to implement Google login instead of Google Plus login.
I am not using Google Plus just for a login functionality.
So, what should i do now?
There's a GoogleSignIn SDK: https://developers.google.com/identity/sign-in/ios/start-integrating.
If you are just interested in sharing you should probably be using the SFSafariViewController to present the share dialog box in a webview:
- (void)showGooglePlusShare:(NSURL*)shareURL {
// Construct the Google+ share URL
NSURLComponents* urlComponents = [[NSURLComponents alloc]
initWithString:#"https://plus.google.com/share"];
urlComponents.queryItems = #[[[NSURLQueryItem alloc]
initWithName:#"url"
value:[shareURL absoluteString]]];
NSURL* url = [urlComponents URL];
if ([SFSafariViewController class]) {
// Open the URL in SFSafariViewController (iOS 9+)
SFSafariViewController* controller = [[SFSafariViewController alloc]
initWithURL:url];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
} else {
// Open the URL in the device's browser
[[UIApplication sharedApplication] openURL:url];
}
}
I have to share text, url and image in Google plus from iOS app. Google plus sign in is deprecated and only basic sharing with text+url is available which is same as native iOS G + share. But I want to share image, url, etc., from my iOS app. Is any other way is possible to share media with text in Google plus now.
The Google share link supports two url paramaters: url for the target url, and hl for a language code.
- (void)showGooglePlusShare:(NSURL*)shareURL {
// Construct the Google+ share URL
NSURLComponents* urlComponents = [[NSURLComponents alloc]
initWithString:#"https://plus.google.com/share"];
urlComponents.queryItems = #[[[NSURLQueryItem alloc]
initWithName:#"url"
value:[shareURL absoluteString]]];
NSURL* url = [urlComponents URL];
if ([SFSafariViewController class]) {
// Open the URL in SFSafariViewController (iOS 9+)
SFSafariViewController* controller = [[SFSafariViewController alloc]
initWithURL:url];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
} else {
// Open the URL in the device's browser
[[UIApplication sharedApplication] openURL:url];
}
}
I'm trying to integrate the new Facebook SDK into an app I'm working on and for some reason whenever I try and share a link the share screen doesn't come up. I get kicked to the Facebook app (or the web app if there's no Facebook app installed), but I never get an option to share the link I'm trying to get the user to post.
I've pretty much followed the example on the Facebook developer site to a T, but for reference, here's my code:
- (IBAction)shareToFacebook:(id)sender {
NSLog(#"Share to Facebook");
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentURL = [NSURL URLWithString:#"http://google.com"];
content.contentTitle = #"Test Post!";
content.contentDescription = #"Content Description;
FBSDKShareDialog *shareDialog = [FBSDKShareDialog new];
[shareDialog setMode:FBSDKShareDialogModeAutomatic];
[shareDialog setShareContent:content];
[shareDialog setFromViewController:self];
[shareDialog show];
// [FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];
}
As you can see above, I've tried using both the convenience method Facebook uses in their documentation, as well as being more verbose, but both produce the same result (opening the Facebook app but not giving the user an option to share any content). Any help at all would be greatly appreciated!
add to you code
[shareDialog setDelegate:self]
<FBSDKSharingDelegate> to your class
FBSDKSharing code
#pragma mark - FBSDKSharingDelegate
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults :(NSDictionary *)results {
NSLog(#"FB: SHARE RESULTS=%#\n",[results debugDescription]);
}
- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error {
NSLog(#"FB: ERROR=%#\n",[error debugDescription]);
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer {
NSLog(#"FB: CANCELED SHARER=%#\n",[sharer debugDescription]);
}
set break point in the didFailWithError and You can see many interesting underlying errors descriptions.
This this example for share image from application to facebook with using swift
func shareWithFacebook(){
let share : FBSDKShareLinkContent = FBSDKShareLinkContent()
share.imageURL = NSURL(string: "image url")
share.contentTitle = "content description "
share.contentURL = NSURL(string: "https://www.example.com")
let dialog : FBSDKShareDialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = share
let facebookURL = NSURL(string: "fbauth2://app")
if(UIApplication.sharedApplication().canOpenURL(facebookURL!)){
dialog.mode = FBSDKShareDialogMode.Native
}else{
dialog.mode = FBSDKShareDialogMode.FeedWeb
}
dialog.show()
}
Don't forgot to add facebook framework
As it states in the FBSDKShareDialogMode.h:
#discussion The automatic mode will progressively check the availability of different modes and open the most
appropriate mode for the dialog that is available.
So just choose another Share Dialog Mode.
It actually turned out to be a small typo in my info.plist for the app. Just a heads up to anyone else getting a similar error to check over all the information they have setup there and be sure it's all correct.
I had this problem on only one iPhone whereas in other iPhones it worked fine. It turned out that the Facebook app in that device was outdated and hence the FBSDKShareDialog wasn't showing up. Once the Facebook app was updated to the latest version, the FBSDKShareDialog started working fine.
try to use this mode:
dialog.mode = FBSDKShareDialogModeFeedWeb
To share on Facebook through Native iOS app.
We need updated FB SDK installed in app.
I used Pods to installed.
link to get pod set up into Mac: https://cocoapods.org
Write pod file name in podfile :
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
or
manual installation please follow : https://developers.facebook.com/docs/sharing/ios
after successful installation of FB SDKs.
Write code on button action:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"https://AppLink"];
content.quote = #"Sample description of app";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
It will automatically handle Native or Web (if not installed.)