UIActivityViewController when have no Facebook account in settings - ios

I'm using UIActivityViewController, I want to show Facebook option even if the user has not defined a Facebook account in device settings.
In my code, Facebook option not shown when there is no Facebook acoount in settings.
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
But, in Safari or more apps there is Facebook option and when click on it - a alert is displayed with "No facebbok account" title and message says "go to settings".
There is any way to add Facebook like this or this possible just for apple apps?

There's no way to do that using UIActivityViewController. If you check other apps (no apple development) you can see that doesn't use UIActivityViewController but Action Sheets or something else and uses Social Framework. You can check this answer. And check this tutorial if you use Social Framework.
Hope it helps!

Related

Pop WeChat/Weixin Safari-like Share Sheet in my app UIActivityViewController?

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];

iOS Share sheet : facebook twitter not present. Only Message and Email present

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.

UIActivityViewController Flickr Sharing - No Flickr option appears

I am trying to use the UIActivityViewController Flickr sharing in iOS 7 but the Flickr icon does not appear in the sharing sheet. I feel like I am missing something basic.
I am testing on an iPhone 5S.
I am logged into a Flickr account on the device.
The same share sheet displays and shares properly with Facebook, Twitter, Email , MMS, and AirDrop.
The photos app on the device displays the Flickr icon in the photos app sharing sheet and can share successfully to the phone Flickr account.
I am sure that I am not listing Flickr in the excluded activities for the UIActivityViewController.
I have tried with both standard UIActivityViewController and the RDActivityViewController subclasses.
Is there something additional required for Flickr sharing? or could someone confirm that they have seen this work in their own app.
Thanks
Flickr share with UIActivityViewController will only work if you are sharing a image.
So in your array with activity items there should be at least one image.
Make sure that the image is of type UIImage:
NSArray *shareItems = #[someImage, #"Text of the messages"];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
Exmple of how it looks: https://www.dropbox.com/s/jpjmnuqbktqgb8s/FlickTest.png

Facebook send dialog in iOS app

I have an iOs app in which I tell the user to share a link with the friends he wants. I want to offer him the possibility to open a new inbox from within the app and if possible with pre-filled content. But no pre-filled recipient. And I want it to be available to all users (not only those with facebook connect).
Basically I want to replicate the following send dialog for web in the app: https://developers.facebook.com/docs/reference/dialogs/send/
Which means it will open the facebook app and not the browser to show the new inbox dialog.
From my research I found no clear solution and as it is possible from a website I would be surprised I cannot do the same with the app.
Thank you very much in advance,
Jules
You can use UIActivityViewController.
You first have to create a list of the things you want to share: an URL, a string, etc like this
NSArray *activityItems = #[[NSURL URLWithString:#"www.link-to-share.com], #"What you want written above"];
Afterwards, you just have to create the UIActivityViewController with the things you want to share and present it modally:
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
You can also add a completion block so that you are notified when the user is done with the sharing:
[activityController setCompletionHandler:^(NSString *activityType, BOOL completed){
//do stuff
}];

How to launch myapplication settings tab in settings app from my application in ipad

Is there any way to open myapplication settings tab directly from my application like what we will use to open twitter settings
([[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=TWITTER"]]).
By showing the Facebook or Twitter composer with the standard iOS Social Framework, will present us an AlertView with an option to go directly to FB or Twitter Settings for the users if the accounts are not setup. So this will be helpful when you want to your user to login to them via the Settings app, if they haven't done so.
Have tested this with iOS 6 in iPad with both FB and Twitter.
Avoid using the canSendTweet method to check before you tweet, just present the ViewController. Should work for the Social framework as well, if you are working with iOS6. Example below.
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[self presentModalViewController:tweetSheet animated:YES];
//If the user doesn't have twitter enabled then an alertview will pop up giving them to option to go straight to settings.
As of iOS 8:
[[UIApplication sharedApplication] openURL:UIApplicationOpenSettingsURLString];
I don't believe that opening the settings for any app other than your own (including the Twitter and Facebook configuration page) is supported.
Just show the composer. If no FB Account is available, it will show an AlertView to go to Settings. Works in iOS 8
var controller = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
controller.setInitialText("My Post")
self.presentViewController(controller, animated: true, completion: nil)

Resources