如何验证 Apple APN 设备令牌 - WCF .NET [英] how to validate Apple APN device token - WCF .NET

查看:29
本文介绍了如何验证 Apple APN 设备令牌 - WCF .NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 WCF REST Web 服务,该服务由移动应用程序调用以将 Apple 设备令牌插入到数据库中.我想在插入数据库之前验证设备令牌.无论如何要验证设备令牌以知道它是否有效??

I am building a WCF REST web service that is called by the mobile app to insert the Apple device Token into the database. I would like to validate a device token before inserting into the database. Is there anyway to validate a device token to know if it is valid??

我在论坛上搜索过,但找不到任何示例代码(在 .NET 中)来执行此操作,有人建议我应该使用 Apple FeedBack 服务,但我该如何在 .NET 中执行此操作??

I have searched around the forum and could not find any sample code (in .NET) to do this, there were recommendations that I should use the Apple FeedBack service but how do I do that in .NET??

谁能给我提供一段示例代码来验证 .NET 中的 Apple 设备令牌.

Could anyone please provide me a piece of sample code to validate an Apple Device Token in .NET.

非常感谢,

推荐答案

您无法验证设备令牌.在将令牌插入数据库之前,您唯一可以验证的是其长度为 32 个字节(以二进制表示)或 64 个十六进制字符(以字符串表示).

You can't validate the device token. The only thing you can validate before inserting the token to your DB is that its length is 32 bytes (in binary representation) or 64 Hexadecimal characters (in a String representation).

除此之外,您应该检查 Apple 的响应,看看是否收到 InvalidToken 错误响应.如果这样做,您就知道与导致错误的消息一起发送的设备令牌无效.

Beyond that, you should check the responses from Apple to see if you get an InvalidToken error response. If you do, you know the device token sent with the message that causes the error is invalid.

反馈服务不会返回无效令牌.它返回卸载了您的应用的设备的有效令牌.

The Feedback Service does not return invalid tokens. It returns valid tokens of devices that uninstalled your app.

我不能给你任何 C# 代码,但 PushSharp 应该支持调用反馈服务并读取来自 Apple 的错误响应.

I can't give you any C# code, but PushSharp should support calling the Feedback Service and reading error responses from Apple.

这篇关于如何验证 Apple APN 设备令牌 - WCF .NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