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

feat(iOS): added custom URL schemes handling in the AppDelegate class #969

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

CampioneDev
Copy link
Contributor

Until now, only "associated domains" were handled, using the application_continue function, implementing this Swift method from the UIApplicationDelegate class.

For custom URL schemes, I added a new application_open_url function that implements the signature of this other Swift method.

The code of the pre-existing application_continue function has been moved into a separate handle_deep_link function so the new application_open_url function can call it as well.
For now, I believe it's appropriate to use the same Event::Opened event in both situations. Since the scheme is part of the URL, a listener can differentiate between them if needed.

Tauri: this change works automatically with the "Deep Linking" plugin without further modifications.
Custom URL schemes in mobile apps are essential, for example, when dealing with OAuth redirect URLs.

@CampioneDev CampioneDev requested a review from a team as a code owner August 28, 2024 11:09
@amrbashir amrbashir requested a review from pewsheen August 28, 2024 14:56
Copy link
Contributor

@pewsheen pewsheen left a comment

Choose a reason for hiding this comment

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

@CampioneDev Thanks for the contribution! I have tested it, and it works on my side 👍

Before we merge this PR, we'll need you to do some trivial things:

@CampioneDev CampioneDev force-pushed the ios-custom-url-scheme branch 2 times, most recently from 7a548ea to 7155955 Compare August 30, 2024 16:30
@CampioneDev
Copy link
Contributor Author

Thanks!

(BTW This is my first PR and contribution to OSS ever... I hope everything's ok, and sorry for the force-pushed mess)

@CampioneDev CampioneDev requested a review from pewsheen August 30, 2024 18:09
Copy link
Contributor

github-actions bot commented Aug 30, 2024

Package Changes Through 373e133

There are 1 changes which include tao with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tao 0.30.0 0.30.1

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@FabianLars
Copy link
Member

I also requested @lucasfernog's review because of his involvement in deep links and as the author of #752

CampioneDev and others added 2 commits September 2, 2024 17:13
Until now, only ["associated
domains"](https://developer.apple.com/documentation/xcode/supporting-associated-domains)
were handled, using the `application_continue` function, that implements [this
Swift method from the `UIApplicationDelegate`
class](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623072-application).

For [custom URL
schemes](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app),
I added a new `application_open_url` function that matches the signature of
[this other Swift
method](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application).

Most of the code of the pre-existing `application_continue` has been moved
into a separate `handle_deep_link` function so the new `application_open_url`
can call it as well.

I believe using the same `Event::Opened` event is appropriate in both
situations. Since the scheme is part of the URL, a listener can differentiate
between them if needed.

**Tauri:** since we are emitting the same `Event::Opened` event, this change
works automatically with the ["Deep Linking"
plugin](https://v2.tauri.app/plugin/deep-linking/) without further
modifications.

Custom URL schemes in mobile apps are essential, for example,
when dealing with OAuth redirect URLs.
@CampioneDev CampioneDev force-pushed the ios-custom-url-scheme branch from 2946e1a to 373e133 Compare September 2, 2024 15:13
@lucasfernog
Copy link
Member

Thanks!

(BTW This is my first PR and contribution to OSS ever... I hope everything's ok, and sorry for the force-pushed mess)

your first OSS contribution is a objc-in-rust PR? omg that's impressive

@lucasfernog
Copy link
Member

my first contribution was a dumb issue like "hey you need to fix this typo" people almost deleted my GitHub account 😂 😂

Copy link
Member

@lucasfernog lucasfernog left a comment

Choose a reason for hiding this comment

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

well done!

@lucasfernog
Copy link
Member

I'll force merge this one but would be great if you could setup commit signing in the future (even for your own personal usage!)

@lucasfernog lucasfernog merged commit ad652e5 into tauri-apps:dev Sep 3, 2024
9 checks passed
@github-actions github-actions bot mentioned this pull request Sep 3, 2024
@CampioneDev CampioneDev deleted the ios-custom-url-scheme branch September 5, 2024 07:59
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.

4 participants