createLocalNotification() on iOS won’t display notification (show_in_foreground: true set)

This code works correctly on Android:

   firebase.database().ref('gifts').on('child_added', (snap) => {
      gift = snap.val();

      firebase.messaging().createLocalNotification({
        body: gift.name,
        show_in_foreground: true
      })
    })

On iOS, i just get this warning from React Native:
messaging_notification_received with no listeners registered.

.onMessage(message) works fine

When I build the .xcworkspace, I can get this from XCode’s console:

2017-07-02 18:47:52.015430+0200 appname[1081:1020773] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.

EDIT: Added flag to plist, message disappeared but nothing changes:

Also i noticed:

2017-07-02 19:32:36.452674+0200 app[1086:1026966] [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

2017-07-02 19:32:36.453 app[1086] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

Still, notifications sent by triggering FCM via cURL just work when app is in the background.

Author: Fantashit

6 thoughts on “createLocalNotification() on iOS won’t display notification (show_in_foreground: true set)

  1. I’m getting the same error from React Native on iOS:

    Sending `messaging_notification_received` with no listeners registered.
    

    The local message I sent is like this:

    {
      body: 'My Notification Message',
      id: '1503311359441',
      local_notification: true,
      show_in_foreground: true,
      title: 'My Notification Title',
      _notificationType: 'local_notification',
    }

    It works fine on Android, and message from remote works on iOS too.

  2. I has the same issue on IOS. On android working fine. I’m using “react-native-firebase”: “2.1.4”,”react”: “16.0.0-alpha.12” and “react-native”: “0.47.2”,

  3. A quick hack to this issue
    adding below flag during create local notification

    if([details objectForKey:@"show_in_foreground"] != nil) {
        if([(NSNumber *)details[@"show_in_foreground"] boolValue] == YES) {
            [content setValue:@YES forKeyPath:@"shouldAlwaysAlertWhileAppIsForeground"];
        }
    }
    

    You may refer to full code in this branch ios-foreground-notif

  4. The version I’m using contains the code that @hisokakei posted, still my local notification wont show up when in foreground, any ideas?

    this is my notification object:

    messaging.createLocalNotification({
            body: 'message',
            title: 'title',
            local_notification: true,
            priority: 'high',
            show_in_foreground: true
          });
    

Comments are closed.

createLocalNotification() on iOS won’t display notification (show_in_foreground: true set)

This code works correctly on Android:

   firebase.database().ref('gifts').on('child_added', (snap) => {
      gift = snap.val();

      firebase.messaging().createLocalNotification({
        body: gift.name,
        show_in_foreground: true
      })
    })

On iOS, i just get this warning from React Native:
messaging_notification_received with no listeners registered.

.onMessage(message) works fine

When I build the .xcworkspace, I can get this from XCode’s console:

2017-07-02 18:47:52.015430+0200 appname[1081:1020773] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.

EDIT: Added flag to plist, message disappeared but nothing changes:

Also i noticed:

2017-07-02 19:32:36.452674+0200 app[1086:1026966] [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

2017-07-02 19:32:36.453 app[1086] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

Still, notifications sent by triggering FCM via cURL just work when app is in the background.

Author: Fantashit

7 thoughts on “createLocalNotification() on iOS won’t display notification (show_in_foreground: true set)

  1. I’m getting the same error from React Native on iOS:

    Sending `messaging_notification_received` with no listeners registered.
    

    The local message I sent is like this:

    {
      body: 'My Notification Message',
      id: '1503311359441',
      local_notification: true,
      show_in_foreground: true,
      title: 'My Notification Title',
      _notificationType: 'local_notification',
    }

    It works fine on Android, and message from remote works on iOS too.

  2. I has the same issue on IOS. On android working fine. I’m using “react-native-firebase”: “2.1.4”,”react”: “16.0.0-alpha.12” and “react-native”: “0.47.2”,

  3. A quick hack to this issue
    adding below flag during create local notification

    if([details objectForKey:@"show_in_foreground"] != nil) {
        if([(NSNumber *)details[@"show_in_foreground"] boolValue] == YES) {
            [content setValue:@YES forKeyPath:@"shouldAlwaysAlertWhileAppIsForeground"];
        }
    }
    

    You may refer to full code in this branch ios-foreground-notif

  4. The version I’m using contains the code that @hisokakei posted, still my local notification wont show up when in foreground, any ideas?

    this is my notification object:

    messaging.createLocalNotification({
            body: 'message',
            title: 'title',
            local_notification: true,
            priority: 'high',
            show_in_foreground: true
          });
    
  5. Pingback: 토토

Comments are closed.

createLocalNotification() on iOS won’t display notification (show_in_foreground: true set)

This code works correctly on Android:

   firebase.database().ref('gifts').on('child_added', (snap) => {
      gift = snap.val();

      firebase.messaging().createLocalNotification({
        body: gift.name,
        show_in_foreground: true
      })
    })

On iOS, i just get this warning from React Native:
messaging_notification_received with no listeners registered.

.onMessage(message) works fine

When I build the .xcworkspace, I can get this from XCode’s console:

2017-07-02 18:47:52.015430+0200 appname[1081:1020773] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.

EDIT: Added flag to plist, message disappeared but nothing changes:

Also i noticed:

2017-07-02 19:32:36.452674+0200 app[1086:1026966] [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

2017-07-02 19:32:36.453 app[1086] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

Still, notifications sent by triggering FCM via cURL just work when app is in the background.

Author: Fantashit

3 thoughts on “createLocalNotification() on iOS won’t display notification (show_in_foreground: true set)

  1. I’m getting the same error from React Native on iOS:

    Sending `messaging_notification_received` with no listeners registered.
    

    The local message I sent is like this:

    {
      body: 'My Notification Message',
      id: '1503311359441',
      local_notification: true,
      show_in_foreground: true,
      title: 'My Notification Title',
      _notificationType: 'local_notification',
    }

    It works fine on Android, and message from remote works on iOS too.

  2. I has the same issue on IOS. On android working fine. I’m using “react-native-firebase”: “2.1.4”,”react”: “16.0.0-alpha.12” and “react-native”: “0.47.2”,

  3. A quick hack to this issue
    adding below flag during create local notification

    if([details objectForKey:@"show_in_foreground"] != nil) {
        if([(NSNumber *)details[@"show_in_foreground"] boolValue] == YES) {
            [content setValue:@YES forKeyPath:@"shouldAlwaysAlertWhileAppIsForeground"];
        }
    }
    

    You may refer to full code in this branch ios-foreground-notif

Comments are closed.