简体   繁体   English

AWS CLI SNS 向我的 iOS 应用程序推送通知有效,但如何播放不同的声音或更改徽章编号?

[英]AWS CLI SNS push notifications to my iOS app works, but how can I play a different sound or change the badge number?

I'm using the Amazon Web Service Command Line Interface to send a push notification to my iOS app using the command:我正在使用 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!\" 

This works fine, but is it possible to also pass info for playing a non-defualt sound or changing the app's badge number using the AWS CLI?这工作正常,但是否也可以传递信息以使用 AWS CLI 播放非默认声音或更改应用程序的徽章编号?

When sending a message to Apple's APNs directly you're able to post a json block similar to this to change the sound played or badge number:当直接向 Apple 的 APNs 发送消息时,您可以发布一个类似于此的 json 块来更改播放的声音或徽章编号:

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

This is all new to me, any help would be appreciated!这对我来说是全新的,任何帮助将不胜感激! Thanks!谢谢!

SOLVED解决了

Update: Solution that worked for me:更新:对我有用的解决方案:

Used this command:使用了这个命令:

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

The contents of the file named "aps.json" is:名为“aps.json”的文件内容为:

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

Which sets the badge number, and uses the custom sound included in my app.它设置徽章编号,并使用我的应用程序中包含的自定义声音。

Solution that worked for me:对我有用的解决方案:

Used this command:使用了这个命令:

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

The contents of the file named "aps.json" is:名为“aps.json”的文件内容为:

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

Which set the badge number, and uses the custom sound included in my app.设置徽章编号,并使用我的应用程序中包含的自定义声音。

Windows:视窗:

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\"}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM