【问题标题】:Push Notifications warning?推送通知警告?
【发布时间】:2011-02-14 11:45:18
【问题描述】:

我正在我的应用程序中处理推送通知。但我收到了这个警告: 分配'struct NSString *'的不兼容Objective-C类型,预期'struct NSData *'

收到警告的代码是:

  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Here you send the deviceToken to your server.. 
deviceToken = [[[[deviceToken description]
                 stringByReplacingOccurrencesOfString: @"<" withString: @""]
                stringByReplacingOccurrencesOfString: @">" withString: @""]
               stringByReplacingOccurrencesOfString: @" " withString: @""];

NSLog(@"Device Token: %@",deviceToken);
}

谁能告诉我为什么我会收到这个警告。

谢谢

【问题讨论】:

    标签: iphone objective-c push-notification ios-4.2 apple-push-notifications


    【解决方案1】:

    为什么不创建一个单独的名为 deviceTokenStr 的 NSString,因为 deviceToken 本身是一个 NSData 对象,它会导致错误

        NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString:      @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];
    
        NSLog(@"Device Token: %@",deviceTokenStr);
    

    【讨论】:

      猜你喜欢
      • 2015-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 2022-07-16
      • 2015-11-25
      相关资源
      最近更新 更多