beeminder / BeeSwift

Official Beeminder for iOS app
Other
29 stars 5 forks source link

Entering app from notification should take you to the goal not the gallery #41

Open andrewpbrett opened 4 years ago

andrewpbrett commented 4 years ago
### Desiderata
- [ ] Confirm replicata on modern BeemiOS

Replicata

  1. Receive a notification about a specific goal
  2. Tap on notification to open Beeminder app

Expectata

You should be directly on the goal screen that sent the notification.

Resultata

You land on the gallery screen.

Verbata: deep links,

krugerk commented 4 years ago

The same (galleryVC is shown but not VC of the tapped goal) seems to be the case when tapping on the graph of a goal in the widget.

krugerk commented 4 years ago

A related wish for the iOS app is that clicking on a zeno reminder should load the goal page, not just launch the app… - philip https://forum.beeminder.com/t/ios-is-open-source-again-request-for-feature-bugfix-requests/3620/10

andrewpbrett commented 4 years ago

That's what this is referring to, receiving a Zeno reminder and tapping on it should load the goal page.

krugerk commented 4 years ago

Exactly Browsing the forums one comes across several feature requests and bug reports. I meant the link to the forum as a reference link back to the forum. Whichever is updated first can make its way to the other so both github followers and forum users can see the announcement.

krugerk commented 4 years ago

@andrewpbrett What does the payload (userInfo Dictionary) for such a remote notification look like?

We can see in the Notification Center a notification with something to the effect of "eek! goal x needs y points by 12am"

andrewpbrett commented 4 years ago

I believe that the custom payload is currently empty, but we could have it send the slug of the goal (that's how it worked a long time ago). Alternatively, the apns_collapse_id has the shortname of the goal, e.g. "apb/steps", that could be used to identify the goal if it's accessible.

adamwolf commented 4 years ago

on iOS, how many distinct collapse IDs per app-user can you have? On Android, it will only collapse the last 6 you send, which makes me sad :(

andrewpbrett commented 4 years ago

As far as I know there's no limit, the docs don't mention any. @chipmanaged might be the one to ask if having lots of notifications come in makes it so they no longer collapse :)

krugerk commented 4 years ago

So a sample remote notification could look like this?

{
  "aps": {
    "alert": "eek! goal steps needs 9870 steps by 10pm",
    "sound": "default"
  },
  "Simulator Target Bundle": "com.beeminder.beeminder"
}

or is alert itself a dictionary using title and subtitle?

chipmanaged commented 4 years ago

I don't know what the notifications would do if they were sorted automatically. (Want me to find out?) I have mine sorted by app and it's just one stack that's infinitely long when I open it.

andrewpbrett commented 4 years ago

@krugerk the notifications are being sent with the Apnotic gem. The relevant bit of code looks like:

notification = Apnotic::Notification.new(token)
notification.topic = "com.beeminder.beeminder"
notification.alert = goal.alert_text(type)
notification.badge = eep_count
notification.sound = "default"
notification.apns_collapse_id = goal.shortname

@chipmanaged I don't think the sorting should matter. If I'm understanding @adamwolf right, he's saying that on Android, if you have a lot of goals (or maybe a lot of notifications to the same goal? I'm not sure) the OS won't collapse more than six. Also, I'm not sure if that discussion was intended for this issue, it might be better to move it somewhere else if not.

krugerk commented 3 years ago

OK. Mostly I was curious to know how the data structure looked. (I do not yet have debugging for the app installed on the iOS device, just the one in the simulator.)

You mentioned that the apns_collapse_id contained the username/slug. The slug is also present in the alert text. This ticket concerns itself with opening the goal corresponding to the one mentioned in goal.shortname.

Since we now support iOS 10 and up, it looks like it might be enough to use userNotificationCenter(_:didReceive:withCompletionHandler:) from the UNUserNotificationCenterDelegate.