Yes, it is possible using the REST API as ksan mentioned.
I have a wordpress site that receives photos uploaded from my app and when I approve a photo to be shown, the user receives a Push notifying the user that his photo was approved.
Yes, it is possible using the REST API as ksan mentioned.
I have a wordpress site that receives photos uploaded from my app and when I approve a photo to be shown, the user receives a Push notifying the user that his photo was approved.
Here is a curl example you can copy paste into Terminal (Linux/mac) to test push to your own devices:
curl -X POST \ -H "Content-Type: application/json" \ -d '{"app\_id": "MY-APP-ID", "include\_ios\_tokens": ["MY-IOS-DEVICE-ID"], "include\_android\_reg\_ids": ["MY-ANDROID-REG-ID"], "contents": {"en": "Hello world"}}' \ https://gamethrive.com/api/v1/notifications
This thread has some PHP example: http://forums.coronalabs.com/topic/47808-issue-with-api-call/
Thanks everyone!
I’ll probably stick to GameThrive then.
So I am also sorry for starting this dreadful thread again But since I am stuck with Parse for all their other backend stuff I want PUSH to work from their service as well. I don’t like being on several platforms for huge projects. So I got everything working from both iOS and Android using Restful API and Parse except… the Push received on an Android device is empty, why?
Whatever I write at Parse, blank, custom Json or whatever it will be blank when received. It is received in matter of milliseconds but still empty.
Anyone, please?
What is the json you send to parse for the notification? I use pushbots these days, but perhaps it’s similar: I had to define message (alert content) twice in the json (one in root and one time in the payload) in order for it to work on both platforms:
commands_json =
{
[“platform”] = { 0, 1},
[“msg”] = sendMsg,
[“sound”] = psound,
[“badge”] = “+1”,
[“tags”] = { fbuser },
[“payload”] = { [“alert”] = sendMsg,
[“sound”] = psound,
[“custom”] = { [“fb”] = fb,
[“fi”] = fi }
}
}
Hi
I am only trying to use Parses own Push Sending Web Interface and nothing works. The complete JSON getting sent is like below.
{ “alert”: “test” }
I have also tried to send through CURL with the below but my keys are marked XXX.
curl -X POST \ -H "X-Parse-Application-Id: XXX" \ -H "X-Parse-REST-API-Key: XXX" \ -H "Content-Type: application/json" \ -d '{ "where": { "channels": { "$in": ["SSF","SmartPhone"] }, "deviceType": "android" }, "data": { "alert": "Alert message here." } }' \ https://api.parse.com/1/push
And less than a second after executing the push ends up on all Android devices but with custom and alert empty.
So I am also sorry for starting this dreadful thread again But since I am stuck with Parse for all their other backend stuff I want PUSH to work from their service as well. I don’t like being on several platforms for huge projects. So I got everything working from both iOS and Android using Restful API and Parse except… the Push received on an Android device is empty, why?
Whatever I write at Parse, blank, custom Json or whatever it will be blank when received. It is received in matter of milliseconds but still empty.
Anyone, please?
Hi, I’m stuck in the same part using Parse and GCM.
I’m receiving push notifications from Parse, but empty:
I/Corona (17471): ### — Notification Event —
I/Corona (17471): ### type: remote
I/Corona (17471): ### name: notification
I/Corona (17471): ### custom
I/Corona (17471): ### {
I/Corona (17471): ### }
I/Corona (17471): ### alert:
I/Corona (17471): ### applicationState: inactive
But when I use the Google Notification example, I get custom and alert messages.
I believe it’s Parse problem, right?
What do you think?
What is the json you send to parse for the notification? I use pushbots these days, but perhaps it’s similar: I had to define message (alert content) twice in the json (one in root and one time in the payload) in order for it to work on both platforms:
commands_json =
{
[“platform”] = { 0, 1},
[“msg”] = sendMsg,
[“sound”] = psound,
[“badge”] = “+1”,
[“tags”] = { fbuser },
[“payload”] = { [“alert”] = sendMsg,
[“sound”] = psound,
[“custom”] = { [“fb”] = fb,
[“fi”] = fi }
}
}
Hi
I am only trying to use Parses own Push Sending Web Interface and nothing works. The complete JSON getting sent is like below.
{ “alert”: “test” }
I have also tried to send through CURL with the below but my keys are marked XXX.
curl -X POST \ -H "X-Parse-Application-Id: XXX" \ -H "X-Parse-REST-API-Key: XXX" \ -H "Content-Type: application/json" \ -d '{ "where": { "channels": { "$in": ["SSF","SmartPhone"] }, "deviceType": "android" }, "data": { "alert": "Alert message here." } }' \ https://api.parse.com/1/push
And less than a second after executing the push ends up on all Android devices but with custom and alert empty.
It is by far parse’s fault, I spent 40 hours trying to solve it and I did not get any response from parse at all so I skipped and went to GameThrive, it worked in 5 minutes.
On a lot of these push systems you have to actually make sure to include the ‘alert’ key with the data you want to display on your Android device.
Best.
Using Pushwoosh via their REST API: https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/
(The free version doesn’t have REST API though unfortunately, so it’s paid service only for using with Corona)
Okay, I think I’m well on the way to solving this Parse push notifications on Android in Corona business once and for all.
First, some clarity about what I think the Parse REST API docs are trying to tell us in it’s own special kind of way:
The REST API is meant for importing installations. Using it to create them is kind of a hack - especially on Android.
That out of the way, here’s how we “import” installations for Android devices (as they’re created in real time - you probably use the word “registration” for this, like normal people).
Now, here’s where it gets interesting.
Add this code to your main.lua
print ("Registering for push notifications") local function notificationListener( event ) if ( event.type == "remote" ) then --handle the push notification print( "[PUSH] REC PUSH NOTIFICATION:" ) --require("pl.pretty").dump(event) elseif ( event.type == "remoteRegistration" ) then --code to register your device with the service print( "[PUSH] REMOTE REG" ) --require("pl.pretty").dump(event) local function onInstallation( event ) if not event.error then print( event.response.value ) end end --realistically, put a conditional here and only do this for android local installationObj = { ["deviceType"] = "android", -- important ["pushType"] = "gcm", -- important ["GCMSenderId"] = "XXX", -- important, and see my note below ["deviceToken"] = event.token, -- important ["channels"] = { "" }, -- you can change this if you need to } -- if you're not using mod\_parse, you should be. parse:createInstallation( installationObj, onInstallation ) end end
You’ve seen this code in the Corona Demo for Push Notifications, and it probably looks even more familiar if you’ve been staring blankly at the mod_parse push notifications documentation like have.
The most important thing to point out here is that GCMSenderId should be the same one you plugged into your settings in Parse.
What you’ve done essentially here is created a Push installation by assembling everything on-the-fly and importing it. The GCM Sender ID stuff is the missing link that we’ve all been trying to figure out.
When you run this (on an android device, or the android emulator targeting Google APIs and signed into a Google account, not the Corona Simulator), you should see some output that a record got created (if you have mod_parse debugging on). You can also pop into parse and look at the installations table to confirm this.
Now, fire up some curl and send a notification:
curl -X POST \ -H "X-Parse-Application-Id: XXX" \ -H "X-Parse-REST-API-Key: XXX" \ -H "Content-Type: application/json" \ -d '{ "channels": [""], "data": { "alert": "Test Push" } }' \ https://api.parse.com/1/push
You should get a push notification, that probably looks hideous and has no content, but it works. Im still working on figuring out how to get all the right pieces in the right places on the notification, but we’ve basically got end-to-end push notifications.
Using Parse.
On Android.
Using Coronoa.
*drops mic*
(Seriously, I’ve been at this for quite some time today. It’s time for bed. I’ll try to get the rest working and update. Feel free to beat me to it.)
One final note. I commented these out because I don’t know if anyone is using them, but the “Penlight” library is Lua gold. if nothing else, get yourself some “pl.pretty” for dumping tables, but theres lots of other useful stuff in there and you can pick and choose what you want.
Hi, I’m stuck in the same part using Parse and GCM.
I’m receiving push notifications from Parse, but empty:
I/Corona (17471): ### — Notification Event —
I/Corona (17471): ### type: remote
I/Corona (17471): ### name: notification
I/Corona (17471): ### custom
I/Corona (17471): ### {
I/Corona (17471): ### }
I/Corona (17471): ### alert:
I/Corona (17471): ### applicationState: inactive
But when I use the Google Notification example, I get custom and alert messages.
I believe it’s Parse problem, right?
What do you think?
It is by far parse’s fault, I spent 40 hours trying to solve it and I did not get any response from parse at all so I skipped and went to GameThrive, it worked in 5 minutes.
On a lot of these push systems you have to actually make sure to include the ‘alert’ key with the data you want to display on your Android device.
Best.
Using Pushwoosh via their REST API: https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/
(The free version doesn’t have REST API though unfortunately, so it’s paid service only for using with Corona)