skip to Main Content

I googled a bunch but can not find a comprehensive answer.
I am getting my token like this

final notificationSettings = await FirebaseMessaging.instance.requestPermission(
      alert: true,
      announcement: true,
      badge: false,
      provisional: false,
      sound: true
    );

final token = await FirebaseMessaging.instance.getToken();

and send my notifications with python firebase messaging

notification = messaging.Notification(
    'Title',
    'Text'
)

message = messaging.Message(
    notification=notification,
    token=token    
)

messaging.send(message)

The notification arrives, but only in the iPhone notification center. It does not show on the lock screen like all other messages. Do I need to feed in some setting in the app to enable this?
I found that the provisional flag (initially I had it as true) triggers this behavior

https://rnfirebase.io/messaging/ios-permissions#provisional-permission

but I have reset it to false and still my notifications do not show on the lock screen…

2

Answers


  1. Chosen as BEST ANSWER

    So, what I had to do was to DELETE the app and rebuild. This would erase all previous settings, a new token will be created and with the new permission parameters the notifications will show on the lock screen.


  2. On iOS, displaying notifications on the Lock Screen depends on the permissions requested and the notification configuration.

    Solution: Ensure that you are requesting permissions correctly on iOS. You could use firebase_messaging plugin to manage this.

    Example with firebase_messaging:

    import 'package:firebase_messaging/firebase_messaging.dart';
    
    void requestPermissions() {
      FirebaseMessaging.instance.requestPermission(
        alert: true,
        announcement: true,
        badge: true,
        sound: true,
        criticalAlert: true, // Allows critical notifications
        provisional: false, // Ensures full notifications
      );
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search