infobip / mobile-messaging-flutter-plugin

Mobile Messaging SDK plugin for Flutter projects
Other
9 stars 6 forks source link

[Android] Initialize the SDK without registering for remote notifications #15

Closed toussam closed 7 months ago

toussam commented 7 months ago

Hello guys 👋

First thing first, thank you for providing a Flutter package for Infobip.

My ticket is following the #12 in which we were requesting the "withoutRegisteringForRemoteNotifications" setting for the iOS platform.

We would like to know if it's planned or possible to implement the equivalent on Android side. I checked Android SDK repository and it seems that this last one can handle such feature: Android 13 Notification Permission Handling

This would be helpful for having the possibility to uniformize the behavior on both platform and our code.

In advance, thank you for everything and wish you a great weekend.

Best regards,

ikresicc commented 7 months ago

Hi,

by the default you won't be registered for the remote notifications on Android platform, and in order to register for them, you can call:

mobileMessaging.registerForAndroidRemoteNotifications();

as it is described on this documentation page.

There is a difference in method name for Android side as there were some implementation differences on plugins side, so probably that was the reason why you were not able to find this.

Hope this will help you resolving your issue.

Best

toussam commented 7 months ago

Hi @ikresicc,

Thanks for the share of information.

I was aware of this method and we are currently using it to display the push notification permission on due time.

What's confusing to me is that when I'm running our app on Android 13, I can confirm to you that the device is being registered post SDK's initialization and without displaying any permission request.

Indeed, the "registrationUpdated" event is being triggered with a valid pushRegistrationId and when I'm fetching the installation instance, the "isPushRegistrationEnabled" property's value is "true".

This is why I created this Github Issue and after reading Android SDK's documentation, not knowing the existence of the Flutter plugin's documentation, I thought that the "withoutRegisteringForRemoteNotifications" setting would be the solution for us.

For now, to prevent the user receiving any push notifications even though he didn't give its consent, we're disabling the push notifications manually when the said event is being triggered for the Android platform.

toussam commented 7 months ago

Just realized there is another property named "notificationsEnabled" that may be reflecting the notifications permission's status. If I understood correctly both platform are not working the same way (due to the"implementation differences on plugins side" that you referred into your previous message), am I right?

iOS platform: is registering the device and enabling the notifications once the permission has been provided android platform: is registering the device right away and enabling the notifications once the permission has been provided

If so, that means we are forced to have specific code for each platform on the Flutter side and that we won't be able to uniformize it.

toussam commented 7 months ago

Hi @ikresicc,

Could you respond to my previous questions when you will have some time please? :)

I thank you in advance,

riskpp commented 7 months ago

Hello @toussam,

I'll try to clarify it:

If I understood the use-case correctly you don't want the user to receive (be able to see) the push notifications until he gave the permission for it on the system dialog, and it's actually the default iOS/Android behavior.

If you sending the in-app notifications which may come as silent, you may use the enabling/disabling push registration method

If I didn't understand the use case, could you please clarify it?

Thank you, Olga

toussam commented 7 months ago

Hi @riskpp,

Thank you for all the provided information!!

I didn't know that the permission was only about displaying the push notifications. I thought that it should also impact the registration which is explaining my previous interrogations.

To illustrate our context, we delayed the registration for iOS platform (using the "withoutRegisteringForRemoteNotifications" setting) to prevent the notification permission being displayed during launch time and therefore we ended up with specific code for both platforms. Because of that, we wanted to uniformize these last ones and the registration's timing, but I will follow up your advice for Android and let the registration being applied during the SDK's initialization (aka at the start of the application).

I'm closing this issue since I got all the needed information and since no modification are needed from on your side.

Again, thank you for everything!

Best regards,