ios - 带有 sns 主题和 boto3 的静默苹果推送通知
<p><pre><code>topic = sns.Topic(topic_arn)
body = {'aps': {'content-available': 1, 'sound': ''}, 'update_type': 2, 'update_code': 44584}
body_json = json.dumps(body, ensure_ascii=False)
message = {'default': 'The default message',
'APNS_SANDBOX': body_json}
MESSAGE_JSON = json.dumps(message, ensure_ascii=False)
response = topic.publish(
Message=MESSAGE_JSON,
Subject='test subject',
MessageStructure='json'
)
</code></pre>
<p>这就是我尝试使用 <code>sns</code> 和 <code>boto3</code> 向主题发布消息的方式。它工作正常,我在我的 <code>iOS</code> 移动设备中收到通知,例如</p>
<pre><code>{
"aps" = {
"alert" = {
"default" = "The default message";
"APNS_SANDBOX" = {
"aps" = {
"content-available" = 1;
"sound" = ""
};
"update_type" = 2;
"update_code" = 44584;
}
}
}
}
</code></pre>
<p>据我所知,由于我发送的消息带有“警报”标签,即使应用程序不在后台运行,它也会立即显示在通知区域中。</p>
<p>很多链接,建议附加<strong>"content-available": 1</strong>,结果不变。
实际上,我正在寻找一个静默推送通知,以便我可以根据它采取一些行动。为此,我必须收到类似的通知</p>
<pre><code>{
aps = {
"content-available" = 1;
"sound" = "";
};
"update_code" = 44584;
"update_type" = 2;
}
</code></pre>
<p>为什么即使我包含 <strong>"content-available": 1</strong>,通知中也会出现 <strong>alert</strong> 标签? </p>
<p>任何帮助将不胜感激。<br/>
谢谢</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这似乎与我从未解决过的相同问题有关:</p>
<p> <a href="https://gist.github.com/tmarshall/6149ed2475f964cda3f5" rel="noreferrer noopener nofollow">Silent push</a> </p></p>
<p style="font-size: 20px;">关于ios - 带有 sns 主题和 boto3 的静默苹果推送通知,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37561939/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37561939/
</a>
</p>
页:
[1]