问题描述
我知道如何创建静音推送通知(播放静音的声音文件)。
我还想发送一个不振动手机的推送通知。
I know how to create silent push notifications (with playing a sound file that is silent).I would also like to send a push notification that doesn't vibrate phone.
当按照以下建议设置静音文件时,手机在锁定时仍会振动或当应用程序未激活时。
When setting silent sound file as suggested below phone still vibrates when it is locked or when the app is not active.
我仍然振动的有效负载:
My payload that still vibrates:
{
aps = {
alert = {
"loc-key" = "SOME_KEY";
};
badge = 1;
sound = "silence.caf";
};
}
这可能吗?
推荐答案
省略声音键应该可以解决问题:
Omitting the sound key should do the trick:
{"aps":{"alert":{"loc-key":"SOME_KEY"}, "badge":1}
声明如果声音文件不存在或默认值被指定为值,则播放默认警报声音。。他们没有说的是,如果你根本不提供声音键,就不会播放声音。如果没有播放声音,手机也不应该振动。
The docs state that "If the sound file doesn’t exist or default is specified as the value, the default alert sound is played.". What they don't say is that if you don't provide a sound key at all, no sound will be played. If no sound is played, the phone should not vibrate as well.
这篇关于如何创建不振动的iOS推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!