【发布时间】:2012-08-13 09:42:33
【问题描述】:
我已经尝试了很多教程来为我的应用程序发送推送通知服务。当我在设备上测试它时它可以工作。但是如果我在我的应用程序在 App Store 上启动后对其进行实时测试,并且我通过从商店下载将它安装在我的设备上,我运行 php 文件以发送推送通知,我没有收到它。这是代码我用于推送通知和我从中学到的tutorial。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
有没有什么教程可以教我实时使用它。我将我的 php 文件的环境从沙箱更改为实时。请指导。
【问题讨论】:
-
您是否为生产服务器使用了正确的 ssl 证书?您不能使用沙盒证书连接到生产服务器。
-
是的,我为生产服务器使用了正确的 ssl 证书..
-
@Sascha:我的编码正确吗?
-
您是否在应用程序中将 deviceToken 发送到您的服务器:application didRegisterForRemoteNotificationsWithDeviceToken:
标签: iphone ios xcode push-notification apple-push-notifications