iOS Simulator WebApp/Bookmark for URL Scheme testing - ios

I'm testing a custom URL scheme in my app, and I'd like to add a homescreen icon that calls that url. Whenever I request my custom URL, it opens my app, and then reverts Safari's address bar to the previously shown URL.
I tried to skirt this issue by editing the properties of another URL, e.g.
Open Safari
Navigate to http://google.com
Tap the action button, and then "Add to home"
But this fails because you can't edit the URL assigned to the homescreen app.
As a fallback, I thought about just having a bookmark to the application, so I tried to bookmark a website and then edit the URL like this:
Open Safari
Navigate to http://google.com
Tap the action button, and then "Bookmark"
but this fails because on the iOS simulator, you can't edit the URL of a bookmark (although you can do this on the device for some reason).
update: As tkanzakic points out, you can edit user-added bookmarks, just not the predefined bookmarks
Ideally, I'd like a homescreen app, but would settle for a bookmark instead.
Also, due to firewall restrictions, I can't connect this device to my Apple account, meaning I can't sync my Safari bookmarks either.

Ah, figured it out. You can get a webapp on the homescreen pointing to any URL by following these steps:
In mobile safari, navigate to any webpage, tap the action button and make a home screen icon for this webpage.
Close the simulator
Open the directory /Users/<USERNAME>/Library/Application Support/iPhone Simulator/6.1/Library/WebClips
The webclips folder stores all the homescreen webapps; find the one you just created and open the Info.plist file in a text editor.
Edit the keys (such as URL and Title) as desired.
When you next relaunch the simulator, you homescreen webapp will point to the new URL.
Optionally, you can change the icon.png to change the webapp's icon.

As a fallback, I thought about just having a bookmark to the application, so I tried to bookmark a website and then edit the URL like this:
Open Safari
Navigate to http://google.com
Tap the action button, and then "Bookmark"
but this fails because on the iOS simulator, you can't edit the URL of a bookmark (although you can do this on the device for some reason).
That is not true, it is possible to change the URL a bookmark, check this article to see how you can do it. I have done this on the Simulator and on a Device.

