在后台模式下,FCM 自定义声音在 iOS 上不起作用
FCM custom sound not working on iOS when in background mode
FCM 最近有什么变化吗?我们的应用程序在推送通知中使用自定义声音。这在 Android 和 iOS 上都运行良好,无论是在前台、后台还是关闭。但最近似乎发生了一些变化,因为当应用程序关闭或处于后台模式时,我们一直使用的相同 PHP 代码突然停止用于自定义声音? (通知已发送,但仅使用默认设备声音)。
通过将声音文件包含在 /app/src/res/raw 中,我能够在 Android 上再次使用它(我们过去常常将它们保存在那里,但很长一段时间以来都不需要它了但总是有效......显然它再次需要)。好的Android解决了
但是对于 iOS 它仍然停止工作!我不确定是不是我在 xCode 中做错了什么,或者我是否需要更改用于触发通知的 PHP 代码。所以这里要回顾一下:
我正在使用:
- xCode11.6
- iOS 目标 11.0
- 在真实设备上测试,iOS 13.6.1
- 声音文件位于 {Project Name}/Resources/ 并添加了“如果需要复制项目”和“创建组”都已选中
触发通知的服务器端代码(之前一直运行良好且未更改):
{
"notification": {
"title": "Test Title",
"body": "Test Body",
"sound": "sound_file.mp3",
},
"registration_ids": ["APA...g","fl...CS"]
}
请帮助...以为我已经过去了这么多年...ugggg!
在我这边,无论我设置什么声音名称,我总是在 ios 端收到 "sound": "default"
发送中:
{
"notification": {
"title": "Alert",
"body": "Test Message",
"sound": "alert.aiff",
},
"registration_ids": ["APA...g","fl...CS"]
}
接收:
{
aps = {
alert = {
body = "Test Message";
title = Alert;
};
"content-available" = 1;
sound = default;
};
}
发生这种情况的唯一原因是 FCM 在重定向到 APNS 时将声音设置为默认值。需要询问 google
我们在 Google/Firebase 支持下创建了工单。
他们的回答:
我们这边没有持续存在的问题可能会导致自定义声音无法正常工作。但是,通过指定自定义声音,声音文件必须已经在用户的设备上,或者在应用程序的捆绑包中,或者在应用程序容器的 library/Sounds 文件夹中。您可以参考此文档以获取更多信息。
对于 FCM,没有任何额外的声音处理,只传递 payload 字段,所以只要客户端上的 payload 显示“sound”文件被成功传递下来,就可能是设置有问题。如果您的应用程序和声音文件最近没有更改,那么这可能是 Apple 方面造成的。有了这个,最好和他们核实一下。
我们发现我们显然使用旧版 HTTP API,因此我们测试了较新的 HTTP v1 版本。 (此处描述:https://firebase.google.com/docs/cloud-messaging/migrate-v1)
这为我们解决了问题。自定义声音回来了。
与此同时,Firebase 支持回复了以下内容,现在承认旧版 HTTP API.
存在问题
Thanks for sharing your observations, Mark.
We’ve received similar reports regarding this issue and that indicates
that this is not an unusual issue in relation to the increasing
reports on the Stack Overflow discussion that you’ve mentioned too.
With that, this issue was just recently identified as a bug with our
Legacy API that’s not properly handling the custom sound for iOS. Our
engineering team has identified the fix for this issue, and we
couldn’t provide a definite timeline at the moment for the release in
our production. I’ll let you know once I have an update for this
issue.
For now, you might consider using our HTTP v1 API to send your
messages. Apologies for the inconvenience this may have caused you.
详细信息:
示例代码:
{
"message":{
"token":"ewrTK.....",
"notification":{
"title":"Breaking News",
"body":"New news story available."
},
"data":{
"title":"Notification title",
"body":"Notfication body"
},
"apns":{
"payload":{
"aps":{
"sound":"notification.mp3"
}
}
}
}
}
我们刚刚与 Firebase 开发团队进行了接触,他们能够重现该问题。他们刚刚创建了一个内部票证来解决这个问题。会在这跟进解决进度
在与 Firebase 进行了几轮额外的沟通后,这是当前的状态更新和他们的回应:
I would like to let you know that this issue was just recently
identified as a bug with our Legacy API that’s not properly handling
the custom sound for iOS. Our FCM gurus have identified the fix for
this issue, and the fix is about to be released on our production, but
we can’t share any exact details or timeline for the release. The fix
should let you send notifications properly based on your custom sounds
configuration and there should be no code changes needed on your end.
Also, it should still properly handle the notification sounds if the
app is closed or in background state for your iOS application.
我们还被告知,目前,从 FCM HTTP 迁移到 HTTP v1 是唯一的解决方法。一旦我们听到对 Legacy API 修复的确认(大多数人阅读这篇文章时都在使用),我们会再次在这里 post 。敬请期待...
请大家检查一下,Google 已经解决了这个问题!!
FCM 最近有什么变化吗?我们的应用程序在推送通知中使用自定义声音。这在 Android 和 iOS 上都运行良好,无论是在前台、后台还是关闭。但最近似乎发生了一些变化,因为当应用程序关闭或处于后台模式时,我们一直使用的相同 PHP 代码突然停止用于自定义声音? (通知已发送,但仅使用默认设备声音)。
通过将声音文件包含在 /app/src/res/raw 中,我能够在 Android 上再次使用它(我们过去常常将它们保存在那里,但很长一段时间以来都不需要它了但总是有效......显然它再次需要)。好的Android解决了
但是对于 iOS 它仍然停止工作!我不确定是不是我在 xCode 中做错了什么,或者我是否需要更改用于触发通知的 PHP 代码。所以这里要回顾一下:
我正在使用:
- xCode11.6
- iOS 目标 11.0
- 在真实设备上测试,iOS 13.6.1
- 声音文件位于 {Project Name}/Resources/ 并添加了“如果需要复制项目”和“创建组”都已选中
触发通知的服务器端代码(之前一直运行良好且未更改):
{
"notification": {
"title": "Test Title",
"body": "Test Body",
"sound": "sound_file.mp3",
},
"registration_ids": ["APA...g","fl...CS"]
}
请帮助...以为我已经过去了这么多年...ugggg!
在我这边,无论我设置什么声音名称,我总是在 ios 端收到 "sound": "default"
发送中:
{
"notification": {
"title": "Alert",
"body": "Test Message",
"sound": "alert.aiff",
},
"registration_ids": ["APA...g","fl...CS"]
}
接收:
{
aps = {
alert = {
body = "Test Message";
title = Alert;
};
"content-available" = 1;
sound = default;
};
}
发生这种情况的唯一原因是 FCM 在重定向到 APNS 时将声音设置为默认值。需要询问 google
我们在 Google/Firebase 支持下创建了工单。 他们的回答: 我们这边没有持续存在的问题可能会导致自定义声音无法正常工作。但是,通过指定自定义声音,声音文件必须已经在用户的设备上,或者在应用程序的捆绑包中,或者在应用程序容器的 library/Sounds 文件夹中。您可以参考此文档以获取更多信息。 对于 FCM,没有任何额外的声音处理,只传递 payload 字段,所以只要客户端上的 payload 显示“sound”文件被成功传递下来,就可能是设置有问题。如果您的应用程序和声音文件最近没有更改,那么这可能是 Apple 方面造成的。有了这个,最好和他们核实一下。
我们发现我们显然使用旧版 HTTP API,因此我们测试了较新的 HTTP v1 版本。 (此处描述:https://firebase.google.com/docs/cloud-messaging/migrate-v1) 这为我们解决了问题。自定义声音回来了。
与此同时,Firebase 支持回复了以下内容,现在承认旧版 HTTP API.
存在问题Thanks for sharing your observations, Mark.
We’ve received similar reports regarding this issue and that indicates that this is not an unusual issue in relation to the increasing reports on the Stack Overflow discussion that you’ve mentioned too. With that, this issue was just recently identified as a bug with our Legacy API that’s not properly handling the custom sound for iOS. Our engineering team has identified the fix for this issue, and we couldn’t provide a definite timeline at the moment for the release in our production. I’ll let you know once I have an update for this issue.
For now, you might consider using our HTTP v1 API to send your messages. Apologies for the inconvenience this may have caused you.
详细信息:
示例代码:
{
"message":{
"token":"ewrTK.....",
"notification":{
"title":"Breaking News",
"body":"New news story available."
},
"data":{
"title":"Notification title",
"body":"Notfication body"
},
"apns":{
"payload":{
"aps":{
"sound":"notification.mp3"
}
}
}
}
}
我们刚刚与 Firebase 开发团队进行了接触,他们能够重现该问题。他们刚刚创建了一个内部票证来解决这个问题。会在这跟进解决进度
在与 Firebase 进行了几轮额外的沟通后,这是当前的状态更新和他们的回应:
I would like to let you know that this issue was just recently identified as a bug with our Legacy API that’s not properly handling the custom sound for iOS. Our FCM gurus have identified the fix for this issue, and the fix is about to be released on our production, but we can’t share any exact details or timeline for the release. The fix should let you send notifications properly based on your custom sounds configuration and there should be no code changes needed on your end. Also, it should still properly handle the notification sounds if the app is closed or in background state for your iOS application.
我们还被告知,目前,从 FCM HTTP 迁移到 HTTP v1 是唯一的解决方法。一旦我们听到对 Legacy API 修复的确认(大多数人阅读这篇文章时都在使用),我们会再次在这里 post 。敬请期待...
请大家检查一下,Google 已经解决了这个问题!!