-
Notifications
You must be signed in to change notification settings - Fork 306
notif: Replace flutter_local_notification createNotificationChannel
with pigeon
#795
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
Conversation
I will leave my review in the next few hours. |
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.
Thanks @rajveermalviya for this! Just a small comment below, otherwise LGTM!
Let's move forward to the mentor review with @sumanthvrao!
pigeon/notifications.dart
Outdated
/// Corresponds to `androidx.core.app.NotificationManagerCompat.createNotificationChannel`. | ||
/// | ||
/// See: https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#createNotificationChannel(androidx.core.app.NotificationChannelCompat) | ||
void createNotificationChannel(NotificationChannel channel); |
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 am not sure if this could return Future<void>
instead of void
in here too, as the autogenerated concrete class has a return type of Future<void>
. Looking at the docs from the link provided, it seems that this method has a return type of void
, but that's in Java, and it doesn't have a type Future
; at least that's how I know so far about Java. 😀
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.
This file is a Pigeon file, not a standard Dart file. It contains types and methods that define the native plugin API interface. See Pigeon's example.
Adding a Future<void>
here will result in an error:
Error: pigeon/notifications.dart:120: Unknown type: Future
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.
Ok thanks, got it!
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.
this looks fine to me, but I have basically no familiarity with pigeon.
2ef9e12
to
60d84a0
Compare
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.
Thanks! Small comments below, and now over to Greg for his review.
pigeon/notifications.dart
Outdated
@@ -94,8 +94,39 @@ class MessagingStyle { | |||
final bool isGroupConversation; | |||
} | |||
|
|||
/// Corresponds to `androidx.core.app.NotificationChannelCompat` | |||
/// | |||
/// See: https://developer.androicd.com/reference/androidx/core/app/NotificationChannelCompat |
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.
nit: developer.android.com
lib/host/android_notifications.dart
Outdated
/// | ||
/// See: https://developer.android.com/reference/android/app/NotificationChannel#setImportance(int) | ||
abstract class NotificationImportance { | ||
/// Corresponds to [`IMPORTANCE_UNSPECIFIED`](https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#IMPORTANCE_UNSPECIFIED()) |
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.
The [text](example.com)
syntax makes it a bit harder to work out what the intended URL is and select it, especially here where the intended URL ends with ")".
I did notice Android Studio helpfully trying to linkify this in a hover interaction:

but then it similarly gets confused about what the intended URL is; it takes me here: https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#IMPORTANCE_UNSPECIFIED(
when it should have taken me here: https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#IMPORTANCE_UNSPECIFIED()
so the browser just leaves me at the top of the page, instead of scrolling me down to the #IMPORTANCE_UNSPECIFIED()
element.
So I think probably most helpful to give up that syntax and just write some thing like:
/// Corresponds to `IMPORTANCE_UNSPECIFIED`:
/// https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat#IMPORTANCE_UNSPECIFIED()
(here and elsewhere in the PR)
60d84a0
to
e37e269
Compare
Thanks for the review @chrisbobbe, pushed a new revision PTAL :) |
ab32f24
to
01adf07
Compare
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.
Thanks @rajveermalviya, and thanks @sm-sayedi and @chrisbobbe for the previous reviews!
Generally this looks great — a few nits below.
pigeon/notifications.dart
Outdated
/// | ||
/// See: https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat | ||
class NotificationChannel { | ||
/// Corresponds to [`NotificationChannelCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#Builder(java.lang.String,int)) |
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.
nit: one remaining instance of the pattern @chrisbobbe pointed out 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.
Separately, the reference to the builder class is good but I think it's most accurate to link to the class as a whole rather than that constructor. Three of the five parameters here don't go to the builder's constructor, but rather to method calls on the builder.
lib/host/android_notifications.dart
Outdated
|
||
/// For use in [NotificationChannel.importance]. | ||
/// | ||
/// See: https://developer.android.com/reference/android/app/NotificationChannel#setImportance(int) |
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: https://developer.android.com/reference/android/app/NotificationChannel#setImportance(int) | |
/// See: | |
/// https://developer.android.com/reference/android/app/NotificationChannel#setImportance(int) | |
/// https://developer.android.com/reference/android/app/NotificationChannel#getImportance() |
The getter's doc has some additional information that isn't on the setter, and they don't link to each other, so best to provide both.
pigeon/notifications.dart
Outdated
/// Corresponds to `androidx.core.app.NotificationChannelCompat` | ||
/// | ||
/// See: https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat | ||
class NotificationChannel { |
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.
nit: put this at the top of the file, before PendingIntent — that makes a nice logical lifecycle-oriented order
The methods on AndroidNotificationHostApi are already good this way.
The enum class NotificationImportance should get the same treatment, coming before PendingIntentFlag.
test/model/binding.dart
Outdated
class FakeAndroidFlutterLocalNotificationsPlugin extends Fake implements AndroidFlutterLocalNotificationsPlugin { | ||
} | ||
|
||
class FakeIOSFlutterLocalNotificationsPlugin extends Fake implements IOSFlutterLocalNotificationsPlugin { | ||
} |
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.
Neat!
Does this mean we can also cut out the test binding's resolvePlatformSpecificImplementation
? That'd be a nice further cleanup commit to come after this one.
test/model/binding.dart
Outdated
@@ -513,6 +509,11 @@ class FakeAndroidNotificationHostApi implements AndroidNotificationHostApi { | |||
_activeNotificationsMessagingStyle.clear(); | |||
} | |||
|
|||
@override | |||
Future<void> createNotificationChannel(NotificationChannel channel) async { |
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.
nit: keep this next to the data it acts on (so _createdChannels
)
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.
Relatedly, in the first commit this should go above takeNotifyCalls
, so as not to separate that from notify
.
bfe1433
to
59d248d
Compare
Thanks for the review @gnprice, pushed a new revision. |
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.
Thanks for the revision! Two nits, and otherwise this looks great.
pigeon/notifications.dart
Outdated
/// See: | ||
/// https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat | ||
/// https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#Builder(java.lang.String,int) | ||
class NotificationChannel { | ||
NotificationChannel({ |
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.
Ah, just to clarify what I meant at #795 (comment) because it might have been confusing:
I think having a doc comment on this Pigeon/Dart constructor is fine and potentially helpful. What I meant was that the doc on this constructor should link to the doc of the upstream builder class as a whole, and not to the specific point on that page for the builder's constructor.
So like this:
/// See: | |
/// https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat | |
/// https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder#Builder(java.lang.String,int) | |
class NotificationChannel { | |
NotificationChannel({ | |
/// See: | |
/// https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat | |
/// https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat.Builder | |
class NotificationChannel { | |
NotificationChannel({ |
but also that second link would be fine to move back to being a doc comment on this NotificationChannel constructor rather than on the NotificationChannel class.
FlutterLocalNotificationsPlatform? _platform; | ||
|
||
@override | ||
T? resolvePlatformSpecificImplementation<T extends FlutterLocalNotificationsPlatform>() { |
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.
commit-structure nit: this should come as a separate commit after the main commit, as per #795 (comment)
59d248d
to
107810f
Compare
Thanks for the review @gnprice, pushed a new revision, PTAL. |
de6271f
to
b36b8da
Compare
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.
Thanks for the revision! Looks good — merging, after fixing two quick nits mentioned below.
This is great progress on #351; looking forward to seeing the remaining pieces.
test/model/binding.dart
Outdated
class FakeAndroidFlutterLocalNotificationsPlugin extends Fake implements AndroidFlutterLocalNotificationsPlugin { | ||
} | ||
|
||
class FakeIOSFlutterLocalNotificationsPlugin extends Fake implements IOSFlutterLocalNotificationsPlugin { |
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.
nit: these can be cut too, since they're effectively part of the implementation of resolvePlatformSpecificImplementation
(the previous revision did cut them, so I'm guessing their coming back was a rebase error)
FlutterLocalNotificationsPlatform? _platform; | ||
|
||
@override | ||
T? resolvePlatformSpecificImplementation<T extends FlutterLocalNotificationsPlatform>() { |
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.
nit in commit message:
notif [nfc]: Remove unused test harness for flutter_local_notification
This sounds like it might mean our whole test harness for that package. Also the package's name has an "s" at the end. So:
notif [nfc]: Remove unused test harness for parts of flutter_local_notifications
Oh and a different commit-message nit — the commit series looks like this: So the first commit message is duplicated. I think you intended the second commit to have the message it had in the last revision:
So I'll put that message back. This is probably also a good moment for a reminder that I highly recommend setting up and using a graphical Git client, like |
b36b8da
to
016f22a
Compare
Work towards #351