GCM PHP get message status - php

I am implementing a GCM server communication using PHP. I have implemented the code in PHP and able to send the messages successfully to the device. But when the device isn't connected to network the message is lying in the server. The PHP is getting a success response. When the device network is turned on the message is getting actually sent to the device.
My question is that is there a way that I can get back from the GCM server or ping GCM server to know the status of the message_id I sent.

You need to use Upstream Messages. It has a delivery receipt requested feature. Check out this documentation here : http://developer.android.com/google/gcm/ccs.html#receipts

If you use the simple HTTP communication with the GCM server, your only way to know if the app received a message is to put some message identifier in the message payload (not the message identifier returned by GCM server, since you can't access that in the app), and to send that message identifier from your app to your server when the message is received.

Related

Mail shoot from server while receiving error from volley in android

I am sending some data from my app to the server using volley library. When the network connection is too slow then I got volley timeout error and received no response from the server but server shoots an email. I have asked for the solution but nothing works. Please provide me some solution

Keeping socket open in Swift for chat application

I have a working chat server in Php/Ratchet. I am using Starscream as my client in Swift. I successfully created a chat between users however this only works when my application is open because this is when the socket is open. How do I make my app receive messages even if my app isn't on. So basically is there a way to keep sockets open. I read somewhere that it is forbidden by Apple.
There's a high probability that your process is going to be shutdown by the system at some point, so I wouldn't rely on the app being active in the background.
Try coming up with a solution for receiving past messages when the client becomes online.
Read about Apple Push Notification Service to notify your users about messages while the app is not active.
Sounds like you are sending messages from your client to your phone. You need to send messages to a server and the server sends them to your phone.
The server, if unable to successfully send a message to your phone, should store the message and should send the stored messages to the phone when the phone is available.
There are message queuing systems for things like this. See, for example, RabbitMQ. There are loads of others too that may work better with your tech stack. Do some research.
Here the client talks to the server, the server hooks up with RabbitMQ or whatever you choose to use, RabbitMQ keeps a track of queued messages and when the phone comes online, RabbitMQ sends the queued messages to the server and the server sends them to the phone.
PS Google "message queue PHP".
You need to be in sync with server. Do following steps.
Dump every message in Database i.e. conversation from both parties with timestamp.
When app goes in to background and comes to foreground flush your all messages which are on your screen/local array for showing messages on screen, call a Sync service which will fetch whole conversation, because definitely server will be having all messages, feed you screen with this service response.
The iOS system will receive socket calls at kernel level but will not pass those messages to you app, so you will not get messages while app is in background.
When app is killed you can implement APNS from apple.

Php Notification system and websocket

i'm trying to develop a PHP notification service for a CRM used by my customers.
Scenario: an user add an appointment for a collegue, and this collegue has to receive a notification inside his CRM profile like, for example, Facebook did.
The structure is pretty simple: a PHP Server in listening with the client browser connected with Websockets.
Server: i'm using Ratchet - PHP WebSockets, i've followed the examples and started the server, server that is able now to accept connection and deliver messages to all clients connected or just to one receiver.
Client: a simple JS script, with Websocket connection and method, that handle all receiving messagges and notify all to the user connected.
My point is: i'm guessing to have the websocket client browser just for incoming messagge, i don't want to allow them to send nothing, the send part must be done by the server that has access to DB in this way:
1) FORM Appointment
2) Submit to the server and save it to DB, in this step a client PHP Websocket connect to the Ratchet server and send the notification to the receiver.
3) The Websocket of receiver receive the notification and alarm the customer.
The questions are:
what can i use to do the step 2 with the PHP websocket client to connect with the Websocket server? is good to use Pusher interface like this example suggest: http://socketo.me/docs/push or can i avoid using this system?
how can i handle the idle time of websocket client ? a timer that send a ping like message to client for avoiding the dead of websocket?
-how handle possible down of client side or server side?
THanks to all of you!

TCP/IP protocall, Android, PHP sending to and reciving from server

I want to send a message to a PHP script on a server from one android device using HttpURLConnection and have the PHP script send the message to a second phone using file.getContents().
When a phone connects with the server is it possible to leave the phone waiting for a response by not echoing a response?
Can I then later use the same connection to respond to the device by executing file.getContents() and passing in the IP address of the device that had initially connected?
Thanks!

Push notification different Messages for different servers ios

I have set up many push notifications in iOS projects. I always receive the same message which I have sent from my application, all going well.
But when I change my server from my local machine (or a dedicated server) to web hosting the message format changes somewhat. For which we are not accepting.
Sample message from our server:
{"msg":"match found !","match_id":"34","rqst":"1"}
Sample message from web hosting server (remote server) :
{\"msg\":\"Match found !\",\"match_id\":\"34\",\"rqst\":\"1\"}
It contains extra backslashes before and after every string.
FYI we are using Slim Framework with PHP MySQL APIs, and the messages sent are JSON.
Use PHP to get ride of the slashes before sending the message.
<?php stripslashes($YourMessage); ?>

Categories