Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which notifications should i use, Push notification or local notification?

I have a cross platform application and i want to send notification to sign in users about their messages.

Now I confused about uses of push, local notifications. What I think of Push notifications is that it is for sending Announcements to users which is not specifically related to their account only.

Can anyone help me out with what should I use? I already used Local notifications in one of my applications with such requirement.

like image 309
Zain Ahmad Khan Avatar asked Dec 03 '22 12:12

Zain Ahmad Khan


2 Answers

It mainly depends on; is the data coming from local or remote?

You cannot control when your users open the app, and only when they open the app (with a few exceptions) you are able to fetch data. Then with that data you would be able to schedule a local notification. But in most cases that doesn't make much sense, because they have already loaded and probably seen the data. It only makes sense when you schedule an alarm clock for instance.

When you want the data to come from remote, like when they receive a message, you will have to use push notifications. The user is then alerted that new data is available without having to go look for it themselves. It is pushed to them.

However, for push notifications you will need infrastructure which you did not when using local notifications. You will need a server to handle the push notifications (Azure has some awesome functionalities for this) and some trigger to send push notifications. This can be an insert on a database, or a scheduled task. Also, the user has to enable push notifications and your app has to register itself to be able to receive them. It can be a pain to implement it the first time.

like image 74
Gerald Versluis Avatar answered Apr 27 '23 01:04

Gerald Versluis


It depends on for what reason you're sending the notification.

A local notification is sent locally on the device, so it doesn't need an internet connection. Examples could be:

  • Send a birthday message when the user has birthday
  • In a harvesting game, send a local notification when the store is full

A Push Notification is sent from a server and it requires internet on your device to receive it. Examples:

  • You get a message in a chat while the app is not open (if I understand your question right, this is your case)
  • In a game: realtime events which are triggered by a server

So in your case, if guess you want to notify the user about new messages if he does not have the app opened. This notification comes from a server and is a Push Notification.

like image 24
Dennis Schröer Avatar answered Apr 26 '23 23:04

Dennis Schröer