question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS notifications inconsistent performance when app is in quit state

See original GitHub issue

What’s working I am currently following the iOS Remote Notification Support documentation, and currently have the following features working,

  1. Foreground notifications
  2. Background notifications

What’s not working However, Quit state notifications only seems to work when any of the following conditions is fulfilled,

  1. User quits app and goes straight to home screen, without opening any other apps. Opening any other apps will cause the user to not receive any quit state notifications
  2. User recently received a quit state notification. This enables user to receive additional quit state notifications even when user is in another app

Observations When the quit state notifications work, i would see [BUNDLE] ./index.tsx. After 10 seconds, the code begins to run and my notification is displayed.

When quit state notifications does not work, I will NOT see [BUNDLE] ./index.tsx at all

Request for help I am seeking advice on any ideas on why this is happening. And hoping to find a fix where the user will be able to receive quit state notifications anytime, anywhere on their phone.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yiheinchaicommented, Nov 19, 2021

Update: It seems that notifee_options is not activating at all, meaning that something went wrong along the way while I am following the steps.

It seems that currently the setBackgroundMessageHandler is dealing with the background state and the quit state, and is not reliably receiving data-only notifications from the quit state. With my current implementation, it is displayNotification that is being called. I am wondering how do get notifee_options to work properly such that I do not have to rely on setBackgroundMessageHandler and displayNotification

I am currently using the Python Firebase SDK, the documentation does not mention where I should put the notifee_options object. This is the code for the current implementation, which I suppose something is going wrong somewhere

data = {
    'message-type': 'xxxx',
    'payload': json.dumps({"role":{"id":xxx,"title":"xxx","start_datetime":"xxxx","end_datetime":"xxx"},"org":{"id":xxx,"org_name":"xxxl"}})
}

apn = {
        "aps": messaging.Aps(content_available=True, mutable_content=True),
        "notifee_options":{
            "title":"xxx",
            "body": "xxxx",
            "subtitle": 'xxx',
            "data":{
                  "name":"xxx",
                  "params":"xxx"
               },
           "ios":{
              "foregroundPresentationOptions":{
                 "alert":True,
                 "badge":True,
                 "sound":True
              },
              "categoryId":"new-role"
           }
        }
     }

message = messaging.Message(
    data=data,
    token="xxxx",
    android=messaging.AndroidConfig(
        priority='high',
    ),
    apns=messaging.APNSConfig(payload=messaging.APNSPayload(**apn))
)

response = messaging.send(message)
0reactions
zenshayancommented, Mar 1, 2022

I’m currently facing the same issue, despite having the notification object in my payload. This is what my payload looks like (Python Firebase Admin SDK)

messaging.Message(
        notification=messaging.Notification(
            body=data_message['body'],
            title=data_message['title'],
        ),
        apns=messaging.APNSConfig(
            payload=messaging.APNSPayload(aps=messaging.Aps(mutable_content=1, content_available=1, sound= "ting.wav"),
              notifee_options={
                'ios':  {
                    'critical': True,
                    'sound': "ting.wav",
                    'criticalVolume': 0.2,
                    'categoryId': "channelHigh",
                },
                'data': data_message
            }
            ),
        ),
        token=registration_token[args.device],
    )

Notification is mapped to the correct channel in foreground, but it’s delivered as a regular notification in background, as if it doesn’t reach the NotifeeServiceExtension at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS notifications inconsistent performance when app is in quit ...
User recently received a quit state notification. This enables user to receive additional quit state notifications even when user is in another app....
Read more >
Technical Note TN2265: Troubleshooting Push Notifications
The device or computer may have lost its persistent connection to the push service and can't reconnect. Try quitting the app and relaunching...
Read more >
Reset push notification settings for app - Stack Overflow
Go to Settings > General > Date & Time and set the date ahead a day or more. Turn the device off completely...
Read more >
5 Ways to fix iOS 16/15/14/13/12 Notifications Not Working
Solution 1: Turn off Do Not Disturb​​ If you are not getting notifications on iPhone, then first you should check if the "Do...
Read more >
Notifications Not Shown - Mobile Push
Android App is Force Stopped ; MIUI 10, Settings > Battery & performance > Choose apps > Select the app that is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found