我正在构建一个 WCF REST Web 服务,该服务由移动应用程序调用以将 Apple 设备令牌插入数据库。我想在插入数据库之前验证设备令牌。无论如何要验证设备令牌以知道它是否有效?
我在论坛上进行了搜索,但找不到任何示例代码(在 .NET 中)来执行此操作,有人建议我应该使用 Apple 反馈服务,但我如何在 .NET 中执行此操作?
谁能给我一段示例代码来验证 .NET 中的 Apple 设备令牌。
非常感谢,
我正在构建一个 WCF REST Web 服务,该服务由移动应用程序调用以将 Apple 设备令牌插入数据库。我想在插入数据库之前验证设备令牌。无论如何要验证设备令牌以知道它是否有效?
我在论坛上进行了搜索,但找不到任何示例代码(在 .NET 中)来执行此操作,有人建议我应该使用 Apple 反馈服务,但我如何在 .NET 中执行此操作?
谁能给我一段示例代码来验证 .NET 中的 Apple 设备令牌。
非常感谢,
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).
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.
I can't give you any C# code, but PushSharp should support calling the Feedback Service and reading error responses from Apple.
这是一个无关紧要的答案,但最近我遇到了这个问题,
因为我的问题是我有很长的通知令牌列表,其中一些是无效的。
所以我需要过滤它们,但没有简单的方法,但我有 1 个用于发送/测试通知证书的应用程序,
Knuff:https://github.com/KnuffApp/Knuff/releases
这样任何人都可以验证推送通知令牌。
希望它能帮助像我这样的用户。