Hi,
I am trying to set up push notifications on my app, and am encountering multiple issues or questions.
I followed the setup guidelines for iOS and Android the best I could. The Android key and iOS certificates are configured (app id D7075715-5086-625A-FFAB-39C2F40FB200
).
First of all a quick feedback : I finally managed to find the way to register the device for push notifications. I was looking for the block in Messaging API, and in fact it was in Native API. That did not feel quite intuitive, but there is probably a good reason for that. The difficult part was that it is not documented in the Codeless doc. Now I have found this block, I see there is one next to it saying “Add Push Notification Event Listener with id”, and I would be curious to know what it does and how, but it’s not documented either. Any hint ?
Now on to the issues. When I try to test my logic in my apps, here is what happens :
On iOS :
- I can register the device for push notifications, both on a sandbox and a production channel. The records show up in the DeviceRegistration table.
- However, the native iOS dialog asking permission for notification never shows up, and in the iOS Settings app, there is no Notifications setting.
- Notifications are never received if the app is not running.
- When the app is running and open, I can receive notifications only if I have actually registered for notifications previously during the same session. If the app has been shut down and relaunched, I don’t seem to receive the notifications.
- When I receive a notification, it doesn’t look like anything like a native notification and nothing like what was previewed in the console. Rather they look like some kind of temporary banner internal to the app, with a Backendless logo which I can’t seem to customize within the console, and they disappear before the user can read anything.
On Android :
- Registering for push notifications goes fine, but I am also not asked for notifications permission. This, however, may be normal, although I am not really sure.
- I do receive the notifications, even when the app is closed, and they do look native, so this is a good point.
- If I have registered the device during the current session, I also receive a temporary banner internal to the app like above in iOS. But this does not happen when the app has since been relaunched. That banner has the same design issues as above (not customizable, with a Backendless logo, etc.)
Thanks for any pointers which might get me in the right direction with all these issues, especially regarding getting native notifications working on iOS.
If it changes anything, please note that I am using an app built in Codeless with UI Builder, and encapsulated in the Native Mobile App Shell.
Hello @Nicolas_REMY
Thank you for your message. I will discuss these nuances with the team and we will give you an answer.
Regards,
Inna
1 Like
Hello, @Nicolas_REMY.
Unfortunately, there is no documentation on the interaction between native shell and ui builder. But we will definitely take care of it.
First, regarding registration. There is a static constant variable in the configurator.dart
file: REGISTER_FOR_PUSH_NOTIFICATIONS_ON_RUN
if its value is true then the application subscribes to notifications at startup. If the value is false, then only after a request from Codeless
.
In the bridge_ui_builder_functions.dart
file, you can set up registration, specify which channels you want to subscribe to, and so on.
Inside this method registerForPushNotifications
, the registerDevice
function you named earlier from backendless_sdk
in Flutter
is called.
There, as a callback, the onMessage
method is passed. It is located in the same file, which you can also configure yourself.
Regarding the problem that push notifications come as an overlay on the page, and not natively in IOS. Native App Shell is a shell with general settings, in your case the application is complex and requires additional settings, the “default” function will not suit you. So yes, you just need to set up push notifications in the onMessage
method the way you want them ideally to be.
Best Regards, Nikita.
Hi Nikita and thank you for this reply.
Thanks to your explanation, I understand the thing about the notifications shown inside the app. I will look into this, OK. If I understand correctly, the logic sequence is :
REGISTER_FOR_PUSH_NOTIFICATIONS_ON_RUN → registerForPushNotifications → onMessage → showOverlayNotification
So if I try to setup the change REGISTER_FOR_PUSH_NOTIFICATIONS_ON_RUN to true, the app will ask for permissions directly on startup, right ? I have yet to try this change, but I need to understand if it does ask for the permission in iOS. Indeed I believe the first issue I have on iOS is that permission is not asked for notifications. Most likely, the fact I do not receive native notifications at all might have to do with this ?
Anyhow, this would be great progress. But, still, I would like permission to be asked at a moment of my choosing and not at first launch (because users who are asked for permission upfront without having started using the app will most likely refuse the permission).
Hi again,
Just as a follow up to my previous reply. Following your message, I have changed the value of REGISTER_FOR_PUSH_NOTIFICATIONS_ON_RUN to true, rebuilt and uploaded to my iOS device. But it has not made things any better
I am never asked if I give permission for notifications, and then the only notification I get is the banner inside the app, if the app is running and in the foreground.
I am looking to get notifications like those shown on the preview.
Thanks for your help.
Hello, @Nicolas_REMY.
Thanks for reporting the problem. We are currently working on a solution. When there is any news, I will let you know.
Best Regards, Nikita.
Hi @Nikita_Fedorishchev ,
Looking forward to this. Will readily test the fix when available.
Thanks.
Update the version of backendless_sdk
in your application in the pubspec.yaml
file to 7.2.5.
After this just call commands:
flutter clean
flutter pub get
Then try to run your application. Push notifications should now work as expected.
Issues fixed:
- Now, when registering a device, an alert appears with a request for permissions to send push notifications.
- IOS push notifications are now fetched when the app is in the background mode.
Best Regards, Nikita.
Hi @Nikita_Fedorishchev ,
I have tested only quickly, but I got the native question asking permission on iOS, and a native notification came through all right. Now I will see how to setup the whole thing so it comes when I need to. But this looks much better ! I will post back here if some issues remain.
Have a good week-end.
1 Like