Hi!
I tried to implement the new push service and it’s working so far!!!
But now I’m struggling with the REST Api to send notifications from the app / a server.
I read http://docs.ionic.io/v1.0/docs/push-sending-push but I’m not sure what to do with this information. Is it possible to make such a POST with PHP or are there any examples/tutorials where I can see how to configure this?
Can’t anyone help me with this? I think this is one of the main things what a developer wants to do with the push service, because only on this way a user can get notified from another. Or not?
Those are simple command that makes the required POST request to the ionic push service that in turns sends the real notification through GCM or APN services.
Were you able to register your client and get a device token? If so you can try to send a push substituting the parameters in this command right away:
curl -u PRIVATE_API_KEY: -H “Content-Type: application/json” -H “X-Ionic-Application-Id: APP_ID” https://push.ionic.io/api/v1/push -d ‘{“tokens”:[“DEVICE_TOKEN”],“notification”:{“alert”:“I come from planet Ion.”}}’
PRIVATE_API_KEY: the private key parameter configured in your apps.ionic.io application.
APP_ID: the id of your apps.ionic.io application
DEVICE_TOKEN: the token received during the registration process of the client. This is the most critical piece of data.
After you manage you to successfully send a push with curl you can easily construct the same POST request with PHP and therefore send the push with your backend app.
Sorry but I don’t have a PHP example to show you, I use python on my backend.
Yes, I was able to register a client and got a device token. I was also able to send and receive a push notification via the CLI option ‘ionic push -s’.
But the problem ist still how to get this done with PHP.
In the example is the python-code, but I didn’t get the CURL command running with PHP.
Obviously substituting correct values for PRIVATE_API_KEY and APP_ID.
You’ll also need to substitude the actual value of the token in DEVICE_TOKEN.
I’m no way an expert in PHP (just googled the commands) and I did not tested anything but that should be what you are missing.
I’m also no pro, but doing it exactly how it’s described in the docs: http://docs.ionic.io/v1.0/docs/push-from-scratch worked very well for me, so give it a try maybe with the demo code also given there!
I also just followed this example and unfortunately have no idea where the problem can be. One time I forgot to send my google api key to ionic, then it won’t work naturally;
ionic push --google-api-key your-google-api-key
If you pushed it to ionic you can also send one-time messages through the ionic.io backend under “Push”. There you also can see the log if the push was done correctly and search after single messages.
2nd: The app should receive pushes from google even it’s closed.
Man Thanks a lot for the code ! Was struggling for the past couple days!
I just copy/paste and it worked just fine.
Now let’s have some fun notifying everyone !
I need your help I follow all the instructions and every push notification that i send at API page ( $url = ‘https://api.ionic.io/push/notifications’; ) goes in 201… Always {“meta”: {“status”: 201, “request_id”:
“3c10ffb6-903f-49d6-81ec-11fe7af082ec”, “version”: “2.0.0-beta.0”},
“data”: {“status”: “open”, “uuid”:
“7cb82e5a-0786-476b-97bd-5a17f9ab6dc8”, “state”: “enqueued”, …
What can i do? nothing is recived, but if i try with same token device from web notification appear… HELP ME pls!
I have created a simple library that allows you to consume the Ionic Cloud API for sending push notifications (normal and scheduled), get a paginated list of sending push notifications, get information of registered devices, remove registered devices by token, …