SayWut / flutter_foreground_service_plugin

MIT License
12 stars 12 forks source link

Sound and vibration not working! #13

Open valeriomarchetti opened 3 years ago

valeriomarchetti commented 3 years ago

Hi dear, I have a problem with enableSound and enableVibration. These flags seem are not working if I set both to true.

void periodicTaskFun() {
  FlutterForegroundServicePlugin.executeTask(() async {
    // this will refresh the notification content each time the task is fire
    // if you want to refresh the notification content too each time
    // so don't set a low period duretion because android isn't handling it very well
    await FlutterForegroundServicePlugin.refreshForegroundServiceContent(
      notificationContent: NotificationContent(
          iconName: 'ic_launcher',
          titleText: 'Title Text',
          bodyText: '${DateTime.now()}',
          subText: 'subText',
          color: Colors.red,
          enableSound: true,
          enableVibration: true),
    );

    print(DateTime.now());
  });
}

I have also tried to change the NotificationContent priority and the NotificationChannelContent importance, but nothing..

P.S. I have already set the android permission to the AndroidManifest

<uses-permission android:name="android.permission.VIBRATE" />

Could you help me?