damus-io / damus

iOS nostr client
GNU General Public License v3.0
2k stars 289 forks source link

Push notifications: Handle logout/login #1707

Open danieldaquino opened 1 year ago

danieldaquino commented 1 year ago

Acceptance criteria:

jb55 commented 1 year ago

On Mon, Nov 13, 2023 at 10:53:31AM -0800, Daniel D’Aquino wrote:

Acceptance criteria:

  • If the user logs out of their Nostr account, they should stop receiving push notifications from that account
  • If the user logs into a new Nostr account, the push notification server should start sending that user notifications of that new account

Wouldn't you still want push notifications regardless of which account your logged into? We would just need account switching functionality so that damus can switch to the appropriate account.

Although we would probably need per-user notification settings to control this.

danieldaquino commented 1 year ago

Wouldn't you still want push notifications regardless of which account your logged into? We would just need account switching functionality so that damus can switch to the appropriate account.

That would make sense if the user manages more than one account at the same time.

I was imagining use-cases where the user temporarily logs into their account on their friend's or family member's device, or someone who created an account but wants to switch to a new one (and "abandon" the old one).

Besides, I imagine that some of the other push notification functionality (e.g. decryption of DMs in push notifications) would only work for the user that is logged in.

However, you pointed out a useful use case. I imagine this would be better managed if we have multi-user support (similar to how Google allows someone to login to multiple accounts from the same browser), because then the user can control whether they want to be logged into 2 accounts, or if they specifically want to logout of their account.

jb55 commented 1 year ago

On Mon, Nov 13, 2023 at 02:07:07PM -0800, Daniel D’Aquino wrote:

I was imagining use-cases where the user temporarily logs into their account on their friend's or family member's device, or someone who created an account but wants to switch to a new one (and "abandon" the old one).

good point. I wonder how most apps handle this, probably on logout like you mentioned...

alltheseas commented 2 months ago

Customer feedback:

Hey weird bug. I enabled push notifications. Then logged out and signed into a different npub. But later I received a push notification for the first account. I checked iCloud but didn't see any stored data for Damus. Is there somewhere else that app cache could have held onto causing previously logged in account to still trigger a notification? Thanks

https://damus.io/nevent1qqsdqthsh3vaqcp6g0f5x78sezl4su63ak58j346kej3rxr540g53dqpzpmhxue69uhnzdps9enrw73wd9hszxrhwden5te0wahhgtnnw4jx7cmpwfkx7uewvdhk6qgjwaehxw309ac82unsd3jhqct89ejhxqgjwaehxw309amk7apww468smewdahx2wnz629

jb55 commented 2 weeks ago

Another:

https://damus.io/nevent1qqs9rcxh7j8z48863pv7p9sgwj202ys3z6yt8q03zkvpdmltkslejespzemhxue69uhhyetvv9ujuurjd9kkzmpwdejhgqgkwaehxw309aex2mrp0yhxummn9eek7cmfv9kqzynhwden5te0wp6hyurvv4cxzeewv4esz9rhwden5te0wfjkccte9ejxzmt4wvhxjmccf5s9v

danieldaquino commented 2 weeks ago

@jb55 @alltheseas I have the basic idea of the solution on the back of my mind, so I decided to quickly create a rough draft of what the solution might look like: https://github.com/damus-io/damus/pull/2644

That draft PR is completely untested, and I haven't really addressed edge cases, but I added the draft to help whoever is going to work on this (whether that's future me or someone else)

danieldaquino commented 2 weeks ago

@jb55 @alltheseas I have the basic idea of the solution on the back of my mind, so I decided to quickly create a rough draft of what the solution might look like: #2644

That draft PR is completely untested, and I haven't really addressed edge cases, but I added the draft to help whoever is going to work on this (whether that's future me or someone else)

To be clear, I am not actively working on this, I just wrote that draft because it was on my mind and so I thought it might help to have this draft around for when someone gets to work on this.