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

refactor: universal link handling in the sample app #181

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

Shahroz16
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Pull request title looks good 👍!

If this pull request gets merged, it will not cause a new release of the software. Example: If this project's latest release version is 1.0.0. If this pull request gets merged in, the next release of this project will be 1.0.0. This pull request is not a breaking change.

All merged pull requests will eventually get deployed. But some types of pull requests will trigger a deployment (such as features and bug fixes) while some pull requests will wait to get deployed until a later time.

This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...

This project uses a special format for pull requests titles. Don't worry, it's easy!

This pull request title should be in this format:

<type>: short description of change being made

If your pull request introduces breaking changes to the code, use this format:

<type>!: short description of breaking change

where <type> is one of the following:

  • feat: - A feature is being added or modified by this pull request. Use this if you made any changes to any of the features of the project.

  • fix: - A bug is being fixed by this pull request. Use this if you made any fixes to bugs in the project.

  • docs: - This pull request is making documentation changes, only.

  • refactor: - A change was made that doesn't fix a bug or add a feature.

  • test: - Adds missing tests or fixes broken tests.

  • style: - Changes that do not effect the code (whitespace, linting, formatting, semi-colons, etc)

  • perf: - Changes improve performance of the code.

  • build: - Changes to the build system (maven, npm, gulp, etc)

  • ci: - Changes to the CI build system (Travis, GitHub Actions, Circle, etc)

  • chore: - Other changes to project that don't modify source code or test files.

  • revert: - Reverts a previous commit that was made.

Examples:

feat: edit profile photo
refactor!: remove deprecated v1 endpoints
build: update npm dependencies
style: run formatter 

Need more examples? Want to learn more about this format? Check out the official docs.

Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests.

@Shahroz16 Shahroz16 requested a review from a team August 3, 2023 12:41
Comment on lines +205 to +221
NSURL *url = userActivity.webpageURL;
if (!url) {
return NO;
}
NSURL *universalLinkUrl = [NSURL URLWithString:@"http://www.amiapp-reactnative-apns.com"];

// return true from this function if your app handled the deep link.
// return false from this function if your app did not handle the deep link and you want sdk to open the URL in a browser.
if (([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"]) &&
[url.host isEqualToString:universalLinkUrl.host]) {
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
} else {
return NO;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

From my understanding of RN deep linking, the steps to take is:

  • Call functions on RCTLinkingManager object in your AppDelegate. Like the code before this PR was doing. RCTLinkingManager captures the URL and stores it for you to use later in javascript code.
  • Then, you can use the RN navigation module in your javascript code to handle a deep link.

This PR looks like it's suggesting that universal link deep links are handled manually in native code and skip RN deep link handling.

Is this PR to demonstrate a workaround that we need to do? Is there a way that customers can handle universal links in their app using javascript with our SDK? If both of those are true, I would suggest we create a feature ticket to improve upon a workaround and then I'm OK with approving this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your understanding of what it does is correct.

The use-case is if the app doesn't handle universal links open it in the browser. Currently, if the app doesn't handle the universal link it doesn't do anything.

It can be solved via JS code or by letting our SDK do it for you. If we do it via JS code it makes it look like it should be how its done? so handling it this way to show users SDK can do deep-link handling if their app doesn't do it.

I am open to ideas here. But this was made out of LJs ticket where she though SDK is broken because its not doing the redirection.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just wanted to highlight, if I remember correctly, we currently open universal links automatically to browsers if they are not supported by app in Android. So if we are considering any solution that recommends JS code to handle this, there will be inconsistency and might create confusions for some customers.

Copy link
Contributor

@levibostian levibostian Aug 7, 2023

Choose a reason for hiding this comment

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

Ok, from reading the responses, this sounds like we are trying to make this fix:

Expected behavior: app does not handle a universal link -> SDK opens the URL in the system browser.
Actual behavior: app does not handle a universal link -> nothing happens. Browser does not open the URL.

Because it's preferred that our RN SDK has an API that uses JS code more then native code, I would consider this proposed change to be a workaround. Therefore, I am OK with merging this PR and us making a ticket for improving this in the future.

We do have a feature request for improving RN deep link handling already. I'll add a note to that ticket. If someone believes this is a different problem, please create a separate ticket.

@Shahroz16 Shahroz16 merged commit 153228c into main Aug 8, 2023
6 checks passed
@Shahroz16 Shahroz16 deleted the shahroz/universal-link-redirection branch August 8, 2023 07:28
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.

3 participants