UIActivityViewController, iOS, swift - ios

Do I need to show my App in UIActivityViewController for my another application without the usage of Extension? Is it possible?
And also need when i tapped on other app which are shown in UIActivity ViewController that transfer me into that app.(If is it Possible?)
I have already looked at the following SO Thread I need to show my App in UIActivityViewController for All Applications as Action Extension(Default), but this is done by extension.
For e.g, In iOS 11.0 and above version it give myfile application which shows the files.In this files when I tapped on pdf it shows the own pdfviewer but when i tapped on share button it provide me another added pdfviewer to read and other function which are supported by that application and transfer me to that app.
Is it possible with Action Extension?
Thank You.

It depends whether you want to receive documents or data.
If you want to be listed for Open In or Copy To, as for a document type like PDF, then just declare in the Info.plist that you are a viewer for that document type.
Otherwise to receive data directly thru an activity view, use an Action or Share extension to be listed in the activity view.

Finally I got the answer
When I use UIDocumentInteractionController this is showing me my other app which are support "pdf" and add the property in info.plist which are provided by #matt.
Below code used in parent app so when touch button it shows result like below image.
This is my code:-
#IBAction func ShareDocAction(_ sender : UIButton){
let fileUrl = Bundle.main.url(forResource: "Terms_Condition", withExtension: "pdf")
self.documentController = UIDocumentInteractionController(url: fileUrl!)
DispatchQueue.main.async {
self.documentController.presentOptionsMenu(from: self.actionButton.frame, in: self.view, animated: true)
}
}
and in child app we need to add below code in info.plist:-
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>PDF Document</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
</array>
</dict>
</array>
Here I attach my image show whole scenario
Thank you

Related

Snapchat SDK getting stuck on completion page Swift/Xcode

so I'm working on an app right now where I need to add snapchat login. To do this, I am using their LoginKit SnapSDK. I implemented it as instructed, but when a user tries to log in, they don't go to the snapchat app but rather it opens a safari popup. This wouldn't be an issue if it worked, but it doesn't. The user can put in their credentials, but on the last page they are prompted with a "continue" button that doesn't do anything. Because it does nothing, the user is never logged in and the popup doesn't close. Below I have attached my code (very simple), an image of my Info.plist, and an image of my Frameworks.
Code:
SCSDKLoginClient.login(from: self) { success, error in
if let error = error {
// An error occurred during the login process
print(error.localizedDescription)
} else {
self.dismiss(animated: true)
self.getUserInfo()
}
}
You made a mistake in your info.plist
for item 3 in LSApplicationQueriesSchema which is rocket should be part of URLScheme. Remove that rocket and put it in URLSchemes
You can just copy this code
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>rocket</string>
</array>
</dict>
</array>
As for frameworks make sure it looks like this

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.

IOS Safari URL UTI share sheet

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...

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