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

Room Enter / Exit Local Push Notification Feature #36

Merged
merged 16 commits into from
Jun 7, 2020
Merged

Conversation

nesimtunc
Copy link
Member

@nesimtunc nesimtunc commented May 30, 2020

TODO:

  • Show room name instead of Id
  • Show one line message for small smart watch screens ex: Entered: Kitchen

Closes #29

@nesimtunc nesimtunc requested a review from umurgdk May 30, 2020 11:57
@nesimtunc nesimtunc changed the title NotificationSettings View and NotificationService communication Notification Feature May 30, 2020
@@ -11,6 +11,9 @@ import Foundation
let ServerHostNameKey = "serverHostname"
let PassOnboardingKey = "passOnboarding"
let LastEnteredRoomIdKey = "lastEnteredRoomId"
let NotifyOnEnterKey = "notifyOnEnter"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to collect all these keys under an enum: String so later on we can understand where these keys belongs to. An enum like UserDefaultKeys

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the situation where the user wants to get notifications for enter or exit without specifying a special room. I wouldn't like to get all the irrelevant notifications from other rooms while only waiting for the bathroom to be available

Copy link
Member Author

Choose a reason for hiding this comment

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

nah this is not that feature, yet. for that we need server side implementation.. this is only for let use know when they entered a room or exited from a room so they don't have to manually update it.

It would be also good to let them know that they have already in the room in the UI (Home screen), or disabled -/+ buttons. But they might want to adjust the number, not everyone going to use the app..

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, it is okay as far as it is opt in.

@@ -53,6 +50,7 @@ class BeaconDetector: NSObject, ObservableObject, CLLocationManagerDelegate {
private(set) var exits = PassthroughSubject<Room.ID, Never>()

private var locationManager = CLLocationManager()
private var notificationService = NotificationService()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe BeaconDetector is a self contained service and shouldn’t depend on any other services like sessions or notification services. BeaconDetector already publishes enters and exits, so showing notification could be lifted up to place session or somewhere else to make BeaconDetector totally isolated.


struct NotificationSettings: View {

@ObservedObject var notificationService = NotificationService()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this settings view owns the notification service? Because we’re creating a new instance for us, remember this new notification service is going to be created every time this view created from scratch.

Copy link
Member Author

Choose a reason for hiding this comment

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

right ... I'll fix it.

return notifyOnEnter || notifyOnExit || notifyWithSound
}

func showPushNotificationIfEnabled(for actionEntered: Bool, title: String, message: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is notification service responsible for showing notifications to the user? If that so enter/exit shouldn’t be part of it’s api. Enter exit is solely known by beacon detector and it’s published properties. Also ifenabled is internal state of this object. Public function shouldn’t leak that detail to outer world. If we want to enable/disable some sort of notifications we can use something like a channel analogy. So for example

showNotification(on channel: NotificationChannel, title: String, message: String, withSound: Bool = true)

disableChannel(_ channel: NotificationChannel)

enableChannel(_ channel: NotificationChannel)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or instead of enableChannel/disableChannel we can have
var enabledChannels: Set<NotificationChannel>() or even better we can make it immutable and whenever a notification setting changes (like enabling a channel) we can create a new notification settings with enabled channels.

Copy link
Member Author

@nesimtunc nesimtunc May 30, 2020

Choose a reason for hiding this comment

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

you mean we let user have optional notification preference for each channel? this is only for the case of rooms who have beacon. rest of the rooms are manually updated, like washing machines, so we don't need notify them.

@nesimtunc nesimtunc changed the title Notification Feature Room Enter / Exit Local Push Notification Feature May 30, 2020
@umurgdk umurgdk marked this pull request as ready for review May 30, 2020 16:36
@nesimtunc nesimtunc marked this pull request as draft May 31, 2020 01:03
always update one push notification to prevent notification noisy
@nesimtunc
Copy link
Member Author

We got 2 new issues @umurgdk

  1. When user changes notification permission from iOS Settings, and comes back to CoThings Notification Settings (where left via "Allow Notifications" button), that button will be there because onAppear method doesn't call when the screen re-appear.

  2. CoThingsBackend doesn't have the latest list of the rooms when connecting in the background.

Shall we merge this pull request and create these issues as bugs?

@nesimtunc nesimtunc marked this pull request as ready for review June 1, 2020 09:03
@nesimtunc nesimtunc assigned nesimtunc and unassigned umurgdk Jun 7, 2020
@nesimtunc nesimtunc merged commit bb63d5c into master Jun 7, 2020
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.

Notification Feature
2 participants