我按照步骤
创建了.pem文件当我在浏览器中使用url时显示; { “APS”:{ “警报”: “喜”, “标记” 是:1, “声音”: “beep.wav”}}
我正在使用此代码在iphone应用程序中接收通知
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
NSLog(@"\n\n\n\nRegistering for push notifications...\n\n\n\n");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
NSString *token = [[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"\n\n\n\n\n device token===%@\n\n\n\n",token);
//DeviceRegisterer *registrar = [[DeviceRegisterer alloc] init];
//[registrar registerDeviceWithToken:token];
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"failed to regiser %@", err);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"notification options %@", userInfo);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Super" message:@"welcome" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
myTextField.text = [userInfo objectForKey:key];
[myAlertView addSubview:myTextField];
[myAlertView show];
[myAlertView release];
}
}
但我无法收到通知消息。 请帮助解决此问题。
提前致谢, Senthilkumar
答案 0 :(得分:0)
您没有使用服务器发送邮件。 pem键旨在由服务器用于发送消息。我认为您不能使用您的iPhone应用程序直接发送推送消息。 如果您的服务器使用php尝试在此站点中找到传递通知的代码。 注意:在我的服务器上,ApnsPHP代码根本不起作用,我使用了stackOverflow中的一个简单的php脚本(抱歉不记得链接)来管理它并且有效。
答案 1 :(得分:0)
我解决了这个问题。 php .pem文件中的问题。谢谢你的想法。