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.
Related
I'm trying to pop the built in Safari share WeChat in my iOS app. But can't find a way to make WeChat app show up in the UIActivityViewController!
I noticed that the WeChat app icon shows up when sharing images from the Photo Gallery, and Safari link sharing. The native Notes app doesn't have WeChat option.
Not sure how that's working, any help is appreciated! Thanks!
This is done using "Share" extensions. See Apple docs for more information: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/ShareSheet.html#//apple_ref/doc/uid/TP40014214-CH12-SW1
Regarding why some apps appear in certain sharing contexts but not in others, this is because a Share extension has to declare to iOS which kind of data it supports for sharing. Presumably, WeChat developers did not enable their Share extension for "pure" text content, like in the Notes app. See here for how to set which kind of data a Share extension accepts: https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8
Unfortunately you won't be able to add the WeChat Share extension on behalf of them if they didn't allow it, but you might be able to use some WeChat API to develop your own app extension with text content enabled.
Hope it helped.
WeChat's icon won't appear in UIActivityViewController if you try to share anything other than URL. WeChat only accepts URL posts. This code snippet should work for you:
NSArray *items = #[[NSURL URLWithString:#"http://google.com"]];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
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,
For Share sheet for my iOS app. As I referred in this link How to display the default iOS 6 share action sheet with available share options?.
And I end up with below working code :
NSString *string = #"Some text to share";
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[string]
applicationActivities:nil];
[self presentViewController:activityViewController
animated:YES
completion:^{
NSLog(#"complerted.");
}];
But I can see only Email & Message button !!?
How can I get other social media buttons in Share sheet like Facebook , twitter as seen below. Even though user account not available/created in device? (As we can see iOS default Photos app, where the share sheet has social buttons even though for example facebook not installed in the device!) Should I enable or extend extension?
Please help,
Thanks & Regards,
//Update
- I added iOS-8 social framework and imported #import <Social/Social.h>.
This UIactivityController show the app which can share your string or image. If you have not added any Facebook or twitter account than that will not show that app in this action sheet.
Try by adding Facebook and twitter account in your devices setting. you will able to see that app too.
You have a More button in your share sheet. Tap on it & it will shows all the available Extension & turn on it for Facebook & Twitter.
As Instagram official document says
To include a pre-filled caption with your photo, you can set the annotation property on the document interaction request to an NSDictionary containing an NSString under the key "InstagramCaption". Note: this feature will be available on Instagram 2.1 and later.
For Instagram 4.x or lower, it works well. But for Instagram 5.0, Instagram team added a new feature called "Direct". When users upload a photo, they have two options "Followers" or "DIRECT". I think this is the reason why "InstagramCaption" doesn't work. Is there a new way to add caption programmatically?
Thank you so much!
self.dic.annotation = #{#"InstagramCaption" : captionString};
self.dic.delegate = self;
[self.dic presentOpenInMenuFromRect:shareButton.frame inView:self.view animated:YES];
It doesn't work now.
Best response I've gotten so far:
Thanks for your report and interest in the Instagram platform. We are aware of this issue and it will be fixed in the next update of the iOS app.
I followed up asking for a timeframe or anymore info on a workaround but have not heard anything.
This is fixed in Instagram Version 5.0.1.
It appears that they have removed the caption url parameter from their URL scheme though. So UIDocumentInteractionController can still pass a caption through the annotation property but trying to add one through the URL scheme is no longer supported.
When I share an image via Facebook using the latest version of the sharekit library, it sets the pre-filled status default message as the message, but doesn't give the user the opportunity to change that message like you can when sharing using sharekit on Twitter. Is this possible with Facebook using ShareKit?
You won't get around getting the text from the user if that's what you want. Otherwise you could pre-define a set of standard text's youself.
Changing the default share text inside ShareKit is very simple:
NSString *someText = #"This is a blurb of text I highlighted from a document.";
SHKItem *item = [SHKItem text:someText];
The documentation shows some more ways on how to use ShareKit at its best.
Yes, it is possible to use ShareKit with facebook have a look at the SHKConfig.h file.