IOS Safari URL UTI share sheet - ios

I am trying to pass the current URL from safari to my app using the safari share button and share sheet. I want this to go to my app and not have it be a share extension. From safari, the share sheet does not show my app. I have registered the following document types (UTI) without success:
public.url
public.file-url
public.url-name
My app does show up from a pdf document share using com.adobe.pdf without any issues. Any help sharing the URL from safari would be most appreciated. I am also having a similar issue with using share button from a photo displayed from the apple app.
What are the correct UTI for safari url and a photo via the share button to properly appear on the share sheet? Thanks.
Bob

Go to the project (root element in the Project Navigator) and select your Share target
Go to Info
Open NSEXtension -> NSExtensionAttributes -> NSExtensionActivationRule
For URL Support: Add NSExtensionActivationSupportsWebURLWithMaxCount underneath NSExtensionActivationRule (type is Number, the value is any number higher than 0 depending how many URL's you allow to handle in one share action)
For Photo and/or Video Support add NSExtensionActivationSupportsImageWithMaxCount and/or NSExtensionActivationSupportsMovieWithMaxCount
For other file types add NSExtensionActivationSupportsFileWithMaxCount
In the raw code of the Info.plist file of your Share target it will look like this:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>YourStoryboard</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
NOTE for people who don't see their app appearing in Dropbox'es Export sheet: Dropbox passes a URL to the share sheet, you'd have to support NSExtensionActivationSupportsWebURLWithMaxCount

I just dealt w/ this issue. It appears to be a Safari issue and not an App configuration issue. So long as your permissions are set correctly per the documentation, try testing in google chrome. Shares just fine from there...

Related

How to make deep links work in flutter when opened with gmail?

I am trying to implement deep linking in my flutter app. I am using the uni_links flutter package.
I am sending the deeplink for my application to the user's email account. However, in gmail, you need the http protocol in the href value, Otherwise gmail will not consider that as a valid link. Hence I am forced to use the following link in the email :
Click here
as opposed to a link like,
Click here
Now with https://myexample.flutter.dev, when I open the link from gmail, it doesn't open my app.
But, if I change my CFBundleURLSchemes key to myexample and CFBundleURLName to flutter.dev, when I type in myexample://flutter.dev in my browser, it opens my app. However, like I mentioned before, this is not recognized as a valid link in gmail.
What is the issue here? How do I resolve this?
Here's my ios/Runner/Info.plist :
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>myexample.flutter.dev</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
</array>
The first one is custom link you can do it by yourself
Click here
The second one is universal link
You need to provide file on the backend side to make it work.
Universal Links only work with https scheme and require a specified host, entitlements and a hosted file - apple-app-site-association.
Click here
UniversalLinksDocumentation
PS. I think right now as the end of the 2020 the best way to handle deeplinks is by Firebase Dynamic Links. Maybe future people will consider it it should be much more easier

Register iOS app to open an image from the photo library (PhotoKit) and all other apps

I have been struggling with this for a few hours and couldn't confirm wether the following scenario is possible to achieve anymore or not.
Scenario : I am developing an app that deals (create, store ...) with files (image, video, pdf ..) and want to expose it as a viewer for these type of files to any other app in the device and mainly the photo library.
Current behaviour : my app is visible (and of course handling the files) when hit sharing from files browser on iPhone, google drive, one drive ... except the photo library. The only possible way I found to make it visible there is through creating a Share Extension which does not serve what I am attending to do since it is a limitation that Share Extension can not communicate with the app and attend to open it and pass the image path (or stream).
Here is my info.plist CFBundleDocumentTypes :
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>CFBundleTypeName</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>
All I found so far is you just need CFBundleDocumentTypes to register your app in the device target apps for opening certain files (by types indicated by LSItemContentTypes). But no one has mentioned (I couldn't find one yet at least), why this sort of config won't get your app visible as a viewer when selecting share photo from photos library.
To Reproduce : just create a native iOS project via XCode or Xamarin.iOS project and introduce the above section into your info.plist. And of course run your app. You'll see it from files explorer, from safari trying to share a pdf to your file..., but not from photos library.

Make my app appear in UIActivityViewController for highlighted text?

I would like to make my app appear in the UIActivityViewController for text sharing, like in Mail, iMessage, Notes, Gmail etc etc.
For example, when user tapback on selected text and hit the 'Share' button from any app like in the attachment:
I would like my app to appear in the UIActivityViewController and when the user selects my app, to launch it with the ability to handle that selected text.
So what I have tried: Search in Apple documentation.
Searched for relevant UTI but I understood that the UTIs are used only for files and not for a simple NSString (Correct me if I'm wrong).
I have worked with UTI's for images, text files, pdf etc, but I have no solution for being shared with highlight text.
Read about UIDocumentInteractionController and again, it won't help me, because its for using to handling files.
I have tried to implement Share Extension, but this is not the solution that i want, I don't need the post popup and moreover than that I need to launch my app after sharing like in Mail, Notes, iMessage does (Regarding to Apple documentation we can't launch the contain app through Share extension only through Today extension).
Of course, I have searched a lot in StackOverFlow, didn't find solution for that question.
So any solutions? Thanks!
If you want to share text through UIActivityViewController you have to use Share Extension.
To make your app appear in UIActivityViewController to share text you have to add this code/Key to your Info.plist of Share Extension:-
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<true/>
</dict>
<key>RequestsOpenAccess</key>
<true/>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
by this your app will appear in UIActivityViewController and able to text sharing.
and to avoid Post Popup you have to design MainInterface.storyboard according your requirements.

Display app in Open In menu … in case of file attachment from Microsoft apps

I tried this key in plist..
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>All Files</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
<string>public.content</string>
</array>
</dict>
</array>
this works for file sharing but in case of file attachment from ms-word app this code does not work while Dropbox and Slack still in menu. Also I have tried lots of examples.
This is not just Open In menu, this is Activities menu, that means it displays apps with Share extensions inside. To get into this menu you should create Share extension in your app, and this extension will show in MS Word app.
To create Share extension in your app you should add new Target for it, File > New > Target > Application Extension > Share Extension.
Here is official documentation about share extensions.
It can be little confusing, so I created simple example with empty extension, you can get it here .
Screeshot with example app in Activities menu:
UPD
To see your app next to DropBox icon in Activities menu you should create Action extension for your app. I created another example with empty Action extension here. How DropBox action extension works: it displays Action extension inside MSWord app and uploads selected file to DropBox server.Also, you should know, that these extensions are not App launcher, so you should implement you functionality in extension without you app opening, link
openURL not work in Action Extension
Screeshot with Action extension icon:

Opening a jpeg image from mail app into my iOS app

I was trying to implement this functionallity for the first time, and seemed pretty straight forward, but for some reason is not working for me.
My intention is to open a simple jpeg from the mail app into my application, after that was not working I was just trying to open any kind of document by adding this to the Info.plist.
Same result, my application is not appearing on the list of "Open with..."
<key>CFBundleDocumentTypes</key> <array>
<dict>
<key>CFBundleTypeName</key>
<string>All Docs</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.content</string>
</array>
</dict> </array>
I have search already in StackOverFlow and the apple docs, but none of the answers make it work for me, so maybe is something simple that I am missing here...
Why is my iOS app not showing up in other apps' "Open in" dialog?
How do I associate file types with an iPhone application?
How I am testing it (maybe has to do with this):
Have an email with an attachment. Add the settings to the plist and the run the application on my device, hoping that the next time I open the mail app and click on the attachment my app will be on the list.
Well, it seems that is not possible. At least to provide a custom way to open images from the mail app. There is no problem if is from another place, but apple has limited the options on the mail app so we would use the "copy" option as a workaround.
Update:
This question goes in the same direction.
It is now possible to open images from the mail app, it's just somewhat convoluted:
Tap and hold the image.
Tap on Quick Look so the image goes fullscreen.
Tap the image to show the top toolbar.
Tap the open in button at the top right.
Scroll the list to the left to find your app.

Resources