Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 04-30-2010, 02:40 AM   #1 (permalink)
Raj
 
Join Date: Jan 2010
Location: Chandigarh
Age: 25
Posts: 14
rajender_sharma is on a distinguished road
Send a message via Skype™ to rajender_sharma
Default APNS provider error connection timed out failed to connect 111

When I try to send Push Notifications I get this error: "Connection refused", but I don't know why... I've uploaded my apns-dev.pem in the same directory as well in the root-directory but that won't work either.

<?php
$payload['aps'] = array('alert' => 'This is the alert text', 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev.pem';
$apnsPass = 'secret';

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($streamContext, 'ssl', 'passphrase', $apnsPass);

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);

if (!$apns) {
echo "Error: $errorString ($error)";
}

// Do this for each
$deviceToken = '00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000';
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
fwrite($apns, $apnsMessage);
// End do

socket_close($apns);
fclose($apns);
?>


Does anyone know what I'm doing wrong? When I remove the passphrase and don't send it it doesn't work either...

Last edited by rajender_sharma; 05-04-2010 at 01:30 AM.
rajender_sharma is offline   Reply With Quote
Old 05-28-2010, 10:58 AM   #2 (permalink)
Registered Member
 
azdev's Avatar
 
Join Date: Oct 2009
Posts: 104
azdev is on a distinguished road
Default

I would check out Urban Airship (Urban Airship - Easy-to-use push notification and In App Purchase services for iPhone applications) if you want a relatively easy APNS solution and you're planning on sending fewer than 250,000 push notifications a month. After 250,000 they start microcharging you. They provide sample PHP code as well.

I started down the road you're on and had similar headaches before switching over to Urban Airship.
__________________
My apps
Wordmaster
Wordmaster Free
LOLCreator
loltranslate
azdev is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 357
5 members and 352 guests
.Snipe, baja_yu, guusleijsten, NSString, Paul Slocum
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,645
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, leighec68
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:29 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0