Corona Cloud Push Notifications

Hi greglosang, I’ll get the team to look at this straight away.

Thanks

-Mohamed

Mohamed,

Another concern:

In corona-cloud-core.lua, it appears that coronaCloudController.authToken is a required variable when

calling coronaCloudController.registerDevice (it’s used on line: 487)

The problem is that this variable, coronaCloudController.authToken is never set anywhere!  The only

place it would be set that I can tell is either in:

coronaCloudController.loginAPI

or

coronaCloudController.loginFacebook

But since I’m only wanting to use the Push Notifications, not any of the other features, I would never have a user logging in at all, so that means the authToken would never be set.

So is it really possible to use ONLY the Push Notification feature?  The devices would need to each be registered without any logging in, they would be registered when the user first indicates they want the notifications.

Then, in PHP I’d like to use a single command to then send a message to all registered users.

Is this possible?

Why is coronaCloudController.authToken used in coronaCloudController.registerDevice?  Or is it (hopefully) just nil and ignored?

I’m also not having any luck with the PHP to send the notification; here’s what I’ve got:

This is the response I’m getting (I changed a few chars after Authorization Basic):

Error Code:Array ( [url] => https://api.coronalabs.com/notifications.json?message=Hello [content_type] => [http_code] => 400 [header_size] => 66 [request_size] => 353 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.55188 [namelookup_time] => 0.270326 [connect_time] => 0.312304 [pretransfer_time] => 0.509163 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => -1 [starttransfer_time] => 0.55183 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => 54.235.69.115 [redirect_url] => [request_header] => POST /notifications.json?message=Hello HTTP/1.1 Authorization: Basic NxxxxxzA0ODgwMjAwMxxxxxDg4NzICHangedThisZGZjNTU3YxxmMzoyYzZmxzBlZGFhODI5xxxxxjk1OGNlMzI2YWM2MWJhNzcxYmRmYjZj Host: api.coronalabs.com Accept-Encoding: deflate, gzip Accept: application/xml Content-Type: application/xml; charset=UTF-8 Content-Length: -1 Expect: 100-continue ) Call Failed 1

This is my PHP code:

<!DOCTYPE html>

<html lang=“en”>

<head>

</head>

<body>

<?php

$accesskey = “accesskeyfromcoronacloud”;

$secretkey = “secretkeyfromcoronacloud”;

$url = “https://api.coronalabs.com/notifications.json?message=Hello”;

$curl = curl_init($url);

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);

curl_setopt($curl, CURLOPT_USERPWD, “{$accesskey}:{$secretkey}”);

$headers = array();

       $headers[] = ‘Accept: application/xml’;

       $headers[] = ‘Content-Type: application/xml; charset=UTF-8’;

       

 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

 curl_setopt($curl, CURLOPT_POST, TRUE);

 curl_setopt($curl, CURLOPT_VERBOSE, 1);

 curl_setopt($curl, CURLOPT_HEADER, TRUE);

 curl_setopt($curl, CURLINFO_HEADER_OUT, true);

 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

 curl_setopt($curl, CURLOPT_ENCODING, ‘’);

 curl_setopt($curl, CURLOPT_TIMEOUT, 15);

 curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);

 curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);

$response = curl_exec($curl);

$resultStatus = curl_getinfo($curl);

print “Error Code:” . curl_error($curl);

                                   

if($resultStatus[‘http_code’] == 200) {

    echo $response;

} else {

    echo 'Call Failed '.print_r($resultStatus);                         

}

curl_close($curl);

?>

</body>

And if I change to this:

curl_setopt($curl, CURLOPT_USERPWD, $accesskey.":".$secretkey);

I get this:

