APNS 令牌与 NSString 比较

发布于 2024-10-07 22:14:39 字数 342 浏览 0 评论 0原文

我有两个 APNS(Apple Push)令牌可供比较。

一件来自苹果公司。每次我启动应用程序时,它都会从 Apple 接收令牌(作为 NSData *)。

另一个来自我应用程序的 SQLite3 数据库。当我的应用程序第一次从 Apple 收到令牌时,它使用将令牌作为 TEXT 的 INSERT 记录在其 SQLite3 数据库中。

然后我尝试比较这两个令牌。是的,它们应该是相同的,每次我使用 NSLog 在控制台上输出它们时,它们看起来确实是一样的。

但每次我使用 isEqual: 或 isEqualToString: 进行比较时,我都得到 NO。我很困惑。

任何人都可以帮忙吗?

I got two APNS (Apple Push) tokens to compare.

One is from Apple. Every time I launch the app it receives the token (as a NSData *) from Apple.

The other is from my app's SQLite3 database. When the first time my app received the token from Apple, it recorded the token in its SQLite3 database with an INSERT with the token as TEXT.

I then tried to compare these two tokens. Yes they are meant to be the same, and every time I use NSLog to output them on Console, they did look the same.

But every time I use isEqual: or isEqualToString: to compare, I got NO. I'm confused.

Any one can help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆伤 2024-10-14 22:14:39

我遇到了同样的问题并找到了一个简单的解决方案。要将令牌 (NSData *) 转换为字符串 (NSString *),只需使用 description

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token {
    NSStrinng *strToken = [token description];
...
}

I had the same problem and found an easy solution. To convert the token (NSData *) into a string (NSString *), simply use description:

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token {
    NSStrinng *strToken = [token description];
...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文