T
T
tiger_132020-06-01 15:42:09
Swift
tiger_13, 2020-06-01 15:42:09

How to correctly implement the loading of notifications?

Hello! I am writing an application in which one of the TabBarController's ViewControllers is a ViewController with a UITableView that displays notification cards (different types of notifications, sorted by date)
How can I correctly, in real time, implement the loading of these notifications? The task is that even if the user is on another ViewController, the application still receives a notification, and a red circle appears in the tabbar near the icon. That is, the option of receiving data one-time in viewWillAppear on a ViewController with notifications is eliminated, since in this way the user must go to the page with notifications to find out that he has new ones. Push is only suitable for those who have agreed to the mailing list. How best to implement?
Thank you in advance for your response

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vorobei, 2020-06-01
@tiger_13

You are looking for a way to implement feedback . Not many conceptual options.

  1. Long Pooling - each time you send an http request, if there is an event, the server stops holding it and responds with data. I haven't seen any projects on this, but often on the backend side.
  2. Pushes - the requested permission refers specifically to the display of pushes. Even without a stock of permissions, you will receive them as long as the app is open. Good option for feedback.
  3. Websockets are a kind of flagship, for narrow needs. Direct server-client communication, a stable connection is required. Most messengers use this technology.

On the client side, global notifications, database observers, direct refresh by trigger are available to you.
Note that the backend you want to receive this data from must support the . It's just that you can't connect to anyone in any way.
PS I don't suggest sending a request every N seconds, because I think it's a perversion.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question