sending automatic push notification from mysql to android mobile - php

I have a database that contains some data and i want to get notified automatically on my mobile app if any value in the database is changed without having to check the database every certain time,i have tried many methods and viewed several tutorials but it leads me no where,any help ??

This is not going to be possible with only database. You need to write down an RESTful API which your app needs to poll to look for changes.
Ideal way of doing it is using GSM to push notify your app when ever you change something in your app. This will again require PHP/ASP/NodeJS etc... There must be some way you are updating your database? This should go exactly there.

Related

linking android application to the mysql database phone and link the info as well

Hey guys im faced with a challenge of linking my localhost mysql/php when adding something in a form that form should also be linked with my android application.
ex. I have made a form for the admin whereby they could add a new bus route and it will be stored into their database using php mysql in localhost server now that new route should also be linked to my android application it should display the new route (My android application uses sqlite database so two different database here) so when users use the application when they search for new route it should also display as well
How can i go with that? any ideas please im really stuck in this
thank you
Well there are generally 2 approaches to follow when you want to 'Sync' your web database to your mobile database
Push Notifications: You could send a push notification to all your users, whenever a new route is added to the mysql db. When the notification is received by your app, (it's not necessary you show the notification to the user) you could just ping the server for the new route, or you can send the 'route' in the message part of the push notification if you can, and then add this new route to your sqlite database.
AccountManager: Using the AccountManager is the preferred method when you want to Sync your data. The AccountManager uses the SyncAdapter to Sync your apps data with it's cloud. When Android pings the servers of other apps for syncing, it pings your app's server too, and syncs your data. This method also takes care of issues like, if the internet connection was not working when it was intended to sync, so android will schedule the next sync soon.
To provide a good service, you should take a look at a client-agnostic API architecture.
In this architecture, you have a PHP/go/whatever-written API, that can or can not be REST (but it's reccomended), that will provide, given a HTTP petition, the desired result.
Using PHP in the simplest way, you should create different .php files, one for each action ( www.myserver.com/getRoutes.php, www.myserver.com/getRouteDetail?routeId=3), and make those PHP files query the MYSQL database and return (echo) XML / JSON / Raw text.
this should then be parsed by your mobile application, and added/updated to your SQLite database.

Update app data from server (Swift)

I need some help with refreshing data. I have an app in Swift 2.0 and I want to the server send an action and execute a method in the app. I already try with push notification and It works greate but if the user disable the notification the method still execute? and according my knowledge this method is only execute when you press the notification. What is the best way to acomplish this?
I am trying to avoid that the app constantly request data from the server.
My server is in PHP.
Thanks!
I think you can use protocols/delegates.
Delegates are good ways to be notified only when needed and and alternative to notifications.
Go check for more here :
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html
With this scenario I think we have these locations to request for updates:
At appDelegate, overriding applicationDidBecomeActive, called when the app becomes active in foreground.
In the view didAppear from the main view from our app (the first view that appears when we open our app).
Both options make more requests to the server than they should, but maybe the 1st is the least costly because is called just when app becomes active, and this is a good moment to check for updates.

delay websocket updates and show the message later on?

I have an app where basically players challenge each other. At some point their challenge completes and I need to provide them (both of them - there are two players) with an update message, like 'Hey, you won and got 100500 points'. And vice versa - "Hey You looose"
I use websockets and pusher api to tackle the live updates, this works perfectly when player is "online". But what if they are not? The way to go for me looks like I can still handle the event with pusher and instead just displaying the message, I can store it to db to table challenge_notifications with fields messages and seen = 0. it's ok, but what would be the best way then to show this to the player when he comes online next time? I don't want to have ajax request on every page load checking to see if there are any unseen notifications for the user.
I probably somehow need to fetch all pending notifications only once, when they get online?
I use Laravel 5 for my backend.
There was a recent post on the Pusher blog about how to detect if a user is online or not using the Pusher HTTP API: Enabling Smart Notifications with Pusher and SendGrid.
The example uses SendGrid, but you could instead store the update to a database, send them a Push Notification, an SMS etc.
what would be the best way then to show this to the player when he comes online next time?
I guess there are two forms of "coming online":
The user is no longer on the site and has to navigate to the site. In that case as the page loads you can query the DB and serve them up any missed notifications directly (this would seem the easiest solution). Or, if it fits your app architecture, make a single AJAX request when the page loads to get any missed notifications.
If the user has gone offline due to them being mobile or having a bad network connection. In that case you can bind to the connected event using pusher.connection.bind('connected', function() {}); and then make a query to see if they've missed any notifications.
In summary: it would seem that querying the DB for any missed notifications upon normal page render (on the server) would be the simplest solution and wouldn't required much resource usage. But there are alternative mechanisms of delivering a notifications (email, SMS) if they're not online.

notify user in android application when inserting new record by website

I have an android project that connected with website using php and MySql DB
I want to notify the user that has the application when the admin insert new record by the website.
I'm searching for solutions, and I found this one
http://developer.android.com/guide/google/gcm/gs.html
but I didn't Know, is it the suitable solution for me?
or there are another solutions
thanks
That looks like a fine way to notify your app - you'll just have to add in the code on the website to call gcm when the data changes.
Another solution would be to have your app periodically poll the website for changes, but that's costly in terms of bandwidth. I'd use GCM

Using Google Plus API to store stream data in MYSQL database

I've been playing with the Google+ API PHP starterkit. My ultimate goal is to run a cron job on my server that uses the Google+ API to grab the activity data, then store it in a MYSQL database-- where I can then dynamically update a twitter-like feed on a website.
Is this a possible/practical way of mining a Google+ profile's public stream? If not, what do you suggest as a good alternative?
Sounds like a good way to me.
One thing you have to keep in mind though is that there is no easy way to check if an activity has been deleted after you have added it to your database. You would have to check with $plus->activities->get($activityId) for each of the activities you want to display to see if it still exists (unless of course you don't mind them appearing on your website).
Apart from that your solution will work fine.

Categories