Keep getting alert view message of "Open this page in YourAppName?" when trying to launch app from safari
Asked Answered
G

2

10

I need to be able to launch my iOS app from the Safari browser. So I went to my .plist file in xcode and added an item to my URL Schemes and entered in the string of myappname.

Now if I go to Safari, and type myappname:// in the URL address bar and submit it, it shows me a UIAlertView that says Open this page in "MyAppName"? with options for Cancel and Open.

If I tap Open it successfully opens my app, however I want to do this without the UIAlertView popping up with that message.

I have done some quick searching online and it looks like people keep having trouble with this whenever a new iOS update comes out and I can't seem to find a recent solution or answer.

I am on an iPhone 4s with iOS 7.1, and I'm using xcode 5.1 if that makes any difference.

Also, I have been using an app available in the App Store called "Frontback" that successfully does this same thing without the UIAlertView showing in Safari so this is definitely possible.

Thanks for the help.

Guimpe answered 1/4, 2014 at 19:47 Comment(9)
what is an example of the url scheme you wish to use to open the app ? or is that irrelevant you just want to open the app when ever something like hi://this_is_my_app.coolThew
I guess that is irrelevant XDThew
The URL Scheme that I described above works perfectly. I just want to get rid of the UIAlertView.Guimpe
going about that method is impossible, to get rid of the alert view, iOS displays the alert view to keep you from opening malicious data with out getting your consentThew
Using traditional means I don't think it's possible. Is there non-apple app that already does this?Countrywide
I have been using an app available in the App Store called "Frontback" that successfully does what I think is this same thing without the UIAlertView showing in Safari.Guimpe
Maybe it's because my app is not actually in the app store yet?Guimpe
@Guimpe : did you ever solve this problem?Semibreve
@Bob I honestly don't remember. I know I finally got rid of it, but I don't think I actually solved it because that's just native Apple functionality.Guimpe
R
2

I use this method in my app without getting a UIAlertView. It just goes straight to the app.

I had a similar issue when I first started implementing it. I suspect that it's not a problem with myappname://, but possibly a problem with how you added the URL Scheme.

Make sure to assign your custom value (myappname) to the URL Identifier object (com.mycompany.myappname). The URL identifier should be a String and the URL Schemes should be an array with your custom value being a String.

The XML version of your .plist should look like this:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.mycompany.myappname</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myappname</string>
        </array>
    </dict>
</array>   
Religieux answered 10/1, 2015 at 19:9 Comment(2)
"I suspect that it's not a problem with myappname://, but possibly a problem with how you added the URL Scheme." - You are probably correct. I asked this a long time ago, and I think I just didn't know enough about what I didn't know to understand the issue.Guimpe
So you're able to open the app without the alert showing, just by using a custom URL scheme? Showing the alert seems like it's default behavior in iOS 9+. Would love to know if your approach works still because the alert still appears even when following this answer.Labialized
B
0

Here is how to avoid the "Open this page in YourAppName?" popup when using Universal links.

My observation is as follows:

  1. When using html links that the user needs to click then the popup does not appear.
  2. If you want to use window.location.href or window.location.replace to directly get back to the app without the user needing to click a link then it seems to depend on if is there is a delay before the redirect. If the page loads fast and you directly call window.location.replace then the popup will appear. However if you set a timeout to 400ms and then trigger window.location.replace then there will be no popup.

I found this when noticing that after a change and redeployment of the html page, the popup was not shown. This was the case for me because I use a cloudflare worker to host the html page and after an update the initial response time is about 400ms while it is just 15ms if requested again.

Bryan answered 14/1, 2023 at 8:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.