我编写了一个 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}\nRun Code Online (Sandbox Code Playgroud)\n这是我工作的本地通知配置:
\nvoid 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)