Giter Site home page Giter Site logo

android_alarm_manager's Introduction

Warning: This is an experiment

This project is an adaptation of the official Flutter Android Alarm Manager plugin.

It has been refactored to rely on flutter_service for Dart callbacks execution.

Please refer to flutter_service for details about what it does or bug reports.

Why?

The original implementation of android_alarm_manager executes Dart callbacks in an Android JobIntentService, which is a good default that will suit users most of the time.

However, there may be cases when you want the Dart callback to execute in a different context, like a Foreground Service for example. This is how this plugin differs from its original counterpart: it exposes the serviceType you would like it to run the Dart callback in.

API

The original public API of the plugin remains available, but:

  • the initialization is different.
  • a new parameter serviceType is available in all available public methods.
Initialization

Instead of calling

await AndroidAlarmManager.initialize();

You should now call

// at least one of the two should be set to true
await FlutterService.initialize(
  jobIntentService: true,
  foregroundService: true,
);
Specifying the service type

Most public methods available on the AndroidAlarmManager class now expose an optional parameter serviceType:

await AndroidAlarmManager.oneShot(
  const Duration(seconds: 5),
  1,
  callback,
  serviceType: 'JobIntentService' // by default set to 'JobIntentService' - currently also accepts 'ForegroundService'
);

If you have:

  • initialized FlutterService with foregroundService set to true
  • started the FlutterService' FlutterForegroundService by broadcasting an Intent containing a notification

Then you may now decide to execute the Dart callback within that Foreground Service:

await AndroidAlarmManager.oneShot(
  const Duration(seconds: 5),
  1,
  callback,
  serviceType: 'ForegroundService' // by default set to 'JobIntentService' - currently also accepts 'ForegroundService'
);

android_alarm_manager's People

Contributors

vkammerer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.