plugin com.apple.share.Facebook.post invalidated - ios

In my app I'm using the following code that allows to share an image with a text:
- (IBAction)sharePressed:(id)sender {
UIImage *postingImage = [UIImage imageWithContentsOfFile:self.filepath];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[#"Lorem ipsum", postingImage] applicationActivities:nil;
[self presentViewController:activityViewController animated:YES completion:nil];
}
Posting the image to Facebook works fine and it appears on my FB wall, however in my console I get the following message:
plugin com.apple.share.Facebook.post invalidated
I've tested it on a couple of devices, as far as I could see it only happens on my iPhone 6 with iOS 8.1 installed.
Anyone knows what that message means and how to prevent it from showing?

Here is the correct answer ios plugin com.apple.share.Facebook.post do not show provided text. It's a bummer.
I'm afraid to tell you, you cannot post text to Facebook programatically. It's a new Facebook prohibition that forbids "pre-filled" Facebook sharing. That is why newer versions of iOS do not show your text, even tough it's correctly provided (and works on Twitter and in other sharing options).
For more info please refer to https://developers.facebook.com/docs/apps/review/prefill

This is a terrible error message by Apple. Go to settings and check your facebook/twitter accounts. You will notice they have no password set (perhaps this happens after updating to 8.1). Just update the account info and the message will be gone and your post/tweet will work.

In my case, this is related to the fact that the Facebook app replaces the iOS system level Facebook share extension with a custom one. Case is triggered as follows:
Load an app and share to Facebook (Note: Facebook app is currently
installed)
Exit app
Delete the Facebook app from device
Open app again (still active in memory) and share to Facebook ...
fail! The app is looking for a share extension that was
uninstalled along with the Facebook app
Kill and restart the app, share to Facebook. Voila! The app has loaded the default iOS Facebook share extension and it works again.
Head scratcher as to why Apple let Facebook take this approach as opposed to either forcing them to replace the default Facebook share extension or just not allowing them to inject their own, only if their app is installed.

It also happen when u try to set an URL using addURL: method for SLServiceTypeTwitter in your SLComposeViewController. Deleting it fix the issue.

Facebook has updated their policy. It doesn't work with this anymore. you need to integrate Facebook sdk to do so. here is the relevant references for those who want to share image or post from your app to Facebook
https://developers.facebook.com/docs/sharing/opengraph/ios#sharedialog

I faced the same issue. I was using activity controller and SLComposeViewController, and in both cases got the same error, even if i don't set any text/url etc for fb programatically. So according to me, in my case, it was not the issue of new facebook policy as mentioned in comment above.
To avoid any inconvenience in future, i fixed it by using facebook share SDK (not using SLComposeViewController or activityViewController now). FBSdk is integrated in my iOS project and the code, i used for sharing purpose is as:
#IBAction func shareOnFaceBook(sender: AnyObject) {
var content = FBSDKShareLinkContent()
content.contentURL = urlToShare() //method returning the url
content.contentDescription = textToShare() //method returning text(string) to share
var dialog = FBSDKShareDialog()
dialog.mode = FBSDKShareDialogMode.Automatic
dialog.shareContent = content
dialog.delegate = self
dialog.fromViewController = self
dialog.show()
}
It'll open fb application (if installed), Otherwise will open Safari (fb web application).Hope that it'll help you
Best,

Related

How to share photo to Facebook within iOS app, when Facebook app is not installed on the phone?

Im using FBSDKShareKit (4.22.1), i'm trying to share photo with the following code:
let photo = FBSDKSharePhoto()
photo1.imageURL = URL(string: "sample url")
photo.isUserGenerated = false
let photoContent = FBSDKSharePhotoContent()
photoContent.photos = [photo]
FBSDKShareDialog.show(from: self, with: photoContent, delegate: nil)
but it only works when the native Facebook app is installed on the phone.
I also tried to show the content with Share Button instead of Share Dialog like:
var shareButton = FBSDKShareButton()
shareButton.shareContent = photoContent
shareButton.center = self.view.center
self.view.addSubview(shareButton)
it didn't work, if app was not installed either.
i want the FBSDK i used in my app, opens Safari when Facebook app is not installed, it opens safari by default for FBSDKShareLinkContent, but not working for FBSDKSharePhotoContent.
does anyone know what is the problem?
I have implemented another way to share photos using Graph API. It was very helpful. Here is a link.
Just what you need is to take the permissions from the user to publish_actions
before posting.
Also there is no native facebook app installed. Just got logged in through Browser.
Well, I found the answer in Facebook developer website, which is:
Photos
People can share photos from your app to Facebook with the Share
Dialog or with a custom interface:
Photos must be less than 12MB in size
People need the native Facebook for iOS app installed, version 7.0 or higher
you can also ask for "publish_actions", you need to login twice, first with readPermission for email, then when user wants to share a post loginWithPublishPermission for "publish_actions". the point is that you have to add "publish_actions" first of all in your Facebook developer account.

How to share URL using Xamarin iOS

