APNs工具App推荐,适合APNs开发使用

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zhaowei_yingzi/article/details/82700448

APNs工具App推荐,适合APNs开发使用

最近在调试APNs功能时,通过服务器下发消息太慢了,也很麻烦,之前都是自己从网上找APNs服务器代码,用过Java版、C#、Node.js、Python等等,过一段时间会出现项目运行不起来,可能是环境被破坏了,或者就是项目被我清理删除了,每次想项目时都可能要从网上找代码。例如Java版,作为一个iOS开发,每次都要配置很长时间,还经常报错不知道怎么修复,就不能像iOS开发一样,下载一个Xcode就可以了么?

吐槽也吐槽够了,下面我来介绍一下这块App:APNs工具,可以直接在AppStore上搜索到,下载到手机上就可以使用:

APNs工具


启动App,第一次启动,界面上证书都没有配置:


这时,我们需要配置证书,这个App只支持p12推送证书,先导出p12证书,然后打开iTunes(Mac电脑好像直接就有,PC的话需要下载),打开 文件共享>APNs功能,将p12推送证书拖到页面中,这样就导入成功了,参考下图:

导入证书方式


进入App,点击“选择证书”区域,选择刚才导入的证书,添加密码、DeviceToken,选择环境和Voip推送开关,推送内容可以先不填,App默认就有,所有东西添加好如下图:

这里写图片描述


点击“发送APNs推送”,如果App是第一次安装,可能会因为没有网络权限,导致失败,在弹出来的网络权限弹框中点击“允许”,再次点击发送就可以了。

正确的code是200,其他都是错误了,下面是苹果提供的一下错误码:

HTTP status codes

Status code Description
200 Success.
400 Bad request.
403 There was an error with the certificate or with the provider’s authentication token.
405 The request used an invalid :method value. Only POST requests are supported.
410 The device token is no longer active for the topic.
413 The notification payload was too large.
429 The server received too many requests for the same device token.
500 Internal server error.
503 The server is shutting down and unavailable.



Response error strings

Status code Error string Description
400 BadCollapseId The collapse identifier exceeds the maximum allowed size.
400 BadDeviceToken The specified device token is invalid. Verify that the request contains a valid token and that the token matches the environment.
400 BadExpirationDate The apns-expiration value is invalid.
400 BadMessageId The apns-id value is invalid.
400 BadPriority The apns-priority value is invalid.
400 BadTopic The apns-topic is invalid.
400 DeviceTokenNotForTopic The device token doesn’t match the specified topic.
400 DuplicateHeaders One or more headers are repeated.
400 IdleTimeout Idle time out.
400 MissingDeviceToken The device token isn’t specified in the request :path. Verify that the :path header contains the device token.
400 MissingTopic The apns-topic header of the request isn’t specified and is required. The apns-topic header is mandatory when the client is connected using a certificate that supports multiple topics.
400 PayloadEmpty The message payload is empty.
400 TopicDisallowed Pushing to this topic is not allowed.
403 BadCertificate The certificate is invalid.
403 BadCertificateEnvironment The client certificate is for the wrong environment.
403 ExpiredProviderToken The provider token is stale and a new token should be generated.
403 Forbidden The specified action is not allowed.
403 InvalidProviderToken The provider token is not valid, or the token signature cannot be verified.
403 MissingProviderToken No provider certificate was used to connect to APNs, and the authorization header is missing or no provider token is specified.
404 BadPath The request contained an invalid :path value.
405 MethodNotAllowed The specified :method isn’t POST.
410 Unregistered The device token is inactive for the specified topic.
413 PayloadTooLarge The message payload is too large. For information about the allowed payload size, see Create and Send a POST Request to APNs.
429 TooManyProviderTokenUpdates The provider’s authentication token is being updated too often. Update the authentication token no more than once every 20 minutes.
429 TooManyRequests Too many requests were made consecutively to the same device token.
500 InternalServerError An internal server error occurred.
503 ServiceUnavailable The service is unavailable.
503 Shutdown The APNs server is shutting down.



详细APNs资料可以苹果查看:
Sending Notification Requests to APNs

展开阅读全文

没有更多推荐了,返回首页