Ionic Push sending messages through the web server

Hello everybody, I implemented in my application the Ionic Push and GCM, tested sending messages CLI and Dashbord and it worked perfectly, but now I would like to automate the way to send notifições using a web application in PHP, I wonder if it is possible and how can I do this.

While I’m not using Ionic Push, I’m using Parse, but I accomplished this thing and think it is a great idea.

I’d stick with Ionic Push. I’m already using parse just fine, but I know the ionic team is amazing and they have a great community behind it, so I’m sure Ionic Push is great.

With that being said, it is totally possible to use Ionic Push with a backend server. They have a REST API you can use to make the requests.

See here:

1 Like

Save the push_token to your backend, use it with the REST API. Done.

I tried to do the post to a url of the Agreement with what is specified and obtained a reply Next :

{
result: "error"
message: "You must provide a valid API key"
}

Looks like you need to provide a valid API Key…

I’d check which keys you are using on the backend and make sure they are the correct ones required.

1 Like
1 Like

Work fine, thanks :slight_smile: :slight_smile:

same problem for me, i am trying to send request in advanced rest client,
url: https://push.ionic.io/api/v1/push
method: post
header:
Content-Type: application/json
X-Ionic-Application-Id: “xxxxxxx”

json:
{
“tokens”:[
"**********************************************"
],
“notification”:{
“alert”:“Hello World!”,
“ios”:{
“badge”:1,
“sound”:“ping.aiff”,
“expiry”: 1423238641,
“priority”: 10,
“contentAvailable”: 1,
“payload”:{
“key1”:“value”,
“key2”:“value”
}
},
“android”:{
“collapseKey”:“foo”,
“delayWhileIdle”:true,
“timeToLive”:300,
“payload”:{
“key1”:“value”,
“key2”:“value”
}
}
}
}

Response: {result: "error"message: “You must provide a valid API key”}

Dont know where to put API key, and in which format, please help

Read the docs:

your POST should authenticate using Basic Access Authentication with no password and your Private API key for a username.

So you take your private API key, add a “:” and “” (for no password) after it, then you base64 this string and send it at the Authorization header - that’s how Basic Authentication works.