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

查看:26
本文介绍了如何创建不振动的 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天全站免登陆