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

TRCL-3689 Add primer screen to prompt the user to enable notification #251

Merged
merged 10 commits into from
Sep 17, 2024

Conversation

ruixhuang
Copy link
Contributor


Description / Intuition

  • Adding primer screen.
  • Adding token registration logic.
  • Verifying order filled registration is received.

Still pending:

  • Disable the Abacus order notification.
  • Localization of the notification content is not working.
My.Movie.mp4

Before/After Screenshots or Videos


Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring or Technical Debt
  • Documentation update
  • Other (please describe: )

Copy link

linear bot commented Sep 16, 2024

@ruixhuang ruixhuang marked this pull request as ready for review September 16, 2024 21:59
Comment on lines +162 to +164
open func onInputValueChanged(input: FieldInput) {

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this for?

Copy link
Contributor Author

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 {
Copy link
Collaborator

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
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Comment on lines +44 to +46
if notificationPermission?.authorization == .notDetermined {
notificationPermission?.promptToAuthorize()
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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)?
Copy link
Collaborator

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"

Copy link
Contributor Author

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.

Comment on lines +88 to +90
if let token = token, permission == .authorized {
AbacusStateManager.shared.registerPushNotification(token: token, languageCode: languageCode)
}
Copy link
Collaborator

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

Copy link
Contributor Author

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.

@mike-dydx mike-dydx self-requested a review September 17, 2024 19:14
@ruixhuang ruixhuang merged commit 453dcd9 into develop Sep 17, 2024
5 checks passed
@ruixhuang ruixhuang deleted the features/push_1 branch September 17, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants