且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何验证 Apple APN 设备令牌 - WCF .NET

更新时间:2023-12-03 14:50:22

您无法验证设备令牌.在将令牌插入数据库之前,您唯一可以验证的是其长度为 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.