surrealroad / Safari-Push-Notifications

Reference Server for pushing Safari Notifications via Apple Push Notification Service For use with Safari Push Plugin for Wordpress (https://github.com/surrealroad/wp-safari-push)
23 stars 9 forks source link

Doesn't send any push notification! #5

Closed DohaSoul closed 10 years ago

DohaSoul commented 10 years ago

I get the permission and the device token saved to the DB, but when I try to send a push notification nothing happen!

I tried to convert the cer to pem as it describe on the README "openssl x509 -in website_aps_production.cer -inform der -out apns-cert.pem -nodes -clcerts" but I got an error which says: "-nodes is an unknown option." so I tried the ways described here: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 which is: openssl x509 -in website_aps_production.cer -inform der -out apns-cert.pem

but when I tried to test it, it says: "verify error:num=20:unable to get local issuer certificate"

then I saw on this website it says that error is just fine! http://lessons.runrev.com/m/4069/l/53405

so I tried another way which convert the ,p12 also to pem them combined them into new .pem as it described on the both up websites, but same thing I'm not getting any push notification!

I also tried the Demo on this website: https://kandutech.net and it's working just fine! but on my website I didn't get any notification.

surrealroad commented 10 years ago

Try using -nokeys instead of -nodes

DohaSoul commented 10 years ago

same error: unknown option -nokeys

usage: x509 args -inform arg - input format - default PEM (one of DER, NET or PEM) -outform arg - output format - default PEM (one of DER, NET or PEM) -keyform arg - private key format - default PEM -CAform arg - CA format - default PEM -CAkeyform arg - CA key format - default PEM -in arg - input file - default stdin -out arg - output file - default stdout -passin arg - private key password source -serial - print serial number value -subject_hash - print subject hash value -issuer_hash - print issuer hash value -hash - synonym for -subject_hash -subject - print subject DN -issuer - print issuer DN -email - print email address(es) -startdate - notBefore field -enddate - notAfter field -purpose - print out certificate purposes -dates - both Before and After dates -modulus - print the RSA key modulus -pubkey - output the public key -fingerprint - print the certificate fingerprint -alias - output certificate alias -noout - no certificate output -ocspid - print OCSP hash values for the subject name and public key -ocsp_uri - print OCSP Responder URL(s) -trustout - output a "trusted" certificate -clrtrust - clear all trusted purposes -clrreject - clear all rejected purposes -addtrust arg - trust certificate for a given purpose -addreject arg - reject certificate for a given purpose -setalias arg - set certificate alias -days arg - How long till expiry of a signed certificate - def 30 days -checkend arg - check whether the cert expires in the next arg seconds exit 1 if so, 0 if not -signkey arg - self sign cert with arg -x509toreq - output a certification request object -req - input is a certificate request, sign and output. -CA arg - set the CA certificate, must be PEM format. -CAkey arg - set the CA key, must be PEM format missing, it is assumed to be in the CA file. -CAcreateserial - create serial number file if it does not exist -CAserial arg - serial file -set_serial - serial number to use -text - print the certificate in text form -C - print out C code forms -md2/-md5/-sha1/-mdc2 - digest to use -extfile - configuration file with X509V3 extensions to add -extensions - section from config file with X509V3 extensions to add -clrext - delete extensions before signing and input certificate -nameopt arg - various certificate name options -engine e - use engine e, possibly a hardware device. -certopt arg - various certificate text options

surrealroad commented 10 years ago

sorry that's my fault. the actual command should be

openssl x509 -in website_aps_production.cer -inform DER -out apns-cert.pem -outform PEM

DohaSoul commented 10 years ago

I created the pem but still didn't get any push notification!

maybe there is something with the DB?! when it's stored the data is saves the id as 1, 2, 3, 4, 5, ..etc and device token is just fine, but the userid is always 0 isn't it suppose to store the id as 4 digit? as it says on the demo here: https://kandutech.net/clicked

another thing.. I tried to play with SimplePush.php file (download link: http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip ) which is provided on this tutorial: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1

and I changed the device token and the payload body to: $body['aps'] = array( 'alert' => array( 'title' => 'test', 'body' => $message ), 'url-args' => array('test'), );

to just test the certificate if its valid or not, the result return with: "Connected to APNS Message successfully delivered" which mean that the cert is valid, but I didn't get any notification.

surrealroad commented 10 years ago

The userid field you can ignore for now, it's something for the next version of the wordpress plugin, nothing to do with the kandutech demo.

As for the simplepush.php script, I honestly I have no idea whether that would work with Safari push. If your server is correctly configured, you should be able to send a push from Terminal with:

curl --data-urlencode "title=Test" --data-urlencode "body=This is a test" --data-urlencode "button=View" --data-urlencode "urlargs=/" --data-urlencode "auth=your authentication code" https://push.yoursite.com/v1/push

or if you know the specific device token to send the push to, replace with https://push.yoursite.com/v1/push/devicetoken/

You can also do this in a browser, like so: https://push.yoursite.com/v1/push/?title=Test&body=This%20is%20a%20test&button=View&urlargs=%2F&auth=your_authentication_code or https://push.yoursite.com/v1/push/devicetoken/?title=Test&body=This%20is%20a%20test&button=View&urlargs=%2F&auth=your_authentication_code

DohaSoul commented 10 years ago

It's worked when I tried it with the Terminal.. so what do you think the problem is?!

surrealroad commented 10 years ago

What are you trying to do that isn't working? Send a push through the Wordpress plugin?

DohaSoul commented 10 years ago

no I'm just trying the demo.. I didn't do any programming thing yet, so I guess everything should be working if it's worked through the Terminal? should I go forward?

surrealroad commented 10 years ago

it's entirely possible the demo code is broken, I'll fix and/or remove it.

surrealroad commented 10 years ago

https://github.com/surrealroad/Safari-Push-Notifications/commit/e8a3be0f6ec6724f32a85b0b98fef81c7b38675e