damus icon indicating copy to clipboard operation
damus copied to clipboard

Deeplink launching to profiles and notes

Open BenGWeeks opened this issue 2 years ago • 14 comments

Showing a blank screen at the moment as damus_state not yet initialised I presume, but putting here so you guys knows this is pretty much done.

TO DO:

  • Resolve damus_state initialisation [RESOLVED]
  • Add instructions to Readme.md for users
  • Increased error handing in DeeplinkManager

Will accept commits to the fork! :-)

ChangeLog-Changed: Added deeplink ability (using nostr://io.damus.nostr/npub1jutptdc2m8kgjmudtws095qk2tcale0eemvp4j2xnjnl4nh6669slrf04x format) (@npub1jutptdc2m8kgjmudtws095qk2tcale0eemvp4j2xnjnl4nh6669slrf04x) ChangeLog-Changed: Added additional error handling to loading contact events (@npub1jutptdc2m8kgjmudtws095qk2tcale0eemvp4j2xnjnl4nh6669slrf04x)

BenGWeeks avatar Jan 05 '23 18:01 BenGWeeks

pretty sure we handle this already? I'm confused. see onOpenURL in ContentView

jb55 avatar Jan 05 '23 18:01 jb55

Oh - there's something in there! How do you get to fire off? Didn't think we had it implemented!

BenGWeeks avatar Jan 05 '23 19:01 BenGWeeks

it supports the old nostr:e:hexkey and nostr:p:hexkey thing but we should make it support npub and note

jb55 avatar Jan 05 '23 19:01 jb55

OK cool. Happy to update if you like (we now have that part)? I like the method on ContentView as well as that would also resolve the damus_status issue I was having.

Speaking on ContentView - looks to me that that could do with some refactoring and using navigation tabs - although that would be quite an update I think and maybe not needed now.

BenGWeeks avatar Jan 05 '23 19:01 BenGWeeks

Yeah I don't think nav is being done correctly, it uses a single stack which is probably wrong?

jb55 avatar Jan 05 '23 21:01 jb55

Yeah, I believe so ... but I'm no expert ... but it looks like one of those jobs you crack open and it ends up being quite a bit to sort it all out. I did actually start doing that with the design updates but soon realised we would have a merge nightmare ;-)

Updated this to work where the previous code was. It's now going to the profile page for a string such as (my nPub):

nostr://io.damus.nostr/npub1jutptdc2m8kgjmudtws095qk2tcale0eemvp4j2xnjnl4nh6669slrf04x

However, it's not loading correctly, so must be missing something at the moment. Will continue looking into it tomorrow but getting late here. I think it's something to do with the fact I'm passing the nPub as a string, but expecting hex or something.

Have abstracted the URL handler into DeepLinkManager although I haven't removed NostrLink as could be

BenGWeeks avatar Jan 06 '23 01:01 BenGWeeks

@jb55, you mentioned you were working on the sharing links going out ... is that going via the website that redirects to nostr:// if installed or directly to nostr://? What format are you using?

BenGWeeks avatar Jan 06 '23 01:01 BenGWeeks

I think profiles and notes not loading correctly are related to the ContentView in that another thread is running, and variables are being dynamically rewritten.

Propose that ContentView uses TabView, which has:

@State var activeTab = TabIdentifier.home

TabView() {
    HomeView()
        .tabItem { ... }
        .tag(TabIdentifier.home) // use enum case as tag
    DirectMessagesView()
        .tabItem { ... }
        .tag(TabIdentifier.messages) // use enum case as tag
    SearchView()
        .tabItem { ... }
        .tag(TabIdentifier.search) // use enum case as tag
    NotificationsView()
        .tabItem { ... }
        .tag(TabIdentifier.notifications) // use enum case as tag
}
.onOpenURL { url in
    guard let tabIdentifier = url.tabIdentifier else {
        return
    }
    activeTab = tabIdentifier
}

Some consideration is needed for jumping to a ProfileView().

This should make this application area significantly easier to maintain - although it requires quite a bit of refactoring to implement.

Ref: Adding TabView and tabItem()

Ref: Handling deeplinks in iOS 14 with onOpenURL

BenGWeeks avatar Jan 06 '23 11:01 BenGWeeks

I fixed profile and note loading in latest build! let me know what you think

jb55 avatar Jan 06 '23 22:01 jb55

Oooh - lovely, let me go look.

BenGWeeks avatar Jan 06 '23 23:01 BenGWeeks

I see the share :-) If I paste the link in Safari it goes to damus.io but then forwards to snort.social. Not sure why - but I think the we need to change the following (or value on the right I forget) to damus.io (and the corresponding value in DeepLinkManager class if you're still using that:

image

BenGWeeks avatar Jan 06 '23 23:01 BenGWeeks

that section is for uris. The feature we have now is universal links via domain association entitlement:

https://damus.io/.well-known/apple-app-site-association

If you click the link in the notes app, signal, telegram, etc it will open in damus.

Not sure why it doesn't work in some apps though.

jb55 avatar Jan 07 '23 15:01 jb55

testing link here... https://damus.io/note1ws6wdg3rgmgue2sjxqp3gkmql70nsvm4fphsgl6nr7km2y57tzpsd0gy6w

jb55 avatar Jan 07 '23 15:01 jb55

Do we want to /e/ and /p/ in the Url? (Saw that used elsewhere but technically don't need).

BenGWeeks avatar Jan 07 '23 18:01 BenGWeeks

this isn't a problem anymore right?

jb55 avatar Feb 08 '23 17:02 jb55