Opening a jpeg image from mail app into my iOS app - ios

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.

Related

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.

Custom URL works in simulator but not on a device

I went through and followed this tutorial to use Custom URL. Everything works as expected on Simulator, so when I use safari and hit myApp:// a dialog pops up asking if I wish to open the app. SO far so good. However, when I installed the app on a device and hit the same thing in safari I get an error saying Cannot open page. Safari cannot open the page because the address is invalid. I tried this enough times, so it's definitely not a typing error. Any help is greatly appretiated.
.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.xyz.myApp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>iOSMyApp</string>
</array>
</dict>
</array>
I copied my bundle identifier for CFBundleURLName.
ANSWER: So just before I was about to bang my head on the desk what I found that it's working when I open a new tab in Safari and then hit the app URL. And I have no idea why this happens. Also if you cancel it and then hit the app URL in the same tab again, it will give you an error I mentioned in the question. So the trick is to hit the app URL in a fresh tab everytime.
This setup is working for me. One thing I have to do is close the current tab of safari and open new one and type
iOSMyApp://

Change App icon dynamically [duplicate]

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.

Can I change app icon programmatically

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.

Associate image file types (UTIs) with iOS App -- Doesn't show 'Open in...' in mail / safari [duplicate]

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.

Resources