I'm developing an app for my local newspaper. When you press the "Share" button, I want the standard iOS share interface to appear allowing users to share the URL of an article with Facebook, Twitter, etc. I'm trying to use the UIActivityViewController, and while it appears, it's not giving me all of the options.
Here's the code I use:
NSObject[] activitiesItems = {
new NSString(post.Title),
new NSUrl(post.URL)
};
var activityController = new UIActivityViewController(activitiesItems, null);
PresentViewController(activityController, true, null);
When the UI opens, this is all I see (no Twitter or Facebook):
This is in comparison to what I see when I share a page from Safari, which has the Facebook and Twitter options, along with a variety of others:
What do I have to change in my code to allow more of these options to appear?
1) Your code is fine
2) On your iOS Simulator go to the Setting and login to Twitter and/or FaceBook accounts and retest your app.
iOS Simulator Setting (botton off screen):
Here is my Simulator view with me logged into Twitter but not Facebook using the same code you posted:
3) Safari is a using a custom ViewController to display what you are seeing... If you actually try to share a link via that Twitter button you will be force to login..
4) Use an actual device for complete testing of all the possible sharing applications installed.
Those options are only supposed to show when you are logged in to an account in the Settings app for FB and Twitter. They are hidden if not.
However that doesn't really explain why they show up in Safari.
Perhaps including the NSString for post.Title in the items array is causing it to exclude some sharing options.

SLComposeViewController won't set initialText for SLServiceTypeFacebook

It seems as a bug in Social framework, it won't set the initial text for Facebook service type. This is my implementation using Swift:
let view = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
if view.setInitialText("Some text") {
NSLog("Success")
} else {
NSLog("Failure")
}
view.addURL(NSURL(string: "https://google.ro"))
self.presentViewController(view, animated: true, completion: nil)
What it works:
The URL shows up for both, Facebook, and Twitter
The initialText works correctly just for Twitter
What is doesn't work:
The initialText won't show up for Facebook, even though the code above outputs "Success"
Update 2
It seems like Facebook really doesn't want developers to set the initial text of a message when Sharing as that it's impossible even with their SDK. In the app I was implementing I've chosen screenshots from the app (uploaded as images) for letting the user share their progress on Facebook.
Update
The solution is to use the Facebook SDK for iOS, that feature of Social framework is not supported by Facebook anymore.
Not a bug, Facebook doesn't allow it anymore.
Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app.
Facebook dose't allow to pre fill message anymore.
For more info here
Saying that, if you use native Facebook sdk it won't solve your problem, because Facebook will not publish your app.
So as written on Facebook guidelines, the only solutions that you have are:
Populate the user message parameter with content that the user manually entered earlier in your app's flow.
Your app’s composer can include a call-to-action that disappears when people start to write a post. For example, Facebook's composer uses grey scale text to ask “What's on your mind?” that disappears when people start to write.
I think it is an iOs 8.3 bug.
Before I updated to that version it was working correctly. :-(

ios plugin com.apple.share.Facebook.post do not show provided text

In my app I'm using the following code that allows to share an image with a text:
- (IBAction)sharePressed:(id)sender {
UIImage *postingImage = [UIImage imageWithContentsOfFile:self.filepath];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[#"Lorem ipsum", postingImage] applicationActivities:nil;
[self presentViewController:activityViewController animated:YES completion:nil];
}
And when posting I can see image, but can't see text. Also text doesn't appear in FB.
I'm afraid to tell you, you cannot post text to Facebook programatically. It's a new Facebook prohibition that forbids "pre-filled" Facebook sharing. That is why newer versions of iOS do not show your text, even tough it's correctly provided (and works on Twitter and in other sharing options).
For more info please refer to https://developers.facebook.com/docs/apps/review/prefill)
I first saw this when Facebook updated their app on April 24th. Plain text sharing to Facebook isn't working as long as the Facebook app is installed. After you delete it, it's available again.
If you try to share a URL or an image together with the plain text, you will see Facebook as an option but the text field will be blank. The image or URL will attach without a problem.
I posted a sample project that reproduces this problem on github:
https://github.com/djr/UIActivityViewController-Facebook
This is not an answer, but it's pretty clear that the problem is caused by the Facebook app.

iOS: Adding a Facebook Like button to a native iPhone app

I would like to know whether it is possible to add a Facebook Like button to a native iPhone app. In the app, the user browses a business directory or deals. When they tap on an item to view the details, it would be nice to have a Facebook Like button that can be used to post the item to the user's Facebook page.
Facebook writes: "Currently, the Like button is only available in mobile web apps".
My app is a native app and not a web app, so therefore I assume it's not possible. However, I do assume that it is possible to mix native UI components on a screen along with web components and therefore it might be possible to implement the Like button, although I am not sure how you pass data from the native portion to the web portion.
If the only solution is a hack, then I won't implement it because at some point the hack will fail when Facebook alters their API.
read around SO a little, you get many leads. Here's one:
Like button in iOS application
And a comment points to github.com/brow/FacebookLikeView
It has same caveats, but it seems there aren't any magic solutions.
There are these blogposts as well:
http://angelolloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html
http://petersteinberger.com/2010/06/add-facebook-like-button-with-facebook-connect-iphone-sdk/
But not sure you get a native UIButton. Maybe you can open a webview in the background and emulate a click on it...
GL, update if you have some findings,
Oded.
Now you can use the FBlike button using the following code but it need to download latest sdk and it is the beta version :(
Here is the code:
[FBSettings enableBetaFeature:FBBetaFeaturesLikeButton];
[FBSettings enablePlatformCompatibility:NO];
FBLikeControl *like = [[FBLikeControl alloc] init];
like.objectID = #"http://shareitexampleapp.parseapp.com/photo1/";
like.likeControlHorizontalAlignment=FBLikeControlHorizontalAlignmentRight;
like.likeControlStyle=FBLikeControlStyleBoxCount;
[self.view addSubview like];
It looks like Facebook finally decided to allow this, more directly, via the Open Graph API.
See documentation here
Check this out, FB just made it possible through their SDK. Only for testing and ios for now
https://developers.facebook.com/docs/ios/like-button/

Resources