I successfully integrated Facebook SDK 3.1 in my app, and I'm trying to propose iOS6+ only features to iOS6+ users. I was able to show the share sheet, but I was quite disapointed when I saw what the post on my wall looked like. Here is an image to describe what I mean :
The first one is what is got from a pre-iOS6 dialog (the web popup), and the second one is got from the new iOS6+ Native Facebook Dialog (SLComposeViewController, in other words).
My questions are :
Is there a way to make the second post look like the first one using FacebookNativeDialog ? Is it possible to give a params Dictionary like before so the post will display correctly "via {myAppName}" ? Or is it simply the new way of showing posts, and the older way is deprecated ?
Two things:
1/ "via iOS" attribution - This is currently per design and cannot be customized for your app.
2/ Having the same look - you can get this by providing only the link when setting up the composer (i.e. don't provide the image):
SLComposeViewController *fbVC = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbVC setCompletionHandler:^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Canceled");
} else if (result == SLComposeViewControllerResultDone) {
NSLog(#"Posted");
}
}];
[fbVC addURL:[NSURL URLWithString:#"https://developers.facebook.com/ios"]];
[self presentViewController:fbVC animated:YES completion:nil];
The key to getting the same look is that the page linked to has Open Graph tags that Facebook can recognize to properly display the data. You can test if the OG tags are good by entering the link into https://developers.facebook.com/tools/debug
If the page does not have OG tags, the link will simply be displayed.
Related
I am trying to share something via the branch.io share sheet:
let shareText = "Some Share Text"
let linkProperties = BranchLinkProperties()
linkProperties.feature = "Some"
linkProperties.addControlParam("$desktop_url", withValue: desktopURLString)
linkProperties.addControlParam("$android_url", withValue: androidURLString)
let object = BranchUniversalObject(canonicalIdentifier: "some.cannonical.identifier")
object.title = "Some Title"
object.imageUrl = someImageURL
object.contentDescription = "Some Content Description"
object.addMetadataKey("some_id", value: identifier)
object.showShareSheet(with: linkProperties,
andShareText: shareText,
from: self,
completion: completion)
All works great, except that the Facebook Messenger app does not show as option in the share sheet. Neither in the suggested options nor under 'More'. What is needed to achieve that?
I found the following question / answer for the default UIActivityViewController. How does that work with branch.io though? Facebook Messenger not showing up with UIActivityViewController
When you share via a share sheet on iOS - whether you use the Branch share sheet or UIActivityViewController - the choice of sharing options is not yours to define, it is defined by the user.
The interface for setting which apps will appear on the list can be accessed by opening a Share Sheet and then scrolling through the list of presented apps until you see the "..." (More) option. Tap on this button and you will be presented with the list of apps that can be shared to on the phone:
Each app will have a slider - if the slider is enabled for a particular app, that app will appear in the list.
Enabling Facebook Messenger for sharing on a user's phone is not something you can do from within your app as a developer.
You mention that the Messenger app is not even available when you tap the More button. This strikes me as odd; every device I check does have Facebook Messenger as an option if it is installed. Perhaps try removing and reinstalling Facebook Messenger.
I dived into the issue once more and I finally found the trouble maker. If I set feature of the branch link properties to a string value containing a space, Messenger disappears in the share sheet. The example:
let properties = BranchLinkProperties()
properties.feature = "Share News" //does not work, messenger does not appear in the share sheet
//properties.feature = "Share_News" //works, messenger appears in share sheet
object.showShareSheet(with: properties, andShareText: "Some Share Text", from: viewController, anchor: UIBarButtonItem()) { (activityType, completed) in
if (completed) {
print(String(format: "Branch TestBed: Completed sharing to %#", activityType!))
} else {
print("Branch TestBed: Link Sharing Cancelled\n")
}
}
feature is used as a parameter in the URL in Branch which is then given to the sharing extension. While this, I think, is an encoding issue in Branch, it seems that the Messenger sharing extension is not handling the URL in the same way as other apps. The 'broken url' does work with other sharing extensions. Hope this helps someone else! I will change the name of my feature to something without space for now.
I have this simple piece of code to display a sharing dialog for a number of social avenues:
let text = String(format:NSLocalizedString("I %# with the Dhammapada verse \"%#\"", comment:"$ to be composed with $$"), part, verse)
let url = URL(string:"http://www.ipuja.net")
let image = buddhanetImage.image ?? UIImage(named:"Icon-72")
let shareController=UIActivityViewController(activityItems:[text, url!, image!], applicationActivities:nil)
shareController.excludedActivityTypes = [UIActivityTypeAssignToContact, UIActivityTypeAddToReadingList,UIActivityTypePostToVimeo];
if (UI_USER_INTERFACE_IDIOM() == .pad){
shareController.popoverPresentationController?.sourceView = self.buddhanetImage;
}
self.present(shareController, animated:true, completion:nil)
Yet the tool woks fine for Google and Twitter, but when I try to share the contents on Facebook, just the url is shown without either text of image.
I checked that doing the thing on Photos and other other third party apps allows to display the full content even for Facebook, so what is missing in my code for that to work?
The URL will override the text and image when sharing to Facebook from a third-party application. Remove the URL and the image and text will appear. Also, if you have multiple hashtags in your text, only the first hashtag will be applied.
Prior to iOS 9, prefilling the Facebook share dialog with text, image, and URL was possible. Once iOS 9 was released, prefilling any fields when sharing to Facebook was not possible at all. Sometime around iOS 9.3 they reenabled prefilling fields, but prefilling all the fields is not possible.
I know that by the title this question has been asked a lot, but with the new Facebook 4.0 sdk this is a problem.
I know that if i call
[self FCMSendOpenGraphRequestWithPath:#"me/friends" andCompletionHandler:^(BOOL seccess, id result, NSError *error) {
if (seccess) {
}
}else{
}
}];
I will get all the user's friends that are using my app and that fit into one paging page (i have noticed that one page can hold 25 friends).
My problem is what happens when i need to get the page 2,3,4..etc'?
I know that if i call the graph call with the 'next' field i will get the next page. But because the Facebook sdk uses only completionHandlers using recursion won't work, and i don't want to hard code all the method call obviously.
All advices will help,
Thanks
I have a NSString which one I use for share on Facebook & Twitter. My requirement is that text will be a link after share on Facebook. On Facebook when user click on that text, then direct go to that link.
My code is like below:
NSInteger Score = [[NSUserDefaults standardUserDefaults] integerForKey:#"K_ScoreVal"];
SLComposeViewController *Facebooksheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[Facebooksheet setInitialText:[NSString stringWithFormat:#"I just completed level 1.1 and score is %d points.",Score]];
[[CCDirector sharedDirector] presentViewController:Facebooksheet animated:YES completion:nil];
I just completed level 1.1 and score is 455 points. This is my text, which one I share on Facebook. But when user click on this text, then direct go to a link. Meanwhile I want to make this text as a hyperlink.
Please suggest me.
What you really want to use is the OpenGraph API for games. Have a look at the introduction docs at https://developers.facebook.com/docs/games/opengraph/
If you go down this road, you can use the
Achievements API
Scores API
Have you tried using Attributed Strings?
NSString *shareString = [[NSAttributedString alloc] initWithString:#"I just completed level 1.1 and score is 455 points." attributes:#{NSLinkAttributeName: #"http://yourlink.com"}];
I am trying to integrate GooglePlus inside an iOS app of mine.
The app sends a simple message. I have a few questions about the setting of the recipient(s).
Here is the kind of code I am using:
[GPPShare sharedInstance].delegate = self;
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder setPrefillText:#"Hello world! How is everything?"];
[shareBuilder setPreselectedPeopleIDs:#"112233445566778899000"]; // Question point!!
if (![shareBuilder open]) {
NSLog(#"Status: Error (shareBuilder cannot open).");
}
When the line with the comment "Question point!!" is present, I can set one(or a few) individual(s) as recipient(s) of the message.
When it is not present the set of recipients defaults to "Friends".
Here are my two questions:
Is it possible to set one of my circles (or a community) as recipient? Not only "Friends".
When using the "setPreselectedPeopleIDs:" method, one needs the ID of the recipient. How do we find this ID? There are documents and videos on the net showing how to find one's own ID, but since people usually send messages to other peole rather than to themselves, it would also be useful to know how to get other's IDs.
Doesn't seem like you can share with a specific circle.
You can use this method to get all of the visible people in the user's circles using this method
queryForPeopleListWithUserId:collection:
which is outlined here:
https://developers.google.com/+/mobile/ios/people
Explanation of the parameters from the header:
// List all of the people in the specified collection.
// Required:
// userId: Get the collection of people for the person identified. Use "me" to
// indicate the authenticated user.
// collection: The collection of people to list.
// kGTLPlusCollectionVisible: The list of people who this user has added to
// one or more circles, limited to the circles visible to the requesting
// application.
And another question that goes into this a little bit:
How to Fetch Google Plus circles in IOS Sdk
It does not seem to me like you can discern who is in what circle, unfortunately.