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

Conference deep link for iOS #1222

Merged
merged 20 commits into from
Apr 16, 2024
Merged

Conversation

StylianosGakis
Copy link
Collaborator

For iOS:
I got into the docs here https://developer.apple.com/documentation/xcode/supporting-associated-domains#Add-the-associated-domain-file-to-your-website

And looked into how this looks like from firebase for the Hedvig app https://hedvig.page.link/.well-known/apple-app-site-association

Then the article here mentions that the identified before the app’s package name is the teamID. So for “appID” it should be “$teamID.$bundleID”.
Not 100% confident this is correct, but when I opened the Xcode project, for the team it said “Unknown name (NT77748GS8)” so I assume either “NT77748GS8" is the right name, or something that only exists on my machine for some reason. This we need to ensure before moving forward. From some forum they say that it should be visible under https://developer.apple.com/account/#/membership and then “This will get you to your Membership Details, just scroll down to Team ID”, so I guess John is the only one who can see this to confirm.

StylianosGakis and others added 13 commits March 29, 2024 21:10
As specified here
https://developer.android.com/training/app-links
Handles links that look like `confetti://conference/{conferenceId}`.
I'll make a separate PR
This reverts commit 4e3f302.
Also turn autoVerify to "true", which along with this PR should not
require anyone to manually do anything for Confetti to handle those
links.
iOS will not get the URL directly on app startup before the component is
created, so we need to do this after the fact.
…ce-deep-link-for-ios

# Conflicts:
#	shared/src/commonMain/kotlin/dev/johnoreilly/confetti/decompose/AppComponent.kt
@StylianosGakis
Copy link
Collaborator Author

d67084a seems to have worked.
Video recording below:

Screen.Recording.2024-03-30.at.2.09.21.AM.1.mp4

Copy paste this to test yourself too if you want
xcrun simctl openurl booted "https://confetti-app.dev/conference/kotlinconf2023"
Change the conference name to whatever you want it to be.
Also tried with kotlinconf2023 which does not exist yet to show the error scenario too

@StylianosGakis StylianosGakis marked this pull request as ready for review March 30, 2024 01:20
@StylianosGakis StylianosGakis changed the title Conference deep link for iOS draft Conference deep link for iOS Apr 7, 2024
With this change whenever a deep link is received, we create a
completely new AppComponent so that we start from a clean slate.
In order to be able to observe this change from SwiftUI we also store a
local @State object which we increment at the same time in order to
trigger a re-render of the View.
This is absolutely a hack and we should find a better approach as soon
as possible
Base automatically changed from stylianos/conference-deep-link to main April 7, 2024 19:07
@StylianosGakis
Copy link
Collaborator Author

StylianosGakis commented Apr 7, 2024

Current behavior of the deep links, with Decompose 3.x, showing deep links being handled even if the app was closed before, or open before.
https://github.com/joreilly/Confetti/assets/44558292/7830aa60-981c-49b9-b35f-351a92fe9324

I do not know if there's something equivalent to "process death" I can test for here? :D

Turning this back into a draft so that we can handle two things better:

  • Destroying the old component's lifecycle when we are no longer using it.
  • Figuring out a way to make AppComponent properly observable to remove the reRenderIndex hack

@StylianosGakis StylianosGakis marked this pull request as draft April 7, 2024 19:24
Handles cleaning up old state after a deep link where we want to start
over with a clean slate
Now when there is a new deep link the appComponent inside the
ObservableObject changes and the UI which observes it with
@ObservedObject automatically gets informed about this and updates the
state of the UI
@StylianosGakis StylianosGakis marked this pull request as ready for review April 14, 2024 18:18
@StylianosGakis
Copy link
Collaborator Author

StylianosGakis commented Apr 14, 2024

The current behavior after commit c79600a with observable object and all working

ios-deeplink-working.mp4

@@ -11,17 +11,41 @@ import ConfettiKit

class AppDelegate : NSObject, UIApplicationDelegate {

let root: AppComponent
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could conform AppDelegate to ObservableObject for simplicity? And just make this root property @Published var. Can you try that? If for some reason this is not possible or not working, then maybe move the AppComponent creation and replacing logic to AppComponentHolder?

Otherwise looks good!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm yeah I didn't try to make AppDelegate an ObservableObject since I wasn't sure if that would be a weird thing to be that and an UIApplicationDelegate at the same time. I will give that a shot.

If that does not work for whatever reason, when you say "maybe move the AppComponent creation and replacing logic to AppComponentHolder" I assume you mean so that AppDelegate just calls a small function in init() and on onConferenceDeepLink so that the bulk of the work is done in there instead.

Will pick this up some next week, hopefully earlier rather than later inside of it. Thanks for the feedback 😊

Copy link
Contributor

Choose a reason for hiding this comment

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

when you say "maybe move the AppComponent creation and replacing logic to AppComponentHolder"

Yes. Just create the AppComponent together with its ComponentContext and Lifecycle inside AppComponentHolder. And also add onConferenceDeepLink to AppComponentHolder instead, and call that from AppDelegate. I think this would be cleaner. But the first option with conforming AppDelegate to ObservableObject sounds even better.

Copy link
Collaborator Author

@StylianosGakis StylianosGakis Apr 15, 2024

Choose a reason for hiding this comment

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

Hey making AppDelegate conform to ObservableObject just worked, after fighting with it for a bit 😅 Thanks for your tips!

Make AppDelegate conform to ObservableObject to allow to directly mark
the AppComponent as @published
Then ConfettiIosApp can receive the AppDelegate as an @ObservedObject
and use that published appComponent to pass into ConfettiApp
Copy link
Contributor

@arkivanov arkivanov left a comment

Choose a reason for hiding this comment

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

Thanks!

@joreilly joreilly merged commit 5371ca2 into main Apr 16, 2024
5 checks passed
@joreilly joreilly deleted the stylianos/conference-deep-link-for-ios branch April 16, 2024 06:14
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