Push Notification with MySQL database

Hello, i am currently learning to create mobile app using ionic 2 and still quite new in this framework,

I wonder if there’s anyway to push a notification to an ionic 2 app in Android/iOS but using MySQL Database,
I would like to develop a simple website using Laravel and make the mobile app using Ionic 2:
I would like to register a new employee in the database using the Laravel website,
When a new employee record is created in mysql database table ‘employee’, a push notification is sent to ionic 2 mobile app,

Is this possible to achieve without using firebase?

1 Like

This is not possible just with MySQL.

You have to write something like an MySQL trigger: http://stackoverflow.com/questions/13474012/invoke-pusher-when-mysql-has-changed
You can write a NodeJS server for example who listen to your MySQL DB changes and then he can send a push notification over Firebase, Ionic Cloud or whatever to your devices.

Zapier also provides a plugin for this kind of workflow (never used it): https://zapier.com/zapbook/mysql/onesignal/


Hello, Thank you very much for the reply,
Pardon me, but where can i find a source code example for this solution?

I never coded a web service like that, but you should use this npm plugin: https://www.npmjs.com/package/mysql-events

You can setup a simple expressjs server with that package i think.

Actually, there is a simpler solution: Just send the push notification when the employee is added to the database. To send the push you will need to call an API at your push provider (e.g. Onesignal, Ionic Push etc).

Hello, thank you very much for the information,
I am sorry but, could you elaborate more on this part? Do i call it from the server or from the ionic mobile app itself?

You can do it manually by yourself or automatically with a DB listener service. OneSignal is easy to implement in your Ionic app.

Maybe you can explain more about your project. Do you insert employees into the DB over your website or with your app?

Oh, My apologize if it’s not clear,

The employee is inserted over my website, i just wanted the mobile phone to view the details of the employees including the newly created one, however, i think it would be nice to have push notification when a new employee data is inserted

Then it is quite simple :slight_smile:
Every time you insert a new employee you send a push notification over the Push Service API like OneSignal, Firebase etc.

I would recommend using OneSignal or the Ionic Cloud Service!

OneSignal REST Docs: https://documentation.onesignal.com/reference
Ionic Cloud REST Docs: https://docs.ionic.io/api/endpoints/push.html

1 Like

Sending pushes is done on the server side. @LoLStats answered quite well I think.

1 Like

Thank you very much for the kind assistance, i will try this solution.
By the way, can this solution be tested when i use a localhost server instead of real server?


I’m working on a project like yours is what you can guide me if you find a solution "I have a table news, anyway to push a notification to an application ionic 3 in Android / iOS but using MySQL Database and I would like to register a new news in the database and when a new record is created in the database table mysql ‘news’, a push notification is sent to the mobile application ionic 3,

thank you in advance

1 Like

You can use OneSignal with your app for implementing push notification. If your app is built in PHP, then you only need to add appID code to your PHP file. You can relate to this tutorial on PHP push notification for this.