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

Add asyncOpenURL wrapper #3764

Merged
merged 2 commits into from
Jul 1, 2021
Merged

Add asyncOpenURL wrapper #3764

merged 2 commits into from
Jul 1, 2021

Conversation

luacmartins
Copy link
Contributor

@luacmartins luacmartins commented Jun 25, 2021

cc @chiragsalian @roryabraham

Fixed Issues

$ #3615

Tests

  1. Send a Request Money request from Account A to Account B (both accounts must have PayPal.me username set in Settings > Payments)
  2. Open Safari and log in to Account B.
  3. From Account B, click Pay and from the Dropdown select Pay with PayPal.me and then confirm the payment.
  4. A new window should open and
  5. Verify that you are redirected to Paypal.me and the handle is that of the user you owe and amount matches.

QA Steps

Steps above.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screen.Recording.2021-06-25.at.4.28.22.PM.mov

Mobile Web

web-mobile.mov

Desktop

desktop.mov

iOS

ios.mov

Android

android.mov

@luacmartins luacmartins self-assigned this Jun 25, 2021
@luacmartins luacmartins requested a review from a team June 25, 2021 22:51
@luacmartins luacmartins marked this pull request as ready for review June 25, 2021 22:51
@MelvinBot MelvinBot requested review from Luke9389 and removed request for a team June 25, 2021 22:51
@roryabraham
Copy link
Contributor

Slack thread for context: https://expensify.slack.com/archives/C01GTK53T8Q/p1623955103415500

cc @rushatgabhane

* @param {Promise} promise
*/
export default function asyncOpenURL(promise) {
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why are you doing a negative patten match for chrome or android here? Is there some case when the user agent would be formatted like 'chrome-xxx-safari' or something?

Copy link
Member

@rushatgabhane rushatgabhane Jun 27, 2021

Choose a reason for hiding this comment

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

@roryabraham
The negative pattern match is to exclude chrome, edge, and android.
All of them like to include Safari in their UA

Edge and Chrome's userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"

Also, I think all third party browsers on iOS are just skins for safari.
So chrome on iOS has this issue too. And this pattern detects that in my testing :)

Chrome on iOS detected as Safari

IMG_0430

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for answering this @rushatgabhane! Yes, that is the reason I used the negative pattern match. @roryabraham Do we have any other preferred method?

@@ -0,0 +1,10 @@
import {Linking} from 'react-native';
Copy link
Contributor

Choose a reason for hiding this comment

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

It's been a while so I'm not 100% sure, but does it work to provide an index.website.js for the web implementation and just index.js for all other platforms?

Copy link
Contributor Author

@luacmartins luacmartins Jun 28, 2021

Choose a reason for hiding this comment

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

@roryabraham It seems to work! Would that be preferred? If so, I will also go ahead and update the docs here. I only saw a handful of other modules where all of the files were used, but the code was actually unique to each platform.

*
* @param {Promise} promise
*/
export default function asyncOpenURL(promise) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what do you think about just providing the url as an argument to this function? Is that simpler/less prescriptive than this implementation, in which the promise needs to resolve to a url? Basically something more like this implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@roryabraham
Copy link
Contributor

Also, we should make sure to test on all platforms to ensure we don't introduce a regression on other platforms

@luacmartins luacmartins requested a review from a team as a code owner June 28, 2021 17:42
@MelvinBot MelvinBot requested review from Jag96 and removed request for a team June 28, 2021 17:43
@luacmartins luacmartins removed the request for review from Jag96 June 28, 2021 17:44
@luacmartins
Copy link
Contributor Author

Updated with requested changes and tests on all platforms.

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Okay, looks better to me.

@Luke9389 Luke9389 merged commit 056f968 into main Jul 1, 2021
@Luke9389 Luke9389 deleted the cmartins-async-link branch July 1, 2021 00:01
@OSBotify
Copy link
Contributor

OSBotify commented Jul 1, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@roryabraham
Copy link
Contributor

Unfortunately the deploy comments are not working right now. This was deployed to staging yesterday.

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

Successfully merging this pull request may close these issues.

6 participants