Just create a small app (using Xcode) that opens the URL in its application delegate:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[application openURL:[NSURL URLWithString:#"myappscheme://whatever/"]];
}
Note that I'm using applicationDidBecomeActive: instead of applicationDidFinishLaunching: to make the launcher app work after it has been launched before.
Alternatively you could set UIApplicationExitsOnSuspend in the Info.plist to force termination.

Related

How to open my iOS App from Chrome via link?

The question is same as title, I already set the scheme for my iOS app and also open my app from Safari when I clicked the link. When I tried to set Chrome as my default browser then clicked the link, my app didn't open automatically or asked any permission to open it. Does anyone know what should I do?
I already put my apple-app-site-association(AASA) file on my server and set the scheme.

How to register a custom URL scheme that opens the app when placed into safari

I am trying to get to my keyboard's containing app from the keyboard extension itself. I have been following this tutorial but I am not sure if there is something I am missing.
This is what my info.plist looks like for the containing app
I have not adjusted the info.plist of the extension.
When I open safari and enter in the custom url, it says:
"Safari cannot open the page because the address is invalid"
Am I setting the identifier and scheme name properly? They can be whatever I want them to be as long as I spell it right when I need to use it right?
Did You tried this , it allows you to DepLinking your App with custom URL and Open App from Safari
https://github.com/ijoshsmith/swift-deep-linking

"Safari cannot open the page because the address is invalid" message appears when I try to launch my app from a website

Device : iPhone 5 / iOS 9.3
I have an iOS app which I need to launch from a website. I was able to do it via custom URL scheme.
When I click the "Open App" button in the website, an alert dialog appears that says "Safari wants to open MyApp" with OK & Cancel buttons.
Clicking OK : everything is just fine. The app gets launched from the website perfectly.
Clicking Cancel : First time, it just dismisses preventing the app being launched, which is correct.
When I click on the "Open App" button once again from the website, I expect the same "Safari wants to launch MyApp" alert dialog to appear once again, which is not happening.
Instead, it shows a dialog that says "Cannot Open Page - Safari cannot open the page because the address is invalid" with an OK button.
My assumption was, every time when you click on that link in the website (that can launch the app via custom url scheme), I should be prompted with "safari wants to open MyApp" alert dialog all the time.
What am I missing here ? Appreciate your help in advance.
It's a known behavior.
If you tap on facebook://feeds:
And open it then Safari won't blacklist the facebook scheme for that Safari tab. You would be allowed to open facebook://profile, facebook://feeds, facebook://settings, etc. on that tab
However if you click on 'Cancel' then you're no longer able to able any url with that scheme for that tab only ie you won't be able to open facebook://profile, because it's been blacklisted for that tab.
What should you do?
Open a new tab and try again. It would no longer be blacklisted for that tab.
It would have been much better though if Apple prompted its user with options like:
Deny once. Deny Always. Allow Always
But I'm guessing if they did that then they'd have to provide alternate ways for the user to customize behavior per host/scheme. Obviously Apple doesn't want to allow that.
I met the same problem when using Google Tag Manager in my code. Try the javascript event for opening the app instead of using the href of the tag a.
I was getting a similar error, fixed it by allowing "Installing App" in restriction(Settings->General->Restriction), enable the toggle button. It is by default enabled but I restricted it in past by disabling the toggle button.
Hope this helps anyone.
I just fixed the same problem on an iphone. Go to settings> General> Restrictions> Safari. Make sure it is "allowed" or turned on (swipe to green). Exit out of settings and retry. It should work.

iOS 9 Universal Links not launching the app from the same domain

I have setup my AASA JSON file to open the app when someone visits myDomain.com/ShowInTheApp/*
This works from Notes App, Email, Gmail App, Gmail web on safari and basically any other websites other myDomain.com .
When myDomain.com/chooseAppORweb.html contains a link to myDomain.com/ShowInTheApp/ , safari always opens it in the same tab, app wont get launched. I can tap and hold the link to show the context menu that contains an entry "Open In [My app name]" which will indeed launch my app. But not by single tapping on the link.
When I do the exact same steps from another domain, NOTmyDomain.com/chooseAppORweb.html always launches the app without issues.
Has anyone succeeded in launching the app consistently from the same domain using UL ?
Also, if there is an Apple's document that explains any of these behaviours, please share the link.
I'm not sure when Apple added this to their documentation, but it's explained on their Support Universal Links page, in the first note:
In iOS 9 and later, universal links let users open your app when they tap links to your website within WKWebView and UIWebView views and Safari pages, in addition to links that result in a call to openURL:, such as those that occur in Mail, Messages, and other apps.
When a user is browsing your website in Safari and they tap a universal link to a URL in the same domain as the current webpage, iOS respects the user’s most likely intent and opens the link in Safari. If the user taps a universal link to a URL in a different domain, iOS opens the link in your app.
For users who are running versions of iOS earlier than 9.0, tapping a universal link to your website opens the link in Safari.
(Emphasis added)
Essentially, once a user reaches a page hosted on your domain in Safari, any links they follow on your domain will be opened in Safari, even if they're defined as Universal Links by your app.
As st.derrick mentioned above, this is the in-place behavior for Universal links. If you have previously been taken to the App from the link, but then choose to be taken to the website when prompted with a long press, the functionality to open the App will break. You can remedy this by long-pressing again and choosing to open in-app. It's not an ideal solution, but it is the only way I've seen it be fixed. I hope this helps!

Link from App to an iTunes artist through button

I'm trying to link to an artists iTunes 'page' through a button on my project. I've tried to use their safari page e.g. "http://itunes.apple.com/au/artist/blink-182/id116851" and it worked once but it only showed their page in safari. I would like to direct them to the artists page on the iTunes store app. I have read other questions and they all seem to be how to link to an app on the app store, but nothing about iTunes store. Here is my code for the button:
-(IBAction)ofwebsite2 {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://itunes.apple.com/au/artist/blink-182/id116851"]];
}
I have tried adding itms:// instead of the http:// but that still didn't work.
Adding itms:// instead of http:// should work as this is the only proper way to do it.
Even if you leave it as http, it should open safari, then redirect to iTunes app.
And please note that this will only work in a device, not in simulator.

Resources