PushMeBaby source code:
http://stefan.hafeneger.name/download/PushMeBabySource.zip
后面是app delegate class 代码实现可以参考Urban Airship:
http://bitbucket.org/urbanairship/push_sample/src/tip/APNS/Classes/APNSAppDelegate.m#cl-136
服务器实现:
<?php
$deviceToken = $_GET['deviceToken'];
echo $_GET['deviceToken'];
// Passphrase for the private key (ck.pem file)
// $pass = '';
// Get the parameters from http get or from command line
$message = $_GET['message'] or $message = $argv[1] or $message = 'You got a message';
$badge = (int)$_GET['badge'] or $badge = (int)$argv[2];
$sound = $_GET['sound'] or $sound = $argv[3];
// Construct the notification payload
$body = array();
$body['aps'] = array('alert' => $message);
if ($badge)
$body['aps']['badge'] = $badge;
if ($sound)
$body['aps']['sound'] = $sound;
/* End of Configurable Items */
$ctx = stream_context_create();
/*stream_context_set_option($ctx, 'ssl','allow_self_signed', true);
stream_context_set_option($ctx, 'ssl', 'verify_peer',false);*/
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
// assume the private key passphase was removed.
// stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstr/n";
return;
}
else {
print "Connection OK/n";
}
$payload = json_encode($body);
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "/n";
fwrite($fp, $msg);
fclose($fp);
?>
其他相关文档:
iPhone Software Development: Apple Push Notification Service (APNS)
iPhone Software Development: APNS Client Development Certificate Available Now
OpenSSL support in PHP under MAMP | Barry Jaspan
Running a secure web server on your Leopard-powered Mac | Michael Gracie
分享到:
相关推荐
wpf实现iphone滑动效果demo,效果很尿性
iPhone实现push功能的参考源码,pushMe作为服务器端,pushTest作为客户端。
一个iPhone4游戏Demo和源码,非常适合初、中级学者。
一个简单的iphone checkbox demo
a simple iphone app.....adress book ,sqlite,table,navigation......
蓝牙4.0 iphone4s demo,可用于cc2540的板子。
如题所示 : iphone平台下各种AlertView实现,经典DEMO,不多说了
iphone 百度定位Demo
刚开始接触iphone开发不久,很多控件不会写,收集的各类常用控件的Demo,方便新手同学们查阅,学习.
关于iphone中push notification得实现参考文档
iphone 通讯录 demo
iPhone iOS Push Test.
Provider是指某个iPhone软件的Push服务器。 APNS 是Apple Push Notification Service(Apple Push服务器)的缩写,下文统一使用该缩写。 因 此,整个过程可以分为三个阶段,下面用大家常用的聊天客户端BeejiveIM来...
delphi Iphone demo delphi Iphone demo delphi Iphone demo
这是一个完整的iphone推送机制的.net平台实现
AR_IPhone IPhone上实现增强现实的demo
这个是自己写的一个基于cocos2d的一个iPhone游戏demo 里面除了用到cocos2d框架之外 还用到了蚁群算法
那个 iphone push notifacation 的介绍的源码文件 其中包括克服段的pushClient 和provider的 pushBabyMe
android实现仿iphone滑动解锁demo 再凑几个字
DIV+CSS实现iPhone效果图