【问题标题】:IPA file not fetching device token in iOSIPA 文件未在 iOS 中获取设备令牌
【发布时间】:2013-02-28 12:27:31
【问题描述】:

我创建了启用推送通知的配置文件。在设备中安装 IPA 文件后,应用程序未获取设备令牌。有谁知道为什么我的应用会出现这个问题?

【问题讨论】:

  • 你到底想做什么?您需要在代码中添加一些内容以获取设备令牌。

标签: ios xcode devicetoken


【解决方案1】:

在您的应用委托的 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.
   }

【讨论】:

    猜你喜欢
    • 2014-08-17
    • 1970-01-01
    • 2015-12-02
    • 1970-01-01
    • 1970-01-01
    • 2020-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多