Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguishing mobile app vs mobile web #179

Closed
hgani opened this issue Sep 14, 2015 · 5 comments
Closed

Distinguishing mobile app vs mobile web #179

hgani opened this issue Sep 14, 2015 · 5 comments

Comments

@hgani
Copy link

hgani commented Sep 14, 2015

Hi,

Is there a way to distinguish between a request made from a mobile browser (e.g. Safari in iOS) and one made from a webview within an app?

Thanks

fnando added a commit that referenced this issue Sep 14, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.
fnando added a commit that referenced this issue Sep 14, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.
fnando added a commit that referenced this issue Sep 14, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.
fnando added a commit that referenced this issue Sep 14, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.
@fnando
Copy link
Owner

fnando commented Sep 14, 2015

I just tried iOS simulator and the iOS webview doesn't include the Safari/:version part. I'm relying on this to make the detection. Can you try the ios-webview branch?

fnando added a commit that referenced this issue Sep 14, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.
fnando added a commit that referenced this issue Sep 14, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.
@dgilperez
Copy link
Contributor

+1 (thanks for a great gem, and sorry I cannot try it myself)

@dgilperez
Copy link
Contributor

Also, what about Android webview? It looks this is well documented: https://developer.chrome.com/multidevice/user-agent#webview_user_agent

@samsonasu
Copy link

+1, but I don't think that browser.safari? should return true for the webviews. Our use case involves OTA enterprise app distribution which doesn't work in the webviews and requires standalone safari, which the UIWebKit is decidedly not.

I can understand how this could cause problems for existing apps, but I believe the correct implementation is not to consider a UIWebView as safari, especially considering the UA for the webviews doesn't include the string "Safari."

fnando added a commit that referenced this issue Dec 30, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.

There's one implication: iOS webviews or Safari Web Apps aren't detected as Safari, because they don't include the `Safari` string.
@fnando
Copy link
Owner

fnando commented Dec 30, 2015

@samsonasu agree. I changed the detection of webviews and web apps; they aren't detected as Safari anymore. This will require a major versioning bump and warning message, but that's how I think it should be.

fnando added a commit that referenced this issue Dec 30, 2015
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.

There's one implication: iOS webviews or Safari Web Apps aren't detected as Safari, because they don't include the `Safari` string.
@fnando fnando closed this as completed in d8ef4af Dec 30, 2015
fnando added a commit that referenced this issue Dec 30, 2015
Detect iOS apps webview. Close #179.
ellimist pushed a commit to ellimist/browser that referenced this issue Mar 15, 2017
The user agent from an app webview doesn't include the `Safari/:version` part. We can possibly detect if request is coming from an app's webview if it doesn't include this string.

There's one implication: iOS webviews or Safari Web Apps aren't detected as Safari, because they don't include the `Safari` string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants