无法处理传入的后台消息

时间:2021-04-04 08:21:42

标签: javascript firebase flutter dart firebase-cloud-messaging

当我应用自定义通知声音时,出现如下所示的错误

Unable to handle incoming background message.
I/flutter ( 7271): PlatformException(INVALID_SOUND, The resource %s could not be found. Please make sure it has been added as a raw resource to your Android head project., null, null)

这是我正在实施的代码

    Future _showNotification(Map<String, dynamic> message) async {
    var sound = message['data']['music'];
    print(sound);
    var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
      'channel id',
      'channel name',
      'channel desc',
      importance: Importance.Max,
      playSound: true,
      visibility: NotificationVisibility.Secret,
      priority: Priority.High,
      sound: RawResourceAndroidNotificationSound(sound)
    );

    var platformChannelSpecifics =
    new NotificationDetails(androidPlatformChannelSpecifics,null);
    await flutterLocalNotificationsPlugin.show(
      0,
      '${message['data']['product']}',
      '${message['data']['product']} : ${message['data']['rate']}',
      platformChannelSpecifics,
//      payload: 'Default_Sound',
    );
  }

0 个答案:

没有答案