4

I post this JSON exactly the same in android and postman:

{
"notification":{
"title":"stackoverflow commmunity",
"body":"is awesome"
},
"to":"[mycode]"
}

I define my header in android like this:

urlConn.setRequestProperty("Content-Type", "application/json");
urlConn.setRequestProperty("Authorization", "key=[mykey]");

But I think the header in Android doesn't work and I don't know why because in Postman I get:

Tasks have been queued for a long time
Johannes Gnadlinger
  • 1,339
  • 1
  • 12
  • 32
  • 2
    Hi. Can you post the complete code? And by Android, do you mean you're sending a notification message from the device itself? – AL. Jan 14 '17 at 23:41
  • 1
    I want to send a notification to all devices when data changed in my firebase db. Uploaded my code on [github](https://github.com/Gnadlinger/Presentation.git) – Johannes Gnadlinger Jan 15 '17 at 10:54
  • 2
    Hi. I've seen your code. You're doing something similar to [this](http://stackoverflow.com/q/41560266/4625829). And as mentioned in the comments section, please avoid exposing the Server Key, on your client app side. With that said, the only difference I'm seeing from your code and the post I cited is this -- `setRequestProperty("Authorization", "key=" + AUTH_KEY);`. Can you try following the format? See if it works. – AL. Jan 16 '17 at 03:53

0 Answers0