为什么我的iPod touch 4无法注册APNS?

时间:2012-08-31 06:19:14

标签: ios ios5 apple-push-notifications ipod-touch

我正在尝试在iPod touch 4上测试我的应用,但我需要APNS支持。

我发现APNS的代理回调都没有被调用。

我搜索了Technical Note,但它没有帮助(因为相同的代码适用于我的iPad2,会返回设备令牌)。

对此有什么想法吗?

我正在使用iOS 5.1.1的iPod touch 4

编辑:

啊,这里提供的更多信息。 我之前创建了配置文件以及所有这些证书。这就是为什么我可以用iPad来解决这个问题。

然后今天,我刚刚添加了我的iPod touch 4作为开发设备并再次下载了配置文件。这是不会注册我的iPod touch 4以便能够处理APNS工作????

编辑2:

根据要求:

其实我只是在做Apple要求我做的事情, 我包括

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    NSDictionary *)launchOptions
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge)];
    //Other codes...
}

然后,两个代表回调方法

#pragma mark - For Apple Push Notification Service

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{ 
    NSString *str = [NSString 
                 stringWithFormat:@"%@",deviceToken];
    NSString *devToken = [[[[str description] 
                           stringByReplacingOccurrencesOfString:@"<"withString:@""] 
                          stringByReplacingOccurrencesOfString:@">" withString:@""] 
                         stringByReplacingOccurrencesOfString: @" " withString: @""];
   NSLog(@"%@", devToken);
   NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
    if (standardUserDefaults)
    {
        [standardUserDefaults setObject:devToken forKey:@"device_token"];
        [standardUserDefaults synchronize];
    }
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error);
}

实际上,我只是复制并粘贴Apple提供的内容。 然而,就像上面提到的那样,对于带有iOS 5.0.1的iPad2,带有iOS 4.3的iPhone,而不是带有iOS5.1.1的iPod Touch 4,都不需要这种方法。

0 个答案:

没有答案