ios - AWS CLI SNS 向我的 iOS 应用程序推送通知有效,但如何播放不同的声音或更改徽章编号?
问题描述
我正在使用 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 更改应用程序的徽章编号?
当直接向 Apple 的 APNs 发送消息时,您可以发布与此类似的 json 块来更改播放的声音或徽章编号:
{
"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\"}}"}
它设置了徽章编号,并使用了我的应用程序中包含的自定义声音。
解决方案
对我有用的解决方案:
使用了这个命令:
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\"}}"}
其中设置了徽章编号,并使用了我的应用程序中包含的自定义声音。
视窗:
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\"}'
推荐阅读
- typescript - Parcel 中的多个捆绑包
- google-apps-script - 根据单元格值更改 URL
- ios - 如何在 Xcode 的 AppDelegate.h 中声明接口?
- compiler-errors - Solaris 10 上的 LibreSSL 3.0.2 编译错误:未定义对符号“SHA512Final”的引用
- reactjs - 部署到 Heroku 时出现“无法在模块外使用 import 语句”错误
- c# - 在 Form.cs 中生成自定义 C# 代码,同时在设计时在 Form1.cs 中删除用户控件
- javascript - 导出默认后 vscode 是否支持装饰器?如何让这个启用?
- javascript - 如何检查对象数组中是否存在自定义键
- java - Java aop ComponentScan 不工作 & AnnotationConfigApplicationContext getBean 不工作
- python-3.x - 将 python 数据导出为 CSV