A
A
Alex Rubera2017-04-18 16:03:43
iOS
Alex Rubera, 2017-04-18 16:03:43

How to handle data payload from push notification when app is not active?

Some say it's possible, others don't. The documentation says:

Your app can still receive data messages when it is in the background...

But how? I tried different options, but I have not yet achieved the desired result.
For example. The application is not active. I send this message:
{
  "to": "...",
  "priority": "high",
  "notification": {
    "title": "Заголовок",
    "body": "Текст сообщения",
    "sound": "default"
  },
  "data": {
    "title": "Заголовок",
    "message": "Текст сообщения",
    "payload": {
      "key_one": "val_one",
      "key_two": "val_two"
    },
    "content_available": true,
    "timestamp": "2017-04-17 16:51:58"
  }
}

A notification appears in the tray. But:
  1. If you tap on it, a message opens and the same notification appears in the tray again (this is triggered by my internal data payload handler).
  2. If you open the application not from a notification, but from the main icon on the desktop, then a duplicate notification does not appear. But payload data is not processed at the same time.

I need to not only notify the user about this when receiving a notification, but also physically make changes to the application database.
Maybe I'm digging in the wrong direction?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Karnaukhov, 2017-04-18
@BupycNet

You need to remove the notification block and make the notification yourself. Then the application will always be called

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question