小编kor*_*m99的帖子

如何在颤振背景上设置自定义声音通知?

我编写了一个 flutter 应用程序,但无法使用自定义声音配置 firebase 云消息传递。我收到通知,但当应用程序处于后台时,它们会带有默认声音。在前台,我使用本地通知库,它运行良好,但我也需要在后台工作。

\n

这是我发送的云消息:

\n
{\n   "to":"<firebase_token>",\n   "notification":{\n      "sound":"arrive",\n      "title":"My Title",\n      "body":"My body"\n   },\n   "data":{\n      "click_action":"FLUTTER_NOTIFICATION_CLICK",\n      "status":"done",\n      "screen":"screenA",\n      "message":"ACTION"\n   },\n   "apns":{\n      "headers":{\n         "apns-priority":"5",\n         "apns-push-type":"background"\n      },\n      "payload":{\n         "aps":{\n            "content-available":1\n         }\n      }\n   }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

这是我工作的本地通知配置:

\n
void showNotification({\n    String title,\n    String body,\n  }) {\n    var androidPlatformChannelSpecifics = AndroidNotificationDetails(\n      'your channel id',\n      'your channel name',\n      'your channel description',\n      importance: Importance.Max,\n      priority: Priority.Max,\n      ticker: 'ticker',\n      playSound: true,\n      sound: RawResourceAndroidNotificationSound('arrive')\n    );\n\n    var iOSPlatformChannelSpecifics = IOSNotificationDetails();\n\n    var platformChannelSpecifics = NotificationDetails(\n      androidPlatformChannelSpecifics,\n      iOSPlatformChannelSpecifics,\n    );\n …
Run Code Online (Sandbox Code Playgroud)

push-notification flutter firebase-cloud-messaging

7
推荐指数
1
解决办法
2万
查看次数