扑扑firebase通知声音不起作用的iOS

时间:2020-11-11 19:48:58

标签: firebase flutter notifications firebase-cloud-messaging

我在iOS中遇到了Firebase通知问题,通知的声音不起作用,但是在android中它起作用

*发送通知: Future > sendAndRetrieveMessage(String msg)异步{ 等待firebaseMessaging.requestNotificationPermissions( const IosNotificationSettings(声音:true,徽章:true,警报:true,), ); 等待http.post( 'https://fcm.googleapis.com/fcm/send', 标头: { 'Content-Type':'application / json', '授权':'key = $ serverToken', }, 正文:jsonEncode( <字符串,动态> { '通知': { '身体':'xxxxx, '标题':'xxxx' }, 'priority':'high', '声音':'默认', '数据': { 'click_action':'FLUTTER_NOTIFICATION_CLICK', 'id':'1', '状态':'完成' }, '至':$ tok, }, ), ); 最终完成者>完成者= 完成者>(); 返回completer.future; }

*receive notifications:
 _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
     
        final notification = message['notification'];
        _showNotification(notification['body'], 'text2', 'text3');
       
      },
      onLaunch: (Map<String, dynamic> message) async {
        _showNotification( message['notification']['body'], 'text2', 'text3');
      },
      onResume: (Map<String, dynamic> message) async {
        _showNotification( message['notification']['body'], 'text2', 'text3');       
      },
    );
    _firebaseMessaging.requestNotificationPermissions(
        const IosNotificationSettings(sound: true, badge: true, alert: true,));
initializationSettingsAndroid =
    new AndroidInitializationSettings('app_icon');
    initializationSettingsIOS = new IOSInitializationSettings(
        onDidReceiveLocalNotification: onDidReceiveLocalNotification);
    initializationSettings = new InitializationSettings(
        initializationSettingsAndroid, initializationSettingsIOS);
    flutterLocalNotificationsPlugin.initialize(initializationSettings,
        onSelectNotification: onSelectNotification);

0 个答案:

没有答案