如何通知网站安装了应用程序?

如何通知网站安装了应用程序?

问题描述:

When user enter my site they receive a dialogue box proposing to install my wonderful app. When the user presses the accept button, the play market page with my app pops up. This dialog box appears only if user browses from phone. However, this dialog will popup even if user has my app already. Thus, I am interested in a way to inform site about presence/absence of an app on the phone. If app already installed on a phone, dialog should not appear.

phone w/o app -> browse site -> get dialoge box
phone with app -> browse site -> normal browsing

Simple and useless solution which comes in mind: If link is opened from my app, it is extended with some action to identify that app is installed.
It is useless, because app is all-sufficient, so opening site will not give any benefit.

A bit more advanced idea was proposed by msh: Give user an option which app will open a link. If link is opened with my app as above.

Is there a better way to do this ?

Yes, Mobile Browsers (on their own) cannot communicate the application installed status to web. But still if you are desperate to implement this behavior, I have got a "WILD" solution for you.

This Solution is divided in two parts: Client Side (Android Device) / Server Side (Web)

Client Side (on Android Device):

In your application you'll need to implement a BroadcastReciever that will be continuously listening to the Network State changes. Whenever a broadcast is received for new network connection available (e.g. when the user turns on the Mobile Data), your app should read the acquired IP address and communicate it to your web-server (using HttpURLConnection).

Communicating the IP address will inform your web-server that the device browsing your website from this IP address has got your application installed.

Server Side (on Web Server):

Your web-server will keep a track of all the IP addresses reported by all the devices on which your application is installed(off-course in a database). To avoid redundant entries you can decide a expiry/validation time for each IP address record received.

Now when your server receives a web request, it will match the IP of the requesting client with all the IP's that were saved in its database. If it finds a matching IP, it means that the web request has come from a device on which your application is already installed. Otherwise you can direct the user to your app's play store link.

Limitation of proposed Solution: This solution will work with 100% accuracy only in the case when the user is using Mobile Data (2g / 3g / etc) to connect to internet. Since using Mobile Data, everytime the device will be issued a unique IP address by the service provider.

This wont work perfectly for wi-fi connections. While browsing using a wi-fi, all the devices that are connected to same wi-fi spot are allocated the same IP address. So there may be a situation where two mobile phones are using internet from same wi-fi spot, out of which one phone has your application installed and the other phone does not. This will confuse the server.

** This solution may not be highly recommended, but could be used with some minor fixes if you don't get any other solutions ;)

It is not possible of course, browser doesn't leak phone configuration and installed apps to random websites (I hope, or somebody has to fix it ASAP)

You can probably make your app react to the VIEW Intent with certain URL then redirect to that URL on your site, but that will make Android ask the user whether they want to open this URL with your app or the browser, so it is not transparent

You could have two seperate urls like: www.yousite.com and www.app.yoursite.com. This way at least the users are free of the popup from the app.