我创建了启用推送通知的配置文件。在设备中安装 IPA 文件后,应用程序未获取设备令牌。有谁知道为什么这个问题出现在我的应用程序中?
问问题
186 次
1 回答
0
在您的应用委托的 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.
}
于 2013-02-28T13:23:05.860 回答