Iphone 设备未接收推送通知
我已经创建了一个iPhone应用程序。我正在获取设备令牌。但我无法收到来自APNS的通知。这里我给出了PHP中服务器的示例代码 我从下面的url获得了代码(PHP): APNS.php 目标C: 请帮我解决这个问题 谢谢。我解决了这个问题Iphone 设备未接收推送通知,iphone,apple-push-notifications,Iphone,Apple Push Notifications,我已经创建了一个iPhone应用程序。我正在获取设备令牌。但我无法收到来自APNS的通知。这里我给出了PHP中服务器的示例代码 我从下面的url获得了代码(PHP): APNS.php 目标C: 请帮我解决这个问题 谢谢。我解决了这个问题 我已为我的应用程序创建了authentications.plist。现在它工作正常。当我运行服务器时,我看到下面的消息。我认为它工作得很好。“2010年10月11日星期一18:59:38+0530 APNSHPP[7616]:信息:发送消息队列,运行队列中剩
我已为我的应用程序创建了authentications.plist。现在它工作正常。当我运行服务器时,我看到下面的消息。我认为它工作得很好。“2010年10月11日星期一18:59:38+0530 APNSHPP[7616]:信息:发送消息队列,运行队列中剩余的#1:1消息。2010年10月11日星期一18:59:38+0530 APNSHPP[7616]:状态:发送消息ID 1[自定义标识符:message-Badge-5]:151字节。”从服务器向APNS发送通知。但iPhone应用程序并没有收到该通知。请任何人帮我解决这个问题。
date_default_timezone_set('Asia/Calcutta');
require_once 'ApnsPHP/Autoload.php';
$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
'ApnsPHP/apple_push_notification_production.pem'
);
$push->setRootCertificationAuthority('ApnsPHP/entrust_root_certification_authority.pem');
$push->connect();
$message = new ApnsPHP_Message('****');
$message->setCustomIdentifier("Message-Badge-5");
$message->setText('Hello APNs-enabled device!');
$message->setBadge(5);
$message->setSound('default');
$message->setCustomProperty('acme2', array('bang', 'whiz'));
$message->setExpiry(30);
$push->add($message);
$push->send();
$push->disconnect();
$aErrorQueue = $push->getErrors();
if (!empty($aErrorQueue)) {
var_dump($aErrorQueue);
}
-(void) applicationDidFinishLaunching:(UIApplication *)application{
NSLog(@"Initiating push notification.");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
}
-(void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
NSLog(@"Device Token : %@", deviceToken);
self.currentDeviceToken = [[[deviceToken description]
stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@""]]
stringByReplacingOccurrencesOfString:@" " withString:@""];;
NSLog(@"Device Token : %@", self.currentDeviceToken);
NSLog(@"Remote type : %d", [[UIApplication sharedApplication] enabledRemoteNotificationTypes]);
}
-(void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
NSLog(@"Error in registration : %@", error);
self.currentDeviceToken = @"no device token";
}
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
NSLog(@"Received Notification");
NSLog(@"remote notification: %@",[userInfo description]);
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);
NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
NSString *badge = [apsInfo objectForKey:@"badge"];
NSLog(@"Received Push Badge: %@", badge);
application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
}