Opening an iphone app from PHP/Javascript coded website/page - php

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

Related

How to force user to open my website in safari when they access my wordpress site

My website has Facebook log in function, which does not work if user views my site on facebook app, messenger app, iOS chrome app, Gmail app of iPhone.
Therefore, I need to force user to open site on Safari in such case.
Is there any way to do that? My site is built by wordpress.
Thanks!
UPDATE 1: I am thinking about a javascript to detect if users is on iOS, then pop up a javascript to ask if user wants to view on safari. Is it possible?
If you are in an Apple app like Mail, Messages, Notes etc. It will open with Safari, but if you are in another app eg. Facebook, Twitter, anything developed by a developer, you can't choose how you want to handle URLs in their app, that is up to the developer, and as a developer and Apple guidelines, it is best to open URLs in app so that the user don't leave your app. They use Safari anyway as UIWebView is a component of Safari, and we use UIWebView to browse inside our apps. (This can be manipulated, but still doesn't change the answer as to where you can't control how to handle links inside apps.)
It's not possible to open a specific browser (Safari in your case) from a website.
If you're working on an app, you might want to have a look at SFSafariViewController.
Have a brief idea about different kind of webviews in iOS here

PHP Api iOS - Launch app from PHP code? [duplicate]

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.

Share mobile logged in user details with PHP session

I am working on a mobile site that will run alongside a mobile app being developed by another company. My product manager has provided a spec, in which she is mentioning two options to implement a feature:
Clicking on button from mobile app will open mobile browser, where the user will need to login again, and proceed to perform required action.
Clicking on button from mobile app will open in-app browser, user does not need to login, and completes the entire flow and closes the in-app browser.
My question is: I do not understand difference between mobile browser and in-app browser. Does in-app just mean mobile browser opened from inside the app? And if that is so, then using PHP will I be able to recognize the current login in the app? or is there any way I can ask the mobile team to set a session when they open the "in-app" browser such that I can access that session and determine who is logged in?
As you can see, I am pretty ok with PHP and server side coding, but my knowledge of these new mobile technologies is very poor...I guess I am getting just too od for this job now.. sigh.
Any pointers are very much appreciated.
I think by in-app browser he has meant WebView which opens web pages as a part of application
This question seems to be duplicate although here is the ans you probably need.
Android WebView VS Phone Browser
Have you any doubts left?
mobile browser: a complete application inside the mobile device. Common examples are Chrome, Firefox mobile, Opera Mobile.
in-app browser: it's an instance of WebView. That's a normal view inside your app layout that is able to render web-content.
To open the webview as a currently app-logged user, you generally will add some token parameter to the URL that the web development team can use to identify the user on the server.
The WebView generally behaves like a browser, but you should implement a WebViewClient to properly steer some of the navigation patterns to make sure it behaves inside your app, the way your app should.

IOS HTML5 app Facebook Login failure when 'Add to Home' screen used

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

Android and Javascript: How to know in javascript that an application is installed in the Android device or not?

I have an android app on Google Play and also an website where.
For the moment, I am using javascript to detect if the device connected to the website is an android device. If is, I am displaying a popup dialog on the device inviting the user to download the app from the PlayStore. If the user clicks ok, he will be redirected to the PlayStore page of my app, I f he clicks no, he will continue using the browser.
Now, the problem is that when the user have installed the app and tryes to access the webpage again, he will be asked again to download the app, even if he allready installed it (which is not a good idea).
Do you know a solution on how to check if the user has allready the app installed on his mobile device?
It is also possible to do android detection with php, so if you have a method with php to detect if the app is installed, I can also use it.
Thank you very much.
I don't think this is possible for security reasons. I would not want some random website I visit to be able to access my phone Package Manager and find out what apps I have installed.
This would raise a lot of privacy and security concerns.
But I saw one answer that might have a different way of achieving your intent that might be useful to you:
https://stackoverflow.com/a/12901352/1369222
Even if the user doesn't install your application, your web site shouldn't ask more than one or two times to download your application from the PlayStore. The usual way of doing this is to use the browser's cookies in order to remember if it's a new visitor or not. It's not full proof because the cookies functionality could have been deactivated but at least, you won't have to worry about this problem for most of your visitors.

Categories