IPA文件未在iOS中获取设备令牌

时间:2013-02-28 12:27:32

标签: ios xcode devicetoken

我已创建启用推送通知的配置文件。在设备中安装IPA文件后,应用程序无法获取设备令牌。有谁知道我的应用程序中出现此问题的原因?

1 个答案:

答案 0 :(得分:0)

在你的app delegate的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.
   }