0

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

我发现没有调用 APNS 的委托回调。

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

对此有任何想法吗?

我正在使用带有 iOS 5.1.1 的 iPod touch 4

编辑:

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

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

编辑2:

按照要求:

实际上,我只是做苹果要求我做的任何事情,包括我在内

- (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 则没有。

4

0 回答 0