【发布时间】:2013-02-28 12:27:31
【问题描述】:
我创建了启用推送通知的配置文件。在设备中安装 IPA 文件后,应用程序未获取设备令牌。有谁知道为什么我的应用会出现这个问题?
【问题讨论】:
-
你到底想做什么?您需要在代码中添加一些内容以获取设备令牌。
标签: ios xcode devicetoken
我创建了启用推送通知的配置文件。在设备中安装 IPA 文件后,应用程序未获取设备令牌。有谁知道为什么我的应用会出现这个问题?
【问题讨论】:
标签: ios xcode devicetoken
在您的应用委托的 didFinishLaunchingWithOptions 中添加以下行
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert];
然后实现委托功能 作为
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSString *str = [[NSString stringWithFormat:@"%@",deviceToken] stringByReplacingOccurrencesOfString:@"<" withString:@""];
str=[str stringByReplacingOccurrencesOfString:@">" withString:@""];
str=[str stringByReplacingOccurrencesOfString:@" " withString:@""];
//str is your device token and can used now.
}
【讨论】: