-
Notifications
You must be signed in to change notification settings - Fork 5
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
Introducing Notifications #637
base: main
Are you sure you want to change the base?
Conversation
ActivityResultContracts.RequestPermission(), | ||
) { isGranted: Boolean -> | ||
if (isGranted) { | ||
// FCM SDK (and your app) can post notifications. |
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 isGranted is true, does that just mean you can send notifications even though nothing is written here.
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.
doubling this question
Is this something where we can choose to do something (ex: sending a "success!" message to the user), but it's also okay not to do anything (since notifications will be shown as enabled 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.
I don't think we have to do anything, but having TODOs in main is generally considered bad practice. What behavior should we expect if notifications aren't enabled? Is this information generally available or should it be stored somewhere? (oops, answered by scrolling down LOL)
I don't think we have to do anything then. How do other ppl generally use this function?
) { | ||
// FCM SDK (and your app) can post notifications. | ||
} else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { | ||
// TODO: display an educational UI explaining to the user the features that will be enabled |
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.
Is there some method to keep track of the user already rejecting notifications?
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.
It seems the "shouldShowRequestPermissionRationale" function actually checks the Manifest.permission.POST_NOTIFICATIONS to see whether these permissions was just rejected (meaning ask again on-create), or if it was rejected + "don't show again" box was checked (meaning don't ask again on-create)
When a user rejects, the specific type of rejection is stored within Manifest.permission.POST_NOTIFICATIONS. Pretty Cool
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.
again, try to clean up TODOs. Personally, I don't believe we really need an explanation for this and am comfortable with doing nothing.
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.
Left some questions above
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.
See comments. Also, figure out how u want to update token in backend when onNewToken() is called.
@@ -99,6 +99,7 @@ dependencies { | |||
testImplementation platform(libs.androidx.compose.bom) | |||
androidTestImplementation platform(libs.androidx.compose.bom) | |||
implementation platform(libs.firebase.bom) | |||
implementation(libs.firebase.messaging) |
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.
why does this have parens but the other imports don't? Can we standardize formatting?
@@ -91,6 +107,7 @@ class MainActivity : AppCompatActivity() { | |||
setTheme(R.style.DarkBackground) | |||
} | |||
Utils.getCurrentSystemTime() | |||
askNotificationPermission() |
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.
why are we asking for notification permission every time the activity starts? It is probably annoying if they don't want notifications and the app keeps asking... I feel like the app should just ask once.
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.
udp: I didn't realize that android had a "never ask again" feature. Someone correct me if I'm wrong, but this case should be handled right.
) { | ||
// FCM SDK (and your app) can post notifications. | ||
} else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { | ||
// TODO: display an educational UI explaining to the user the features that will be enabled |
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.
again, try to clean up TODOs. Personally, I don't believe we really need an explanation for this and am comfortable with doing nothing.
@@ -72,5 +72,6 @@ | |||
<color name="light_blue_200">#FF81D4FA</color> | |||
<color name="light_blue_600">#FF039BE5</color> | |||
<color name="light_blue_900">#FF01579B</color> | |||
<color name="penn_red">#990000</color> |
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.
we already have PennRed... Please remove one of them.
class LoginWebviewViewmodel : ViewModel() { | ||
suspend fun sendToken( | ||
mNotificationAPI: NotificationAPI, | ||
notGuest: Boolean, |
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.
can we negate this here. (I know our guest mode stuff is kinda fucked up but notGuest is just an extremely cursed variable name)
Our app can receive notifications now!
Changes
SharedPreferences
. Therefore, to fetch notification tokens, we can easily do so readingSharedPreferences
.Documentation and Testing: