-2

I am using CallKeep to awake the app (for shake detection I am using Shake plugin) when shaking the mobile, I want to up the flutter app when user shake the phone and app is killed.

I know I can use background_fetch: ^1.0.0, but problem is that it only allows after every 15 minutes, I want to listen shake event all the time.

Please help me out I am stuck here.

Thanks in advance

kiner_shah
  • 3,939
  • 7
  • 23
  • 37
Safdar Ali
  • 47
  • 5

1 Answers1

0

Check the code snippet and API documentation carefully. There is a property inside of configure called minimumFetchInterval. You can adjust the value and check if it works, should work.

api-doc Following code snippet is placed under Android part in api doc.

BackgroundFetch.configure(BackgroundFetchConfig(
  minimumFetchInterval: 15,  // <-- minutes
  stopOnTerminate: false,
  startOnBoot: true
), (String taskId) async {  // <-- Event callback
  // This callback is typically fired every 15 minutes while in the background.
  print('[BackgroundFetch] Event received.');
  // IMPORTANT:  You must signal completion of your fetch task or the OS could
  // punish your app for spending much time in the background.
  BackgroundFetch.finish(taskId);
}, (String taskId) async {  // <-- Task timeout callback
  // This task has exceeded its allowed running-time.  You must stop what you're doing and immediately .finish(taskId)
  BackgroundFetch.finish(taskId);
})
Muhtar
  • 1,506
  • 1
  • 8
  • 33