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

查看:99
本文介绍了如何验证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个十六进制字符(以String表示).

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天全站免登陆