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.
Related
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...
I have two app icons built-in (free and premium), is it possible to replace free icon to premium icon programmatically after in-app purchase is completed successfully?
There is a new solution for this situation.
You can use
setAlternateIconName(_:completionHandler:)
iOS 10.3 is out with xcode 8.3.
10.3+
Update:
Usage is pretty simple, the key is to find out plist usage and note that you can not load assets from xcassets ( at least didnt work for me ). You need to add your icon files to project and prefer 180x180 images for quality.
You need to use "Icon files (iOS 5)", new Icon files does not work.
One last thing, when you change icon on a button click it will popup a Alert window that says 'You have changed the icon for "IcoTest".'
//ViewController.swift
#IBAction func ico1Click(_ sender: Any) {
if UIApplication.shared.supportsAlternateIcons{
UIApplication.shared.setAlternateIconName("Icon2", completionHandler: { (error) in
print(error ?? "")
})
}else{
print("NO NO")
}
}
//Info.plist
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>Icon1</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternater1_180x180</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>Icon2</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternater2_180x180</string>
</array>
</dict>
</dict>
</dict>
No, the icon is specified in the application bundle, which you must not change. If you change it, your app signature will become invalid (not the same checksum) and thus your app won't run anymore.
No, definitely not. That part of the application bundle is read-only, and also code signed.
The answer regarding the TapOne app is something completely different. It creates "web clips" to web sites or phone numbers. For example, to create an iPhone icon for your website, you would add something like this to your web page header:
<link rel="apple-touch-icon" href="/your-custom-icon.png"/>
There is more info available here: https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
TapOne and web clips do not programmatically change the icon within an application bundle.
An update: since iOS 10.3 you can update the app icon by having alternate icons defined in the info.plist.
See more at Apple Docs
This is not possible. App icons are not dynamic and they can only be updated by submitting a new updates to your app through iTunes Connect. For more info, read the iTunes Connect Developer Guide. https://itunesconnect.apple.com/docs/iTunesConnect_DeveloperGuide.pdf
I'm afraid not; pretty certain the app icon isn't allowed to conditionally change.
I don't think that's possible without a jailbroken phone. The app icon is contained in the application bundle, which you're not allowed to write to.
I disagree with all the answer above.
Please try the app "OneTap", it will allow you to make your own icon of your new app.
OneTap app is free on Itune.
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.
I have two app icons built-in (free and premium), is it possible to replace free icon to premium icon programmatically after in-app purchase is completed successfully?
There is a new solution for this situation.
You can use
setAlternateIconName(_:completionHandler:)
iOS 10.3 is out with xcode 8.3.
10.3+
Update:
Usage is pretty simple, the key is to find out plist usage and note that you can not load assets from xcassets ( at least didnt work for me ). You need to add your icon files to project and prefer 180x180 images for quality.
You need to use "Icon files (iOS 5)", new Icon files does not work.
One last thing, when you change icon on a button click it will popup a Alert window that says 'You have changed the icon for "IcoTest".'
//ViewController.swift
#IBAction func ico1Click(_ sender: Any) {
if UIApplication.shared.supportsAlternateIcons{
UIApplication.shared.setAlternateIconName("Icon2", completionHandler: { (error) in
print(error ?? "")
})
}else{
print("NO NO")
}
}
//Info.plist
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>Icon1</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternater1_180x180</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>Icon2</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>alternater2_180x180</string>
</array>
</dict>
</dict>
</dict>
No, the icon is specified in the application bundle, which you must not change. If you change it, your app signature will become invalid (not the same checksum) and thus your app won't run anymore.
No, definitely not. That part of the application bundle is read-only, and also code signed.
The answer regarding the TapOne app is something completely different. It creates "web clips" to web sites or phone numbers. For example, to create an iPhone icon for your website, you would add something like this to your web page header:
<link rel="apple-touch-icon" href="/your-custom-icon.png"/>
There is more info available here: https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
TapOne and web clips do not programmatically change the icon within an application bundle.
An update: since iOS 10.3 you can update the app icon by having alternate icons defined in the info.plist.
See more at Apple Docs
This is not possible. App icons are not dynamic and they can only be updated by submitting a new updates to your app through iTunes Connect. For more info, read the iTunes Connect Developer Guide. https://itunesconnect.apple.com/docs/iTunesConnect_DeveloperGuide.pdf
I'm afraid not; pretty certain the app icon isn't allowed to conditionally change.
I don't think that's possible without a jailbroken phone. The app icon is contained in the application bundle, which you're not allowed to write to.
I disagree with all the answer above.
Please try the app "OneTap", it will allow you to make your own icon of your new app.
OneTap app is free on Itune.
I'd like to create a file associate with tiff files in my iOS app (i.e. so that my app appears as a target for opening tiff files from Mail or Safari). Adding the following to my Info.plist file doesn't seem to work:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>tiff</string>
<key>LSItemContentTypes</key>
<array>
<string>public.tiff</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
</dict>
</array>
I have an app that I associate with PDFs in the same way and it works fine. I believe that it is not possible to associate an app with the tiff file type on iOS, but I can't find any documentation stating that.
Has anyone else had luck getting this to work or finding a definitive "no, you can't do that"?
I burned an Apple TSI on this (I never seem to end up using them anyway) and the official answer is: no, you can't do that.
I've logged an enhancement request on Apple's bug reporting site: http://developer.apple.com/bugreporter/ and I suggest you do too if this issue is a problem for you.
Acorn declares file associations for TIFFs, which seems to work fine.
The only differences I could see between Acorn's implementation and yours is that Gus omits CFBundleTypeName and adds LSIsAppleDefaultForType (set to true). You might want to give that a try.
LSIsAppleDefaultForType is undocumented. There's a reference to it here: http://lists.apple.com/archives/cocoa-dev/2006/Jun/msg00747.html
An general note - the Mail and Safari apps indeed does not allow you to "open with .." tiff files (still true in iOS8);
Nevertheless, a lot of other apps, such as Dropbox, GDrive, etc, does allow you to do that.