Show Message on Android App in Real time - php

I am developing an application, where a random number is being generated in an android app, and after that, I am inserting that code in Web Base app.
What I am looking for is, when I am updating the value from web app to MySql database, I want at the same time, to show a message on android app that number has been saved, without doing any action in Android app.
signage-e36e0: null
I have tried Firebase, but I don't think Firebase would be needed.
Any help would be appreciated.

You can show a message in the app once the Webcall for sending rendom number is finished from app side you can know that event in HTTP Client you are using.
If it's not possible for you to listen to HTTP Response then You can utilize Firebase Cloud messaging(FCM) for this.
When you change the value in the database you can send the message to the app via FCM and app will show a message on the screen based on that message.
https://firebase.google.com/docs/cloud-messaging/

Related

FCM - Send to all users/devices from a PHP script [duplicate]

I have created a small App that's able to receive Push Notifications from the FCM Console.
What i want to do now is to send a Push-Notifications to all Android Phones that got the app Installed using the API. And this is where i got completely lost.
Is there no way to send it to all Phones without collecting all the registration-ids?
Does this only work with the Console but not with the API?
thanx in advance
Sending a message to all the phones like what you do from the Firebase Web Console is only possible from the Web Console.
If you need this feature from the API you can submit a feature request:
https://firebase.google.com/support/contact/bugs-features/
Another possibility is to have all the client registering to a specific topic via FirebaseMessaging.getInstance().subscribeToTopic(topicName)
In this way you can send a message to the whole topic without collecting the registration-ids manually.

How to get messege from server with less data usage in Android?

I am writing a Android program that get message from server. I can refresh my program every second to get message from server, but I don't want to do this work.
Is it possible to send message from server to client IP and then get message with my Android program (that installed in client device)?.
If it is not possible, please say me way to get message from server.
You can use this
1) Use push Notification in your app
2) When user click notification refresh your app (make a http request to your server fetch the update info).
OR
If you don't want to show notification in mobile which is no harm (almost every news app does this). Just don't create notification refresh you app.
for more information refer this
GCM
pushnotification in android

Windows azure push notication and catch the notification to a particular website page

Hi im working on a project who has an existing iOS app that uses windows cloud platform. Our task is to create a website for the app. One of the requirements is to enable to catch notifications created by the mobile app. For example if there is a new user, push notifications will be triggered and a website link will catch the notifications and save the data to a database. My question is, is it possible to catch a notification from windows azure push notification using a php script event listener?
I don't have any background on windows azure and i don't have any access to there windows azure account. The only thing they said is to give them the link of the script that will catch the notifications.
What are some steps thats need to be done?
Thank you
I'm not sure this is possible. Notification Hubs sets up communications so that you can send a notification out to a many different platforms at one time (Apple, Android, Windows Phone, Windows 8, etc.). Each device registers with the Notification Hub (or the registration is done for them by a back end) and provides a unique device ID, also known as a Channel URI. When you need to send a notification the Notification Hub then disperses that notification out to each of the correct Platform Notification Systems (PSNs) which then deliver the notification directly to the device.
I say all of that to indicate while it might be possible to register a listener that is not a device with the notification hub using a REST based API (You'd have to create a viable channel URI) I'm not sure there is any way to be listening as a php script to a PSN. Also, the registrations do expire from time to time and so you'd need to make sure to keep registering. Finally, no notification system is 100% guaranteed to deliver a notification. The device could be off, it could be in a bad reception area, bad network connection, or the PSN just doesn't delivery it for some reason, etc.
My suggestion is to take a step back and modify the code where the notification is being produced and send it both to Notification Hubs for device distribution, but also send the content of that notification to your database directly, or have them right the message to a queue which is processed in the backend to save to the database if the database isn't local to the code generating the notifications. This removes the notification hub involvement as far as your website is concerned.
If you really MUST look into the php script getting the messages then you can start by trying to figure out how php can receive messages from the PSNs, which is not an Azure issue. You can use the Notification Hubs REST APIs to register for them, but I'm very skeptical of that route.

Push Notification using GCM - PHP

I am trying to implement Push Notification using GCM,
Besically i am trying to send Notification to the GCM using my PHP server which will deliver it to my android application.
I have used code at androidhive!
The device is getting registered successfully but i am not receiving any notification at my device nor anything is visible at Google console.
I am not receiving any response from the link used https://android.googleapis.com/gcm/send or https://android.googleapis.com
Is there anything wrong in this approach?
Can anyone suggest me any authentic source for this?
Realizing that some people are facing issues implementing GCM. I have decided to post solution.
The example on AndroidHive is working perfectly. Its just the matter of correct configuration.
Replace project ID in Android app. (You can get project ID from you google's console link i.e google.com/apis/console/#project:xxxxxxxxxxxx:access)
Replace Server API Key on PHP Server(config.php)
Key for server apps (with IP locking).
You can get your IP from WhatIsMyIP.
Key for browser apps (with referers) will not work.

C2DM and PHP Server

I'm trying to write the server side of my android app that uses C2DM. I'm going to write it in php. I basically am just doing tests right now. I copied the chrome to phone example for the actual android app and modified it to my liking. Right now my biggest question is the registration.
Let me get everything straightened out.
When registering the device for the first time, the app talks directly to my server. The server grabs the deviceid and responds back with a 200. Right?
So, on the php side of things, I grab the device id like $deviceid = $_POST['deviceId'] Right?
add it to my database. then respond back to the app.. How exactly do I send a particular response back? I assume in the header? I'm unsure how to do that.
Please confirm or deny that I'm on the right track and clear up any confusion.
Thanks for the help.
You don't respond back to the app. You must register your server with google's servers to get a server authentication token. You then use that server token and the device token in a post request to google's C2DM service to have google's servers send a push notification to the phone. Your app and your server never directly communicate when a push notification is sent in C2DM, it is all done through google, yet you need to implement a mechanism for your server to know the device id of the device it wants to send a message to.
This is a pretty detailed guide, though the server code is in Java:
www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html
Make sure you have really gotten the IDs before sending to the server. If you are using an emulator for testing, you could do an echo over at the php script so the message will appear in your logcat.
Google refreshes expired registration IDs so your application should be able to pick up new notifications/ids from google and handle the message by sending to the database.

Categories