http://www.cocoachina.com/bbs/read.php?tid-30410.html 得出从零开始的php版push服务器搭建流程: ============================================================== 0.在Mac OS X机器上安装好XCode, 连接一台正常的iPhone, 保持平和的心态 APP 开发基础设
http://www.cocoachina.com/bbs/read.php?tid-30410.html
得出从零开始的php版push服务器搭建流程:
==============================================================
0.在Mac OS X机器上安装好XCode, 连接一台正常的iPhone, 保持平和的心态
APP 开发基础设置
1.在iPhone Provisioning Portal中建立好APP ID和Device.
2.在Keychain Access.app中生成证书请求CertificateSigningRequest.certSigningRequest(菜单 > Keychain Access > Certificate Assistant
> Request a Certificate From a Certificate Authority...).
3.在iPhone Provisioning Portal > Certificates中请求一个证书(点击Request Certificate,上传CertificateSigningRequest.certSigningRequest).
4.请求完成后,将证书文件(developer_identity.cer)下载,双击导入到Key Chain中.
5.在iPhone Provisioning Portal > Provisioning 中,新建一个Profile, 选择指定的APP ID和 Devices后生成.
6.将刚刚生成的Profile下载为*_profile.mobileprovision, 双击该文件, 将profile加载到iPhone中.
Push Notification service设置
7.在iPhone Provisioning Portal > App IDs,选择需要Push服务的App ID, 进入Configure.
8.确认 Enable for Apple Push Notification service ,配置 Development Push SSL Certificate, 上传第2步生成的证书请求.
9.下载生成的aps_developer_identity.cer, 完成Push服务配置.
10.双击aps_developer_identity.cer,保存到Key Chain.
生成php Push Notification sender需要的证书文件
11.在Keychain Access.app里选定这个新证书(Apple Development Push Services*),导出到桌面,保存为Certificates.p12.
12.运行如下命令:
openssl pkcs12 -clcerts -nokeys -out cert.pem -in Certificates.p12 openssl pkcs12 -nocerts -out key.pem -in Certificates.p12 openssl rsa -in key.pem -out key.unencrypted.pem cat cert.pem key.unencrypted.pem > ck.pem
获得php Push Notification sender所需的设备令牌:
13.新建一个View-based Application项目,在$PROJECT_NAMEAppDelegate.m中:
a.粘贴如下代码:
- (void)applicationDidFinishLaunching:(UIApplication *)app { // other setup tasks here…. [window addSubview:viewController.view]; [self alertNotice:@"" withMSG:@"Initiating Remote Noticationss Are Active" cancleButtonTitle:@"Ok" otherButtonTitle:@""]; [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)]; } - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { //NSLog(@"devToken=%@",deviceToken); [self alertNotice:@"" withMSG:[NSString stringWithFormat:@"devToken=%@",deviceToken] cancleButtonTitle:@"Ok" otherButtonTitle:@""]; } - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { NSLog(@"Error in registration. Error: %@", err); [self alertNotice:@"" withMSG:[NSString stringWithFormat:@"Error in registration. Error: %@", err] cancleButtonTitle:@"Ok" otherButtonTitle:@""]; } -(void)alertNotice:(NSString *)title withMSG:(NSString *)msg cancleButtonTitle:(NSString *)cancleTitle otherButtonTitle:(NSString *)otherTitle{ UIAlertView *alert; if([otherTitle isEqualToString:@""]) alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:cancleTitle otherButtonTitles:nil,nil]; else alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:cancleTitle otherButtonTitles:otherTitle,nil]; [alert show]; [alert release]; }
b.在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 方法中增加
[self alertNotice:@"" withMSG:@"Initiating Remote Noticationss Are Active" cancleButtonTitle:@"Ok" otherButtonTitle:@""]; [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];
14.项目设置
a.Targets > $APP_NAME > context menu > Properties > Identifier
修改 identifier 为App ID
b.Targets > $APP_NAME > context menu > Build > Code Signing > Code Signing Identifier > Any iPhone OS Device
指定 iPhone Developer 为开发用机
15.编译并运行后会在iPhone上显示设备令牌
16.php Push Notification sender代码如下:
<?php $deviceToken = "设备令牌"; $body = array("aps" => array("alert" => 'message', "badge" => 1, "sound" => 'received5.caf')); $ctx = stream_context_create(); stream_context_set_option($ctx, "ssl", "local_cert", "ck.pem"); $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 $errstrn"; return; } print "Connection OK\n"; $payload = json_encode($body); $msg = chr(0) . pack("n",32) . pack("H*", $deviceToken) . pack("n",strlen($payload)) . $payload; print "sending message :" . $payload . "\n"; fwrite($fp, $msg); fclose($fp); ?>

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

SecList
SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.
