APN.C :从误差响应中提取标识符

APNS. C++: extract Identifier from error responce

本文关键字:提取 标识符 响应 误差 APN      更新时间:2023-10-16

我有一个C 应用程序,该应用程序发送Apple Push Notifications

它使用增强的通知格式https://developer.com/library/ios/documentation/networkinginternet/conceptual/remotenotificationpg/chapterpg/chapterspg/chapters/legacyformat.htmll#/plefformat.htmll#//p>

有时我会收到错误,并想正确解析

这是错误响应格式的解释:https://deverveer..apple.com/library/ios/documentation/networkinginternet/conepperual/coneptual/remotenotificationationpg/chapters/communicatingwithaps.html#//communicatingwithaps.html#//apple/apple_re_reff/doc/redoc/doc/uid/uid/uid/tp40008194-194-194-ch101-s101-sw4

我们有1个字节命令,1个字节状态和4个字节标识符。我的标识符提取

有问题

这是我的代码如何提取命令和状态

 char data[6];
 ...
 int Command = data[0];
 int Status = data[1];
 int Identifier = ...;

请帮助我使用标识符

如果您的问题是在四个字节中进行整数,则可以使用:

来完成。
char data[6];
...
int Command = data[0];
int Status = data[1];
int Identifier = (data[2] << 24) 
               | (data[3] << 16) 
               | (data[4] << 8) 
               | data[5];

这将标识符视为大型居民,但是由于文档说ID是不透明的,因此您应该可以,如果您在整个应用程序中都将ID视为大型endian。

该文档还提到了字节,而不是字符,因此您的变量也许都应该被签名?