5

I want to implement Notifications based on changing in MySQL. i have an app thats send tasks to device on runtime. I want that i get notification on my android device when i insert a task in Task table in MySQL. I can get every task from MySQL using php. and i have also make login in which i get username and password and verify it from MySQL. and same like that i have did for task. to get tasks. like this and now i am following this tutorial for implement notification. but how can i get notification when inserting task in MySQL. i have to make an service that will run in background but how will i get if there is anychange in task table. ?

3 Answers 3

3

You can create a trigger in your MySQL database and run an external application everytime a row is inserted in that table. More info: http://dev.mysql.com/doc/refman/5.1/en/faqs-triggers.html#qandaitem-B-5-1-10

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, may the force be with you.
3

You should take a look at Firebase Cloud Messaging, it provides functionality to send messages to the device without polling.

1 Comment

It is not recommended to send large amount of data via Cloud Messaging, but instead use it to notify the android device that there are changes in the database that it should fetch.
0

You can use MySQL triggers to catch changes. In the trigger code you'll do INSERT INTO changes_log … and you can watch the changes_log table for new records.

2 Comments

yeah, but you need another trigger to watch the changes_log table, or if you write an observer, why that extra step?
@m4t1t0 your solution is definitely better. I didn't know before that triggers can execute external programs. I proposed to create a changes_log because one can make this new table simpler or better suited to be handled by observer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.