I am trying to share an animated GIF but default UIActivityViewController Twitter share doesn't support it yet which it will "scale down" it as a still JPG, I have to use SLRequest for it as taught in this article. The downside of that is no preview share sheet and users cannot type their own message anymore.
However, I saw SteppyPants that it seems using a custom action after users click "share" in Twitter share sheet, how can they do it?
In other word, how to replace the UIActivityViewController twitter share action to a custom action which includes SLRequest.
Things I tried:
UIActivityItemProvider and check UIActivityTypePostToTwitter, but
that's run after user click twitter and before editing the text
In UIActivityViewController completionWithItemsHandler delete the just twitted post (with still gif) and post again with SLRequest, but not too sure if I can delete the old post and it's consuming network bandwidth for users anyway
SLComposeViewController, does not support animated GIF upload and not custom share action at all
P.S. I am iOS newb
UIActivityItemProvider and check UIActivityTypePostToTwitter, but that's run after user click twitter and before editing the text
That's pretty close!
I believe Steppy Pants is doing what you said; providing a UIActivityItemProvider to the UIActivityViewController, but with a twist.
When the UIActivityItemProvider's item method is called, it checks if the UIActivityType is UIActivityTypePostToTwitter and if so, the UIActivityViewController is dismissed and a custom SLComposeServiceViewController is presented.
If you look closely you can see: The presented view controller doesn't have a title and the remaining character count doesn't respond correctly to URLs. The SLComposeServiceViewController object then implements didSelectPost to present a spinner UI while it initiates an SLRequest.
Related
Instead of using e.g. ShareKit or custom URL-scheme(to share to e.g. WhatsApp or Instagram), can you tap a button inside the app and skip the share extension dialog and go directly to one of the sharers there?
What I want to achieve is to have a button for each share type in our app, and tapping that button brings the user directly to the share screen for that type.
EDIT: We already have the share extension sharing working today, but we want to have a separate button for each sharer, like many apps have today. See attached example from musical.ly.
Yes it is possible but depends on what exactly you want? Did you want to send some file to printer? Or Email something? share via AirDrop?
I just read some articles on UIActivityViewController and UIDocumentInteractionController in iOS, but I am very confused about how to use them because both seem the same.
So, when do I use UIActivityViewController or UIDocumentInteractionController?
Is there any difference for Open In... & use UIActivityViewController?
I am very confused about how to use them. Please clarify to me their specific use.
In short, UIDocumentInteractionController deals with files while UIActivityViewController deals with various other services in your app. I'm not one to criticize much but you really should at least try to google and read at least the overview in the iOS Developer Docs.
UIDocumentInteractionController documentation:
A view controller that previews, opens, or prints files whose file format cannot be handled directly by your app.
...
Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file. For example, an email program might use this class to allow the user to preview attachments and open them in other apps.
After presenting its user interface, a document interaction controller handles all interactions needed to support file preview and menu display.
You can also use the delegate to participate in interactions occurring within the presented interface. For example, the delegate is notified when a file is about to be handed off to another application for opening. For a complete description of the methods you can implement in your delegate, see UIDocumentInteractionControllerDelegate.
UIActivityViewController documentation:
A view controller that you use to offer standard services from your app.
...
The system provides several standard services, such as copying items to the pasteboard, posting content to social media sites, sending items via email or SMS, and more. Apps can also define custom services.
Your app is responsible for configuring, presenting, and dismissing this view controller. Configuration for the view controller involves specifying the data objects on which the view controller should act. (You can also specify the list of custom services your app supports.) When presenting the view controller, you must do so using the appropriate means for the current device. On iPad, you must present the view controller in a popover. On iPhone and iPod touch, you must present it modally.
Basically UIActivityViewController shares Data Objects (like Strings or Images) where UIDocumentInteractionController shares whole Documents / Files f.e. a PDF.
I'm trying to create a UIActionSheet similar to Safari's. I haven't been able to find anything in the Apple documentation on how to make a UIActionSheet look like this. Is there a control/API that I am missing that I can use to create what's below, or am I stuck with creating my own UIView and displaying that?
Ninja Edit: This appears to be a UIActivityViewController. Is there any way I can add my own custom actions to it?
That is not a UIActionSheet.
It is a UIActivityViewController:
https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html
From Apple's Documentation:
The UIActivityViewController class is a standard view controller that you can use to offer
various services from your application. The system provides several standard services,
such as copying items to the pasteboard, posting content to social media sites, sending
items via email or SMS, and more. Apps can also define custom services.
Your app is responsible for configuring, presenting, and dismissing this view controller.
Configuration for the view controller involves specifying the data objects on which the
view controller should act. (You can also specify the list of custom services your app
supports.) When presenting the view controller, you must do so using the appropriate means
for the current device. On iPad, you must present the view controller in a popover. On
iPhone and iPod touch, you must present it modally.
About the ninja edit : Yes you can add actions to the UIActivityViewController.
See UIActivity on Apple's doc, or this SO question.
I have added sharing to my app by way of iOS 6's UIActivityViewController. In addition to the usual suspects (Twitter, Facebook, etc.) I am also using a subclass of UIActivity I created to enable sharing to another service (App.net). Everything is working fine.
Now I would like to add an option whereby the user can choose a default sharing service, so that when he taps my app's Share button, rather than the UIActivityViewController coming up, instead the interface for the user's chosen default service comes up. Now, I can do this for the standard system services (Facebook and Twitter) using a SLComposeViewController. However I don't see any way of using SLComposeViewController to bring up my custom UIActivity's user interface.
Is there any way I can call my custom UIActivity subclass and bring up its UI directly (i.e. NOT from within a UIActivityViewController)?
I don't see why you would want to be doing this. Since you obviously have some method of creating your own sharing view controller, you could just use this again - no need to go the UIActivity-route (which is a terrible API by the way).
I notice that Mobile Safari's Twitter and Facebook share adds a screenshot of the current page without actually sharing it, eg:
Im trying to duplicate this via SLComposeViewController, however calling the addImage: actually adds the UIImage to the tweet/facebook album (as expected).
Is there a way to just display the screenshot of the page without adding the image ?
Edit:
Looks like SLComposeViewController conforms to UIAppearanceContainer however the UI_APPEARANCE_SELECTOR is not documented.
Safari is previewing the screenshot to the website because it has it loaded and ready in on the screen, when you addURL: on the SLComposeViewController it doesn't resolve that URL and grab a preview.
Also when you addImage: that's exactly what it's doing, it's adding an image to your post, this isn't what you want, you just want to have a visual and not a safari logo/icon in place of the attachment indicating a link.
I can only say there is a private method on the SLComposeViewController class which is how Safari is adding a preview image for URLs added...
You should always get this in your app when sharing a URL:
That sucks, you should add a feature request (http://bugreport.apple.com) so that you can add your own preview here, maybe Apple will make that public in future iOS releases.