Error Code:Array ( [url] => https://api.coronalabs.com/notifications.json?message=Hello [content_type] => [http_code] => 400 [header_size] => 66 [request_size] => 353 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.406769 [namelookup_time] => 0.189662 [connect_time] => 0.2322 [pretransfer_time] => 0.336428 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => -1 [starttransfer_time] => 0.406697 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => 184.73.229.231 [redirect_url] => [request_header] => POST /notifications.json?message=Hello HTTP/1.1 Authorization: Basic NGIChangedSomeOfThismNDg4NzdkIChangedSomeOfThisyYzZmNzBlZGFhOIChangedSomeOfThisM2MWJhNzcxYmRmYjZj Host: api.coronalabs.com Accept-Encoding: deflate, gzip Accept: application/xml Content-Type: application/xml; charset=UTF-8 Content-Length: -1 Expect: 100-continue ) Call Failed 1

Hi greglosang, 

Currently users need to login at least once so they can get an auth_token. 

As I have suggest to a different user on the forum; we are looking into how we can allow new user creation without an email, but in the mean let me suggest this workaround.

You can prompt your user to enter a UserName only, and then you can auto create the email address transparently.

I would suggest you do something like this: [appName]+[UserName]@gmail.com; where [appName]@gmail is an account you have already.

So it might look something like this: myapp+greglosang@gmail.com.

After the user logins in and gets their auth__token, you can register their device.

Give it a try and let me know.

Thanks

-Mohamed

Thanks for the info Mohamed, but it doesn’t make sense in my Apps to require users to sign in just so they can get push notifications.

I guess this makes the Corona Cloud useless for me, for now.

Isn’t it possible just to save the device tokens then send a push message to all the tokens the same way it works if you

weren’t using Corona?  Apple doesn’t require any kind of a signin in order to receive push notifications on devices.

I guess it’s back to writing my own php and just saving the device tokens myself.

Hi greglosang,

I will add your comments/requirement to our system and make sure we look into how we can address it in the future.

Your situation is a unique one, because you are broadcasting to everyone and don’t have any requirement to segment, where you will need to be able to have another level of ID for your users.

What I would recommend is that you give our system a go and see how it works out for you, as I am sure the effort to transparently logging-in your users is many factors easier, and quicker than setting up the whole process for yourself.

In any case, best of luck and feel free to let us know how we can assist.

Thanks

-Mohamed 

Mohamed,

Are you implying by constructing the email address and using the login API call there is a way to login the user without any intervention on the user’s behalf other than the original system prompt that they want push notifications?

Hi,

Sure, there is no need to display anything to the user at any point.

You can make all registration and login calls transparently with no UI.

Thanks

-Mohamed

Hi Mohamed,

Hope you are doing well! I read your comments about push notification for corona cloud that seems interesting for me, I’m working over an game that need some functionality from corona cloud. I’m new for corona cloud. I’m trying to send challenge to corona cloud user in the form of push notification if user have installed the game and registered for push notification. I configured my app on corona cloud server for push notification that are enabled from there, I also have access to register device for push notification (not getting push notification on device by sending there,  server says “Notification is successfully sent.” :(  ). I also found “notification_channel_ids” in response of myprofile but it is always an empty array. :frowning:

Am I doing something wrong?
Thanks in advance!

Usman Mughal

Push Notification with cloud is a pain. I have spent tremendous amount of time figuring out the proper way to handle iOS Push Notifications and I succeeded to make it in elegant way with Parse.com as a backend. 

I thought some of you guys might want to save long hours of testing so I packet everything up for you: CoronaSDK iOS Push Notifications

Piotr, I am tempted to give your tutorials a go but seeing that you only have 3 posts to your name (all of which are to promote your tutorial…) I must say I am a little concerned. No offense intended.

In order to better promote your good work; may I suggest…

  • Post a video showing your app in action. Parse to enter push message, phone in hand beeping with your message etc. 
  • Put a free app on AppStore with your push code running say every 15 mins. 
  • Post a fresh thread about your tutorial in the “Corona Market Place” / “Other Products and Services” section of this forum so it does not look as if you’re spamming all push related threads… 

This way all prospective clients might have a better idea and impression about your tutorials. Best of luck in your endeavor  I want to be convinced so I can buy your tutorial and get this Push thing sorted out. 

Thanks much!!!

Thank you for taking your time and giving me this valuable feedback!  I will use it right away.

Actually I have another account here from a long time: Blerdo.com which is my mobile consultant agency.

I have created this new account because I have decided that I will do tutorials and teaching under my real name for better creditability. (which turned out to be the opposite ;)) I plan to put a lot more from my experience on my website and share it thought the newsletter.

When I will have the video I will post it here.

Take care.

Hi Piotr, 

This is great! I am sorry for not connecting the dots. I now see that you have been a long time member of the Corona SDK family with a lot to speak for your name. I am sure your tutorial is wonderful and full of valuable content. I will go ahead with it as soon as possible. 

Thanks & best regards,

Kerem

@piotr: It would be great if you had mentioned that the “package” is $19.

Hi Mohamed,

Hope you are doing well! I read your comments about push notification for corona cloud that seems interesting for me, I’m working over an game that need some functionality from corona cloud. I’m new for corona cloud. I’m trying to send challenge to corona cloud user in the form of push notification if user have installed the game and registered for push notification. I configured my app on corona cloud server for push notification that are enabled from there, I also have access to register device for push notification (not getting push notification on device by sending there,  server says “Notification is successfully sent.” :(  ). I also found “notification_channel_ids” in response of myprofile but it is always an empty array. :frowning:

Am I doing something wrong?
Thanks in advance!

Usman Mughal

Push Notification with cloud is a pain. I have spent tremendous amount of time figuring out the proper way to handle iOS Push Notifications and I succeeded to make it in elegant way with Parse.com as a backend. 

I thought some of you guys might want to save long hours of testing so I packet everything up for you: CoronaSDK iOS Push Notifications

Piotr, I am tempted to give your tutorials a go but seeing that you only have 3 posts to your name (all of which are to promote your tutorial…) I must say I am a little concerned. No offense intended.

In order to better promote your good work; may I suggest…

  • Post a video showing your app in action. Parse to enter push message, phone in hand beeping with your message etc. 
  • Put a free app on AppStore with your push code running say every 15 mins. 
  • Post a fresh thread about your tutorial in the “Corona Market Place” / “Other Products and Services” section of this forum so it does not look as if you’re spamming all push related threads… 

This way all prospective clients might have a better idea and impression about your tutorials. Best of luck in your endeavor  I want to be convinced so I can buy your tutorial and get this Push thing sorted out. 

Thanks much!!!

Thank you for taking your time and giving me this valuable feedback!  I will use it right away.

Actually I have another account here from a long time: Blerdo.com which is my mobile consultant agency.

I have created this new account because I have decided that I will do tutorials and teaching under my real name for better creditability. (which turned out to be the opposite ;)) I plan to put a lot more from my experience on my website and share it thought the newsletter.

When I will have the video I will post it here.

Take care.

Hi Piotr, 

This is great! I am sorry for not connecting the dots. I now see that you have been a long time member of the Corona SDK family with a lot to speak for your name. I am sure your tutorial is wonderful and full of valuable content. I will go ahead with it as soon as possible. 

Thanks & best regards,

Kerem