This question already has answers here:
How to open a native iOS app from a web app
(5 answers)
Closed 7 years ago.
I was trying to create some web app using Framework 7. Everything's fine, but i'd like to be able to call an app from the Home Screen (for example, the Store or the News app).
I know that some APIs are published by Apple Inc, but I can't find a way to call an app from my PHP code.
The Web app is created to run in Safari.
I tried something like:
<script type="text/javascript" charset="utf-8">
window.location = "myapp://iMessage";
</script>
But it doesn't seem to be able to launch the app.
Before iOS 9
In order to open another app in iOS you need to know what schemes it supports. Not all apps use them, so not every app is openable this way. An example scheme that opens up AppStore looks like this :
itms://itunes.apple.com/us/app/apple-store/id375380948?mt=8
This will open AppStore on "Apple Store" apps screen. You can test this also by replacing itms with https and pasting in your browser. The itms part is the scheme, and the rest are the parameters passed to the app.
Since iOS9
Apps can register to handle "generic" URLS, so a URL like
http://9gag.com/gag/a1MXxR2 will be opened in 9GAG app (unless the user doesn't agree to it - he will be asked the first time he opens such a link in Safari, then it will be opened in Safari).
Note that not all apps support it yet, and there is no way (apart from asking the creators) to know if they ever will.
So to answer your question : there is no generic way to open a "random" app installed on someones phone. Especially not apps which don't support such opening via URLs (no matter whether with a custom scheme, or http(s)).
Some of the popular apps (Facebook, Twitter, Chrome, ...) publish their schemes and you can implement them, not all will do so.
Note: this all applies to non-jailbroken phones.
There's not a general purpose way to open any app. Opening a specific app requires that:
that app has registered to respond to a specific URL scheme (e.g. instagram://)
you know what the URL scheme is. Sometimes an app's URL scheme isn't publicly available.
I think "myapp://" scheme you're using was someone's example but doesn't apply to all apps.
Related
Google no longer allowing embedded webviews as it is a disallowed_useragent for OAuth sign in. For most situations, this is completely fine and there is a workaround. However, I have run into a situation where this prevents websites from being able to use a web-server OAuth implementation.
The Issue:
Nginx PHP server running the Google PHP SDK, using their O-Auth implementation. This works fine on everything except embed browsers. Typically this is okay, however, if a user tries to sign up to our website in an app which uses an embedded browser, we get the disallowed_useragent error (See picture at bottom). This doesn't appear to be a problem in Android Facebook Messenger but can be replicated on the iPhone 7 Plus Facebook Messenger.
Current Research:
I tried to look for explicit workarounds. E.g. ways to force the link to open in the primary phone browser (e.g. Safari app) but all implementations point to app side fixes, which can't be done from a website.
Question:
How can I implement Google Oauth when some users may be using these embedded browsers, without making the user to take an extra manual action (e.g. Open in Safari/Chrome)?
This question is very opinion based but I will give you my opinion.
How should I implement Google Oauth when some users may be using these embedded browsers, without making the user to take an extra action?
You cant really. If someone is using an embedded browser in Facebook messenger (embedded browser) to open your auth link its not going to work. To my knowledge there is no way to force or over ride Facebook messenger or any other app that uses its own embedded browser. Again this is just my opinion but there are a lot of apps out which have started forcing their users to use these embedded browser's. One could question how secure they are and that it is better to use the real installed browser. Do you think this is why google has enabled this to begin with?
I would like to avoid going down the road of detecting the user-agent web-side and force the user to open the link in Safari.
I don't know that sounds like a pretty decent solution to me. It may feel a like over kill a little but if it works go with it.
There's another scenario that is causing issues.
If you have a web app - not a native app with an embedded browser - the user can always choose to put the shortcut to the HomeScreen in iOS.
But when they go to that HomeScreen shortcut to run the app, it will strip "Safari/6xx.x" from the user agent string.
Now, Google sees this as an "Embedded Browser" and denies access to OAuth.
So - "No Web-App-Capable" for you!
If you turn off this meta tag:
<meta name="apple-mobile-web-app-capable" content="yes"/>
two things happen in iOS:
The website now opens in the Safari browser window instead of the cleaner Web-App method.
The website uses the complete Safari useragent which will allow OAuth to work.
The real shame here is that the decisions of Google (To deny non-standard browsers to access OAuth) and Apple (To remove the Safari version in the user agent for homescreen shortcuts) have backed us into the corner where any site that could look really nice in web-app mode can't utilize this OAuth from google.
I've been trying to find a way to spoof the user agent to add the safari version into it so that everything works in homescreen web-apps, but I don't think I can make it work. It seems that safari doesn't allow you to change the navigator.userAgent and on top of that, I'm not sure how it would handle new popup windows in WebApp mode.
I am building an app and because of my missing knowledge of java and Xcode I decided to make this app in HTML,PHP,CSS & javascript(jquery). Now I'm facing the problem of getting this app to the different devices and I want to use PhoneGap for that. I placed an index.html inside the server for the app and there is an iframe placed inside and nothing more. Is it still possible for me to get access to the media storage and send PHPdata back and forth while having an iframe as a bridge between PhoneGap on android and my website on its web server? Can I access the camera of the device?
The short answer: No, and you shouldn't try that.
The long answer (And the safer one) is to use postMessage as described in MDN, do it in a different way could cause inconsistency between devices (Remember how fragmented is android and how painful could be the backward compatibility with 4.3 and below)
So, you could get the iFrame element and then post a message like
otherWindow.postMessage(InfoToSend, "*");
In the same way, you could listen to that event inside the frame:
window.addEventListener("message", receiveMessage, false);
This will no cause cross-frame issues and it will be the safer way to pass information between the frames, this work in both directions, so you could ask (From inside your iFrame) to use some native feature (plugin), listen to this event in your device main app, executed what you need and after that send a postMessage (from your app) to your iFrame with the result (a base64 img for example)
If you are trying to pass the window.cordova the instance or something similar, it won't work, so you will need to establish a conversation between the iFrame and the window.top frame.
I use html5 + css3 + jquery mobile to built my mobile application. Actually I've already desktop version, and i want to make mobile application.
Is that true php wont work on html5 for mobile application?
If that true, i use ajax for call my JSON (that place create on jsontext.php).
I tried HTML5 on desktop browser and it worked.
I built it to apk using build.phonegap.com and install the apk to my device.
After that, my database record not showing. Maybe it didn't execute.
Other user in stackoverflow said we can use backbone.js. how-to-access-a-remote-database-from-jquery-mobile-application
are my steps right? or I have to use backbone.js. THX.
Here's some answers:
Yes, php won't work in a mobile native/hibrid mobile application,
because php needs to be interpreted by a php server before
generating output.
Its easy and simple to both generate and parse JSON, it's widely
used in apps.
That is good. If you want an 'online-only' kind of app, you can use
a webview and point it the url of your app - its basically a browser
without navigation buttons and user interface - but something's
don't work that well, you should test before. It may also display
your app as sluggish and unpolished.
No problem with that, Cordova/Phonegap is actually becoming a very
good mobile framework. You should also install ADB
(http://developer.android.com/tools/help/adb.html), ADT
(http://developer.android.com/tools/help/adt.html) and the Android
device emulator
(http://developer.android.com/tools/help/emulator.html).
You must be sure on how to insert and retrieve dabatase records.
This depends on how you programmed it. Be sure to have the database
available publicly (accessible only from the apps, though).
Hope I've answered your questions, and that it helped.
I have been working on a website that has a mobile version. Integrated into the site is a bit of code that allows users with FB to register without having to fill out a form. If the user meets any of the following conditions all is well
Uses ANY desktop browser
Users ANY mobile browser
The FB just works. However as soon as I do an 'Add to Homescreen' with IOS to make the app look and perform like a native app, when anyone uses the FB signup I get the
'Given URL is not permitted by the application configuration: One or more of the given URL's is not allowed by the Apps settings. It must match the Website URL or the Canvas URL, or the domain must be a subdomain of one of the App domains'
I am assuming that once you use the add to home screen, and the app gets its own instanced browser, the URL changes, likely some form of localhost derivation maybe?
I can't find any definitive answers to fixing this, and was wondering if anyone else had experienced this HTML5 IOS app problem?
Looks like the dev of the extension I was using will be working on a different authentication flow, so not giving this any more dev time
My question is pretty simple actually... I wish to know if, and how, it is possible to check for the existence of an application on an iphone (twitter app for example) and then pop it open via PHP and/or javascript.
The process would go as follows:
User scans a QR code with his Iphone that links to the page
On the page, php or javascript does some magic to check if, and what, twitter applications exist.
The page then sends a custom URL scheme to open up the desired app (twitter:// for example).
Is this possible? Are there any examples of source code that display javascript/php doing this from within the context of an iphone?
Thank you for any help. :)
It would be imposible to check for the existence of an app from Safari.
You may launch an app using a link if the app has registered a protocol. For example, to launch the Facebook app and open it on the user profile you may link to fb://profile.
Here I found a list of some other iPhone apps protocols:
http://wiki.akosma.com/IPhone_URL_Schemes