关于APNs payLoad的一些细节问题

根据开发者文档,细节1:

Each push notification includes a payload. The payload contains information about how the system should alert the user as well as any custom data you provide. The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit.

注:

payload 最大为256字节。

细节2:

If the target application isn’t running when the notification arrives, the alert message, sound, or badge value is played or shown. If the application is running, the system delivers the notification to the application delegate as an NSDictionary object. The dictionary contains the corresponding Cocoa property-list objects (plus NSNull).

如果app没有运行,就会弹出alert消息,声音和标记。如果在运行则会调用这个方法

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{}进行处理。


总的来说,使用APNs需要注意:

1  Note: Avoid using more than one action per notification. Notifications by their nature interrupt the user, and each action adds additional interruption. Apps that overuse notification actions risk annoying their users.


尽量避免发送多个消息推送,这会引起用户抱怨,从而可能删除你的应用(用户体验不好)。

关于更多细则,参考:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用[1],TNetHttpClient是Delphi中的一个HTTP客户端组件,而APNS是Apple Push Notification Service的缩写,是苹果公司提供的推送服务。因此,TNetHttpClient APNS是使用Delphi中的TNetHttpClient组件来与APNS进行通信。 使用TNetHttpClient APNS的步骤如下: 1.创建TNetHttpClient对象,并设置请求的URL和请求方法为POST。 2.设置请求头部信息,包括Content-Type、Authorization和apns-topic等信息。 3.设置请求体信息,包括设备的token、推送的payload等信息。 4.发送请求并获取响应结果。 以下是一个使用TNetHttpClient APNS发送推送通知的示例代码: ```delphi uses System.Net.HttpClient, System.Net.HttpClientComponent; procedure SendAPNSNotification; var HttpClient: TNetHttpClient; Request: TNetHTTPRequest; Response: IHTTPResponse; APNSUrl: string; APNSPayload: string; APNSToken: string; APNSAuth: string; APNSTopic: string; begin HttpClient := TNetHttpClient.Create(nil); Request := TNetHTTPRequest.Create(nil); try APNSUrl := 'https://api.push.apple.com/3/device/'; APNSPayload := '{"aps":{"alert":"Hello World!"}}'; APNSToken := 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; APNSAuth := 'Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; APNSTopic := 'com.example.app'; Request.MethodString := 'POST'; Request.URL := APNSUrl + APNSToken; Request.ContentType := 'application/json'; Request.CustomHeaders['Authorization'] := APNSAuth; Request.CustomHeaders['apns-topic'] := APNSTopic; Request.Source := TStringStream.Create(APNSPayload, TEncoding.UTF8); Response := HttpClient.Execute(Request); if Response.StatusCode = 200 then ShowMessage('Push notification sent successfully.') else ShowMessage('Failed to send push notification.'); finally Request.Free; HttpClient.Free; end; end; ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值