收到时,iOS中的FCM通知不播放声音 [英] FCM Notification in iOS doesn't play sound when received

查看:86
本文介绍了收到时,iOS中的FCM通知不播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的iOS应用程序中使用Firebase推送通知.尽管我可以通过以下有效负载发送通知,但收到后不会播放声音.

I am using Firebase push notifications in my iOS Application. Although I am able to send the notification by sending below payload, it doesn't play a sound when received.

{
    "to": "myToken",
    "notification": {
        "body": "test",
        "title": "test"
    },
    "priority": "high"
    "sound": "default"
}

如果我从控制台发送测试消息,它可以正常工作并播放通知声音.
注意:

If I send the test message from console, it works well and plays notification sound.
Note:

  1. 我的授权码正确
  2. 我正在将http请求发送到https://fcm.googleapis.com/fcm/send
  3. 我已经在iPhone 4,iPhone 6和iPhone 6S上对其进行了测试,所有 没有声音的通知
  1. My Authorization code is correct
  2. I am sending http request to https://fcm.googleapis.com/fcm/send
  3. I have tested it on IPhone 4 , IPhone 6 and IPhone 6S, All recieve notifications without sound

推荐答案

您的JSON "sound" : "default"应该在"notification"密钥之内,而不是JSON的根中.此JSON应该可以使用.

your JSON "sound" : "default" should be inside the "notification" key not in the root of the JSON. This JSON should work.

{
    "to": "myToken",
    "notification": {
         "body": "test",
         "title": "test",
         "sound": "default"
    },
    "priority": "high"
}

这篇关于收到时,iOS中的FCM通知不播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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