Closed tribitinfotech closed 7 years ago
Hi @tribitinfotech , When send a push notification the package sends a post request to the provider, in your case FCM. That post content is json type always. Then the provider is the one what send the notification to the client/s (devices). So how the data gets the devices is out of the package's scope.
Please recheck how you are parsing the data from your android side.
What is the backend response after sending the notification?
Use getFeedback()
method after sending notification in order to get the provider response.
Hi @Edujugon Andtoid side I am using parsing
try { JSONObject json = new JSONObject(remoteMessage.getData().toString());
String title = json.getString("title"); String message = json.getString("body"); String Url = json.getString("imag_uri");
} catch (Exception e) { Log.e(TAG, "Exception: " + e.getMessage()); }
I am getting exception on first line because As I can see in response. there is "" missing in key and value in pushnotification response. I had implemented push notification in android many times and used php server for send push. every time got proper json response. but this time I am using your pushnotification code and not getting valid json push notification response.
@tribitinfotech ,
Could you please paste here an example of data you are sending from backend and also the data you are getting in client side? Also, paste here the pushNotification response (getFeedback()).
@tribitinfotech ,
Also give a try to the below code:
Map<String, String> params = remoteMessage.getData();
JSONObject object = new JSONObject(params);
Log.e("JSON_OBJECT", object.toString());
@tribitinfotech ,
From backend you should do something like follows:
$push->setMessage([
'data' => [
'imag_uri' => 'https://static.pexels.com/photos/4825/red-love-romantic-flowers.jpg',
'body'=> 'Shy7lo Offer',
'title' => 'Shy7lo Offer'
]
])->setDevicesToken(HERE-YOUR-TOKENS)
->send()
->getFeedback();
@tribitinfotech , Did you have a chance to try my suggestions?
Since I haven't got any reply I assume it was solved...Closing the thread.
I am sending data by fcm server. but at android side developer getting response like that.
{imag_uri=https://static.pexels.com/photos/4825/red-love-romantic-flowers.jpg, body=Shy7lo Offer, title=Shy7lo Offer}
That is not well formated json response so user getting error while parsing.