如何创建不振动的iOS推送通知? [英] How can I create iOS push notifications that don’t vibrate?

查看:136
本文介绍了如何创建不振动的iOS推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何创建静音推送通知(播放静音的声音文件)。
我还想发送一个不振动手机的推送通知。

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推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