ios - AWS CLI SNS 向我的 iOS 应用程序推送通知有效,但我如何播放不同的声音或更改角标(Badge)编号?

标签 ios amazon-web-services push-notification command-line-interface

我正在使用 Amazon Web Service 命令行界面通过以下命令向我的 iOS 应用程序发送推送通知:

aws sns publish --target-arn \"arn:aws:sns:us-east-1:545678945607:endpoint/APNS_SANDBOX/MyApp/lk4ggss56-2F29-3r55-6Qw2-dsd4sad4s5a\" --message \"hello!\" 

这工作正常,但是否也可以传递信息以播放非默认声音或使用 AWS CLI 更改应用程序的角标(Badge)编号?

直接向 Apple 的 APNs 发送消息时,您可以发布与此类似的 json block 来更改播放的声音或角标(Badge)编号:

{
  "aps" : {
    "alert" : {
      "title" : "testMessage",
      "body" : "Hi!"
    },
    "sound" : "0546.aiff",
    "badge": "100"
  }
}

这对我来说是全新的,任何帮助将不胜感激!谢谢!

已解决

更新:对我有用的解决方案:

使用这个命令:

aws sns publish --target-arn \"arn:aws:sns:us-east-1:545678945607:endpoint/APNS_SANDBOX/MyApp/lk4ggss56-2F29-3r55-6Qw2-dsd4sad4s5a\" --message-structure \"json\"  --message file://aps.json

名为“aps.json”的文件的内容是:

{"default":"This is the default Message","APNS_SANDBOX":"{ \"aps\" : { \"alert\" : \"New push notification.\", \"badge\" : 9,\"sound\" :\"0546.aiff\"}}"}

设置角标(Badge)编号,并使用我的应用中包含的自定义声音。

最佳答案

对我有用的解决方案:

使用这个命令:

aws sns publish --target-arn \"arn:aws:sns:us-east-1:545678945607:endpoint/APNS_SANDBOX/MyApp/lk4ggss56-2F29-3r55-6Qw2-dsd4sad4s5a\" --message-structure \"json\"  --message file://aps.json

名为“aps.json”的文件的内容是:

{"default":"This is the default Message","APNS_SANDBOX":"{ \"aps\" : { \"alert\" : \"New push notification.\", \"badge\" : 9,\"sound\" :\"0546.aiff\"}}"}

设置角标(Badge)编号,并使用我的应用中包含的自定义声音。

window :

aws sns publish --topic-arn "arn:aws:sns:eu-west-2:123412341234:some-topic" --message-structure json --message '{\"default\":\"This is the default Message\",\"test\": \"value\"}'

关于ios - AWS CLI SNS 向我的 iOS 应用程序推送通知有效,但我如何播放不同的声音或更改角标(Badge)编号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50204116/

相关文章:

ios - 即使内容的 Storyboard已更新,也不会调用通知内容

push-notification - 使用 PHP 客户端为 Google Calendar API 设置推送通知

ios - 按字符串属性的首字母过滤数组

ios - 深度链接未显示正确的 Storyboard

android - AWS 认知 : dealing with token expiration time

php - 我找到了一个链接,但我不知道那是什么

ios - UILabel 属性文本呈现不正确

ios - NSDictionary writeToFile 编码仅在 UTF-8 中?

amazon-web-services - 在 Amazon DynamoDB 中解码字符串集

ios - 单击推送通知时正确重定向到选项卡栏导航 Controller 内的 View Controller