Add custom UIActivity for standard apps - ios

dear community,
A simple question but no clear answer yet.
Can I add my button to standard UIActivityController so that when user goes to Photos/Notes/Safari he can also along with twitter/facebook post it to my destination ?
I'm sure I can do that while calling UIActivityViewController from within my app.
And looks like there is a way to do that for mail attachments. Box app can do that here, probably via CFBundleDocumentTypes in plist. But is there a way to do that with e.g. photos?
Hopefully anybody can give me any useful links with examples of such implementation.
Thanks a lot
--Dannie

As of iOS 6, there is no way to add a custom UIActivity item to built-in apps like Photos, Notes, or Safari.
Custom UIActivity items can only be added to third-party apps.

Related

Customizing UIDocumentInteractionController

Recently I was trying to customize UIDocumentInteractionController. Specifically removing 3-rd party apps from it.
I have read many articles and topics, but all I found out, is that it’s simply “uncustomizable”.
I am trying to pass my image to other apps.
So I have a share button, and I need it to show UIDocumentInteractionController only with social media services like (Facebook, Twitter, Message, Mail, etc) but exclude all other apps that use an image as a basis. I know there is a UTI option, but is there some kind of UTI that will represent only social media options? I didn’t find it. I almost lost my hope :(
But here I opened my Snapseed. And here you go - “Open in” has UIDocumentInteractionController with all apps that can work with images. And there is “Share..” button that has only socials. So can someone explain to me what am I missing? How can I achieve close enough results?

How can I share Safari URL to my Cordova/PhoneGap App (ios)?

I am searching for the last week over many websites, and I can see people with the same question, but they are mostly misundestood.
What I have:
I have an iOS application that can receive URL from browsers (made with ionic/cordova)
What I want:
When I am on Safari (or other browser), i want to use the button Share, and my app appear there, in the list, just like Twitter, Facebook, etc. (I put an arrow in the image below).
Like this:
And, I want this working on many iOS versions.
So, I tried to change my app-info.plist many times and nothing works.
Somebody have a solution for this? Somebody have a info.plist that do this job?
(PS: I don´t want to use URL scheme, links, etc... Its the browser SHARE)
Thanks!
The only way is to create a share extension, as mentioned. It is not a trivial task in that you have to incorporate a lot of pieces together to make it work. Also, it is only supported on iOS 8+, which I guess shouldn't be a major issue at present.
In a nutshell:
Create Share Extension in XCode
Create a JS preprocessor
Add plist key/value pairs for related ExtensionAttributes
Set up custom URL scheme
Customize ShareViewController
Set up global handler function to perform your desired actions in app
See Cordova: sharing browser URL to my iOS app (Clipper ios share extension)
Or https://www.inshikos.com/blogs/76/dev/link-and-photo-sharing-to-a-cordova-ios-app-via-share-extensions-ios-8 that expands it further to include photo and wider share scenarios.
And, yes, a terribly misunderstood question with many false positive answers in other posts.

iOS Show UIAlert in Safari when using My App's Share Extension

I'm developing a simple content blocker for iOS 9+ devices. Everything seems to be working fine in terms of blocking ad's / trackers etc and I even have the ability to 'whitelist' websites directly from Safari using a Share Extension Action.
My question is when the user taps Action > My Apps Share Extension [which adds it to a list inside the main app] I want to show a simple Alert that says something like 'This site has been added to your whitelist..." for a few seconds and then disappear.
... how do I do this?
**UPDATE I have read all of Apples documentation on this but still can't figure it out. The post here does actually refer to how to design a streamlined UI but doesn't really cover my situation.
Hoping someone will know :-)
Why you don't use Notifications for this , you can have your notification style set to show like an UIAlert. You can see something like that in Calendar app in iOS.
UPDATE:
I did a little bit more digging , it's not possible to change the style programmatically according to this. So the best choice is handling it when your app is in foreground. I can't think of any other OS wide solution other than local notifications.

Other apps not allowed in UIActivityViewController?

I'm working on an iOS app in Objective-C and I'm currently trying to make a sharing extension with a UIActivityViewController.
I understand that there is an enum of activity that I can individually exclude from the UIActivityViewController with a property of type NSArray called excludedActivityTypes.
How can I also exclude other apps (such as Pinterest or LinkedIn) that the user can manually add/activate/disable from the panel that shows when you hit the "Other" button in the UIActivityViewController ?
Thank you in advance.
How can I also exclude other apps (such as Pinterest or LinkedIn) that the user can manually add/activate/disable from the panel
You cannot. Of course you could try going to the user's house and pinning his arms behind his back, but, short of that, you are not in charge of what the user does.

"Open in" feature in UIActivityViewController

I need your help with UIActivityViewController.
I need to present activity controller for the file where, except for default actions, the user will be able to open the file in other apps.
I know how to do this with UIDocumentController, which shows popover with all apps able to open the file.
But how can I show all these apps in UIActivityViewController?
P.S. This behavior can be seen in Apple Mail app, for example.
Look at TTOpenInAppActivity for a way to combine both a UIActivityViewController (for normal sharing), and an 'Open in' button on that which brings up a UIDocumentInteractionController. Pre-iOS 8, that is the best way to manage this.
The function and behavior is different between UIActivityViewController and UIDocumentController.
UIActivityViewController
Presents activities that are pre-defined, you can pass an array to select which ones should be excluded among the default ones that are presented, if you want to add more activities you have to use custom activities, unfortunately these will appear bellow the rest of the activities and even more, the icon will always be gray, your app never loses control since you can use delegates and other stuff to know what is going on on those apps. (Unless you manually make an activity which opens another app)
UIDocumentController
This one asks the system for all the registered applications for a certain file extension, many apps have registered their exclusive extensions which makes it so that this app will be the only one displayed. If you pass an image, you will see all the apps that can handle this file. When using this one your app will lose control since the other app will be opened.
What is your final objective?, If you describe it with more detail we could offer you a better solution.
From what i understand, you should see yourself what type of file the user is trying to open, and then yourself open it with the most suitable one.
Since you cant really emulate what apple is doing, you should handle this problem through your interface, offer the user to "share" or to "open with" for example.
The answer is very simple. There is no way to do it. You cannot add the apps except the defaults into the UIActivityViewControllers.
You are absolutley correct, you can acheive this through the UIDocumentInteractionController.

Resources