-
Notifications
You must be signed in to change notification settings - Fork 4k
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
New Local Notification Sample port from Legacy #341
New Local Notification Sample port from Legacy #341
Conversation
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.
Great Start! Few suggestions and questions
|
||
void CreateNotificationChannel () | ||
{ | ||
ArgumentNullException.ThrowIfNull(Resources); |
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.
ArgumentNullException.ThrowIfNull(Resources); | |
ArgumentNullException.ThrowIfNull (Resources); |
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.
Done!
{ | ||
ArgumentNullException.ThrowIfNull(Resources); | ||
|
||
// API 26 and below works but are new in API 26+ |
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 love that you included a message here, but does not seem super clear to me.
Maybe rephrase to include that "creating a NotificationChannel" is only needed in API 26+
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've modified the comment.
var count = Intent?.Extras?.GetInt (MainActivity.COUNT_KEY, -1); | ||
|
||
// No count was passed? Then just return. | ||
if (count <= 0) |
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.
Does this have any nullability issues?
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.
Yes, Intent and Extras may be null.
var button = FindViewById<Button> (Resource.Id.MyButton); | ||
ArgumentNullException.ThrowIfNull (button); | ||
button.Click += ButtonOnClick; | ||
|
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.
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.
Done!
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 wasn't able to get the notifications working on my device with API 32, but apparently it's working fine on API 31. @jonathanpeppers do you have any ideas?
@rachelkang do we need to add this: https://developer.android.com/about/versions/13/changes/notification-permission <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> |
Local Notification should allow the user to click on a button and the user should receive a notification of the times the button is clicked.