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

Fix broken system social share in Webviews and Opera UA detection #11556

Merged
merged 1 commit into from
Oct 4, 2017

Conversation

aghassemi
Copy link
Contributor

Fixes #11473

Chrome does not implement System Share in WebViews (See https://bugs.chromium.org/p/chromium/issues/detail?id=765923 ) but exposes navigator.share API (throws exception on call) so we now we have to use some UA detection to see if system share is supported or not.

Chrome 60+ also started sending OPR (opera) as part of user agent string, this PR also fixes that.

@aghassemi aghassemi merged commit 8541477 into ampproject:master Oct 4, 2017
@jridgewell
Copy link
Contributor

Why not just use a try catch? I dislike using UA detection if possible.

@cramforce
Copy link
Member

It can't be used here. The API pops out the system share UI if no exception is thrown.

@jridgewell
Copy link
Contributor

I thought it was the .share access that was throwing?

@aghassemi
Copy link
Contributor Author

aghassemi commented Oct 4, 2017

@jridgewell discussed here: https://bugs.chromium.org/p/chromium/issues/detail?id=765923 (comment #6 and #7). yes .share throws but if platform implements it properly, it popups the system UI. (we need to feature detect this at layout time to decide whether we can hide the non-system share icons or not)

UPDATE:
it is not the .share access but .share call that throws.

Copy link
Contributor

@dvoytenko dvoytenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

systemShareSupported_() {
// Chrome exports navigator.share in WebView but does not implement it.
// See https://bugs.chromium.org/p/chromium/issues/detail?id=765923
const isChromeWebview = this.viewer_.isWebviewEmbedded() &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also at least add a special case for the Facebook UA string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AMP-Social-Share Webview with replace
5 participants