ably / ably-flutter

A wrapper around our Cocoa and Java client library SDKs, providing iOS and Android support for those using Flutter and Dart.
https://ably.com/download
Apache License 2.0
59 stars 14 forks source link

Ably interferes with firebase_messaging #346

Closed 1N50MN14 closed 2 years ago

1N50MN14 commented 2 years ago

My use case is that I wish push notifications to be handled directly via firebase_messaging. Not only that Ably is catching those notifications but it's also throwing an exception {{type 'Null' is not a subtype of type 'String' in type cast}} in Ably's own Notification class (notification.dart L10) here:

{code} factory Notification.fromMap(Map<String, dynamic> map) => Notification( map[TxNotification.title] as String, map[TxNotification.body] as String?); } {code} Which doesn't make sense anyway because title can be empty per the FCM specs (say data messages) and you can fall back to an empty string, even better, make notification handling optional.

EDIT: Adding the block to ApplicationManifest per PushNotifications.md doesn't work, to me at least, it throws an error {{The prefix "tools" for attribute "tools:node" associated with an element type "receiver" is not bound.}}.

ikurek commented 2 years ago

I think you're missing a namespace for the tools prefix in your AndroidManifest.xml. Please, add xmlns:tools="http://schemas.android.com/tools" as an XML namespace and let me know if that solves the issue 🙂

1N50MN14 commented 2 years ago

@ikurek YES that did it!! Thank you very much! :) One quick question, is there anything that I need to on iOS to make sure Ably behaves the same there as well?

Many thanks!!

ikurek commented 2 years ago

@1N50MN14 I don't think so, on iOS Ably uses APNS instead of FCM, so everything should work fine 🙂 I'm closing the issue, since it seems to be solved.

1N50MN14 commented 2 years ago

Great! Many thanks again this was a life saver today!