Category Archives: apple-push-notifications

SSL: Can’t load the certificate on the new Apple APNs on PHP

I'm on wits end. I had no problem sending an APNS to my phone via terminal with:

curl -d '{"aps":{"alert":"Hello world!","sound":"default"}}' --cert "PushCertificates.pem":"" -H "apns-topic: com.example" --http2  https://api.push.apple.com/3/device/0b2d30ecf71b4fd55871e2f18778eb8fb2e7695a76dc65213e9fe264aa4f984a

But i'm encountering issues with my php where the errow:

SSL: Can't load the certificate "/Users/Desmond/Sites/WS/PushCertificates.pem" and its private key: OSStatus -61

I'm running the standard mac 10.11 apache and php server.

Run APNs from localhost

I'm new to use apns and i spend two days for reading docs related to it. I can run my code from terminal by typing

php simplepush.php

in above part after typing that command i should enter my pass phrase and after enter pass push will be send.

But from localhost means run above code from address bar shows

Failed to connect: 0 

i'm really confused and l donot know what's else i should do!!

i think there is problem with that pass phrase or something need to do with apache!!of course maybe!!!

Do my a favor if somebody know what i should do!!

Best Regard

How to set up a web service for a post request in php [duplicate]

I am setting up Safari push notifications and they send a response to a endpoint that they choose.

I need to set up a web service backend to account for this.

They POST a token to:

/v1/devices/<deviceToken>/registrations/<websitePushId>

How do I set up my backend, using rewrites, or something... to capture the deviceToken and websitePushId?

I have a php script to add this info to a database. I just don't know how to get the POST info, and those two parameters into that script.

Any ideas?

Using the .htaccess file to redirect safari push notification URL to a specific endpoint

I am trying to get push notifications working on safari and they POST to a endpoint on your server. (which you don't have a choice of)

/v1/pushPackages/<websitePushId>

<websitePushId> = web.com.websitename

With some data in the body of the POST

{"user_id":"323", ...}

When this endpoint is hit, I need to return a zip file of the package they want.

What I want to do, is hit a file that does all that logic and returns the package.zip

My end point is:

https://websitename.com/API/SafariNotifications/web.com.websitename/v1/pushPackages/createPushPackage.php

My .htaccess file looks like this:

RewriteEngine On

RewriteRule ^/v1/pushPackages/(.*)$  /API/SafariNotifications/$1/v1/pushPackages/createPushPackage.php

# remove www from host
RewriteCond %{HTTP_HOST} ^www\.(.+)
RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]

# This redirects the 404 page to a custom 404 page.
errordocument 404 /404.php

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
# This makes all the pages hit the index page
# This lets the database to run the site.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]

I am using MAMP and testing it in postman. But every time I go to the /v1/pushPackages/ URL, it just sends me to my index page.

How can I make it hit my end point?

Thanks

How to send apple push notifications securely?

Currently I have an PHP script which sends push notifications to my app. Nothing unusual and it works great.

My problem is with the .pem file. It is currently just a few folders higher (at least not in the www/html folder ! ), but it just do not feel right, the PHP from the html folder can access the .pem file without any problem.

I do not think this is the best approach to use the .pem file in a secure way. Are there other ways to use the .pem file. Like placing it in another folder or access it with some kind of password (yes little strange with an private key ;) ) ?

In general: what is the best (most secure!) way to access an .pem file from an web connected PHP file?

How can I make APNS work for Iseries?

My company would like me to implement push notifications for an app that is in development. These notifications would be based off of events occurring on our Iseries (AS/400 ).

I have utilized IBM Web Administration for I to create a HTTP Server and have used Digital Certificate Manager to attach APNS certificates to said server.

I am also storing device tokens in a database on our AS400.

I am now having a hard time figuring out how to go about creating this 'persistent connection' to APNS with the server I created. I have little to no knowledge of server side programming and any help or direction would be GREATLY appreciated.

Thanks!

Unable to send iPhone push notifications Windows 8

I have successfully sent iPhone push notifications from a Windows 7 machine. But the client machine which is running Windows 8 is not able to send push notifications. I have copied Apache error log. The port is used by System. So Apache uses 8080 and 443.

[Wed Aug 06 17:12:40.356484 2014] [ssl:warn] [pid 1424:tid 392] AH01909:      
www.example.com:443:0 server certificate does NOT include an ID which matches the server name

[Wed Aug 06 17:22:29.196742 2014] [mpm_winnt:warn] [pid 1424:tid 1988] (OS 995)
The I/O operation has been aborted because of either a thread exit or an application request.  : AH00341: winnt_accept: Asynchronous AcceptEx failed.

[Wed Aug 06 17:23:54.493543 2014] [core:warn] [pid 3844:tid 384] AH00098: pid file  
C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Aug 06 17:23:54.658420 2014] [ssl:warn] [pid 3844:tid 384] AH01909:   
www.example.com:443:0 server certificate does NOT include an ID which matches the 
server name

[Wed Aug 06 17:23:54.688440 2014] [mpm_winnt:notice] [pid 3844:tid 384] AH00455: 
Apache/2.4.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11 configured -- resuming normal operations
[Wed Aug 06 17:23:54.688440 2014] [mpm_winnt:notice] [pid 3844:tid 384] AH00456:  
Apache Lounge VC11 Server built: Mar 16 2014 12:13:13

[Wed Aug 06 17:23:54.688440 2014] [core:notice] [pid 3844:tid 384] AH00094: Command  
line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Wed Aug 06 17:23:54.690441 2014] [mpm_winnt:notice] [pid 3844:tid 384] AH00418:  
Parent: Created child process 5708

[Wed Aug 06 17:23:55.098499 2014] [ssl:warn] [pid 5708:tid 392] AH01909:  
www.example.com:443:0 server certificate does NOT include an ID which matches the 
server name

[Wed Aug 06 17:23:55.264953 2014] [ssl:warn] [pid 5708:tid 392] AH01909:  
www.example.com:443:0 server certificate does NOT include an ID which matches the 
server name

Can this log provide a clue for my problem? Thanks in advance.