iOS application ExternalHosts - ios

I'm developing an app using phonegap/cordova (1.7.0), I can't figure out how to make my application work with a less restrictive option than *. If I try setting www.mywebservicedomain.com or *.mywebservicedomain.com it can't retrieve data anymore. I see many questions about this and the general answer is to just set *. I'd like to understand how to be more restrictive, if it is possible.
Thank you in advance for your efforts.

That is indeed possible. But be aware that redirects on the servers may lead to connections to different domains which you also have to specifiy. Luckily those restricted accesses appear in the debug log in xcode. Run the project on the simulator or the device from within xcode and then you will see which requests to which servers got blocked.
In the cordova.plist it should look like this:
<key>ExternalHosts</key>
<array>
<string>*.googleapis.com</string>
<string>*.gstatic.com</string>
</array>
I use Google maps in my project which uses the described redirect. Thus I had to add the gstatic although my requests point to maps.googleapis.com originally (I use cordova 1.7).

Related

How do I find an apps/websites Deep Link?

I have a cordova app which uses the AppAvailability Plugin (https://www.npmjs.com/package/cordova-plugin-appavailability) and I have to find out if a specific app is installed. Its easy on Android, since I just know the packagename, but on IOS I have to know the URI Scheme or the DeepLink (eg. myapp://).
But I just seems to not be able to find out how to get it. Example is the asos.com.au website and their app. The Package name is 'com.asos.app', so that part is solved.
But if you go on the website (or in my usecase, if you are forwarding to their website) it opens the app if is available. And if it is available I want to have my app know that it wont redirect to the website (this is actually pretty important).
So, on IOS I have to know this URI Scheme.
Any Ideas?
This sounds like asos.com has implemented deep linking, and indeed http://www.asos.com/apple-app-site-association is present and looks good. Find more documentation here: https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html

Open in "(null)"? dialog in iOS 9

So I'm trying to add a custom URL scheme to my app. Everything works. The confusing part is that when a user gets redirected it puts up a dialog box that says:
Open in "(null)"?
I can't figure out why it says null and not the name of the app. The only other spot I've been able to see this issue mentioned is here:
'Open this page in "null"' Modal appearing from FacebookSDK login after iOS9 and Swift 2 upgrade
but that talks about updating to the latest SDK. It does mention whitelisting the scheme which I tried doing using LSApplicationQueriesSchemes but that doesn't seem to fix it either.
So in my case it ended up being that the following had gotten added to my Info.plist:
<key>CFBundleDisplayName</key>
<string></string>
Either removing this key or giving it a non empty string value fixes the issue and causes it to give: Open in "name of app"?.
The value in that dialog is specified in Build Settings -> Packaging -> Product Name. By any chance, is that field somehow blank? Usually the build should fail if so, and presumably you'd have also noted something wrong on the homescreen, but who knows!
As a side note, URL schemes are not a fool-proof way to handle deep linking anymore, and are actually actively discouraged by Apple. At minimum, you also need to implement Universal Links, but even that is not a complete solution because of variations in how other apps (Facebook, etc) handle outbound links. You may want to consider a tool like Branch.io (full disclosure: I'm on the Branch team) to give a hand with all the logistics.
I found this about whitelisting urlschemes for iOS 9 (found answer here)
Any app built with SDK 9 needs to provide a LSApplicationQueriesSchemes entry in its plist file, declaring which schemes it attempts to query.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>
This worked for me in getting rid of that.

Long list of domains in iOS Entitlement file in iOS 9.0-9.2

We have a need to support 100+ domains in our entitlements file for Universal Links.
Example:
applinks:test.myapp.com
applinks:blah.myapp.com
applinks:foo.bar.com
etc...
I know that *.myapp.com will be supported in iOS 9.3, but is there a way to do this elegantly for customers using iOS 9.0 to 9.2 without having to manually add 100+ entries to the entitlements file? Is there a way to do this without having to rebuild and re-release our app every time we need to add a domain to the list?
Thanks!
The new wildcard support in iOS 9.3 is designed for exactly the situation you're describing, so there isn't really a solid alternative in earlier OS versions.
If you don't want to worry about continually updating the list of subdomain applinks entries (or even if you do, but need to wait for App Store review), the best workaround is probably hosting fallback pages on each subdomain with a call-to-action the user can use to continue into the app. That would work as follows:
Assume that you have applinks:mydomain.com configured.
User opens a link to new.mydomain.com/exciting-page (which is NOT covered by the entitlement above).
User sees a custom interstitial, functionally similar to something like this. On this interstitial is a link pointing to mydomain.com/new/exciting-page
User opens the link and the app launches.
The only thing I am not sure about is whether mydomain.com and new.mydomain.com count as 'different domains' for the purpose of Universal Links, since Universal Linking functionality is disabled in Safari for links within the same domain (source). If this turns out not to work, you could easily use something like applinks:mydomain.io and a link to mydomain.io/new/exciting-page in step 3 instead.

Angularjs http.jsonp iOS9 404

I have a Cordova Angularjs app that is getting some JSON from my server. It works on iOS 8, but when I "upgraded" to iOS 9 I am now getting nothing from my server. The server has not been changed, and I can see the JSON response if I navigate to my url.
I narowed it down a little to my $http.jsonp() method. It is giving me a 404 error when trying to retrieve the JSON. The same exact code works fine and gets the JSON on an iOS 8 device.
Anyone else having an issue with this and iOS 9 and have figured any more out? It definitely seems like an Apple related issue...
Add this to your info.plist file.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
From this page
App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.
This has been turned on by default in iOS9. They suggest developing using https whenever possible. To get around that you would need the previous code in this answer.

Defining Facebook URL Scheme at compile time on iOS

This question could also be a general "How to change info.plist contents at compile-time" but I know it's a complex issue that is handled differently on iOS and MacOSX. The thing is that specifically when working with the Facebook SDK, it feels kind of wrong supplying my FB app-id twice - once in the "URL types" dictionary under "URL schemes" in the app's info.plist and once in my code. I want to be able to change the app-id dynamically from within my code without touching the info.plist file. I looked into Apple's launch services and found a potentially helpful "LSSetDefaultHandlerForURLScheme" method, only to find out that I was looking at the MAC developer library. I saw some other SO questions about this issue but the general opinion seems to be that this is not doable. Any ideas that don't involve pulling information out of the plist at compile time? (I want to be able to support several app-ids that are defined in a specific header file in my code).
Thanks!

Resources