Closed sandy-abrightmind closed 8 years ago
You have to POST to actions/pushNotifications/registerDevice with:
{
'app': 'app_handle',
'platform': 'ios/android',
'registrationId': 'token'
}
P.s. send these as POST params, not as JSON ;-)
I'm still not doing something right. =(I'm testing via Postman.Is the correct URL: localhost/CraftCMS/public/admin/actions/pushNotifications/registerDevice ?I've attached a screenshot of my postman configuration.Thanks!SandyOn October 15, 2015 at 8:21 AM Bob Olde Hampsink notifications@github.com wrote:You have to POST to actions/pushNotifications/registerDevice with:{ 'app': 'app_handle', 'platform': 'ios/android', 'registrationId': 'token' }P.s. send these as POST params, not as JSON ;-)—Reply to this email directly or view it on GitHub.
Sorry, I didn't get the screenshot
Yeah, I just realized that it didn't send it via the email. Here it is.
Ah, you're sending them as Headers instead of as Post values
Oops.
I added them as params and it still doesn't work. =(
If I type the url that it created into an address bar, it gives me "Page Not Found" error... so maybe it's the URL that I have wrong?
Yeah sorry, the url should be /actions/pushNotifications/devices/registerDevice
It works if I submit the URL to the browser but it doesn't add a new device if I do it from postman.
Any ideas why it won't work from postman?
I'm assuming that I won't run into any authentication problems when I try to submit it from my Android/iOS code?
Because you have the variables both in the url and in the post body?
I don't understand what you mean by that. I have postman configured with the exact same url as above and it doesn't work. I was just curious if that's because it doesn't know the login credentials for CraftCMS. And maybe in the browser, the credentials are cached?
No, the call can always be made anonymously.
Your url should not have "?app=gcm&platform=android®istrationId=test9823" in it, these should be POSTed
It did that automatically when I set the params in Postman.
When I ran my url in the browser, it returned success as true for that url.
And it added the new device token to Craft when I ran that url in the browser.
However, if I run it via Postman, it does not add the new device token.
It only does that automatically when you've selected GET instead of POST
Here is a screenshot of my postman configuration.
I have it selected as POST and it still adds the params to the URL.
Ok, looks like you're posting with get variables, but empty post body. Can you look inside the Body tab?
The body tab was empty.
Even when I add the information there, it doesn't work in Postman.
Okay, so if I log out of CraftCMS then the URL that worked in the browser doesn't work. It takes me to the login page of craft. =(
I figured it out!!!
It was my URL. Here is a new screenshot:
Thank you for your help! =)
Nice! That was actually what I was trying to say ;-)
Yeah, I'm new to CraftCMS so I wasn't sure how to access it. =) Thank you for all of your help!!
Hi
I've been trying to figure out how to add a new device token to an app via Android/iOS code instead of through the CraftCMS CP?
Can I add a new device token via URL?
If so, what is an example URL with the POST parameters?
Thanks! Sandy Davis