-
Notifications
You must be signed in to change notification settings - Fork 0
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
TRCL-3689 Add primer screen to prompt the user to enable notification #251
Conversation
open func onInputValueChanged(input: FieldInput) { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So subclass can overwrite with custom behavior.
import RoutingKit | ||
import Utilities | ||
|
||
public final class dydxPushNotifcationToggleWorker: BaseWorker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp check "notification"
@@ -22,14 +22,14 @@ public enum dydxSettingsStoreKey: String, CaseIterable { | |||
case .language: return DataLocalizer.shared?.language | |||
case .v4Theme: return dydxThemeType.classicDark.rawValue | |||
case .directionColorPreference: return "green_is_up" | |||
case .shouldDisplayInAppNotifications: return true | |||
case .shouldDisplayInAppNotifications: return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default is false here, but true in alerts worker dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxAlertsWorker.swift
Unsure if the default would ever actually be used in dydxAlertsWorker
though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will revert it back to true.. It's going to be overwritten by the worker anyway.
if notificationPermission?.authorization == .notDetermined { | ||
notificationPermission?.promptToAuthorize() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if forget, is notDetermined
the only time the prompt will actually display? Is it also displayed for .ephemeral
? If not, we can maybe try it in all cases and skip the == notdetermined
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should only show the primer when the state is .notDetermined, since it's the only time the app can prompt for the system notification toggle. In other cases, user has to manually toggle through the device's Settings.
.ephemeral is only available for app clips.
import Utilities | ||
|
||
public class dydxNotificationPrimerViewModel: PlatformViewModel { | ||
@Published public var ctaAction: (() -> Void)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general question, why do we show a primer if "ok" is the only action? Should we add like a "not now" option? Otherwise, the primer is just an extra step for the user to say "no"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User can drag down the half sheet to dismiss, so it's the same as "not now".
The primer serves as a value prop to the subsequent system notification toggle which is quite generic. The idea is that with the value prop the user will be more likely to allow notification in the next step.
if let token = token, permission == .authorized { | ||
AbacusStateManager.shared.registerPushNotification(token: token, languageCode: languageCode) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even if user is not authorized, I think we would still want to send the language/token update in case they authorize it in the background
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would mean the backend will send notifications to all users. When the notification is enabled from the device Settings, this will get called when the app is foregrounded again, so it should handle most cases.
Description / Intuition
Still pending:
My.Movie.mp4
Before/After Screenshots or Videos
Type of Change