Skip to content

Commit

Permalink
Add image of foreground notification to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianAssmann committed Feb 23, 2021
1 parent 1132324 commit 3da1865
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,23 @@ final androidConfig = FlutterBackgroundAndroidConfig(
bool success = await FlutterBackground.initialize(androidConfig: androidconfig);
```

The notification icon is for the small icon displayed in the top left of a notification and must be
a drawable Android Resource (see [here](https://developer.android.com/reference/android/app/Notification.Builder#setSmallIcon(int,%20int)) for more).
Check out the example app or the
[Android documentation for creating notification icons](https://developer.android.com/studio/write/image-asset-studio#create-notification)
for more information how to create and store an icon.
This results in the following notification (where `background_icon` is a drawable resource, see example app):
![The foreground notification created by the code above.](./images/notification.png "Foreground notification created by the code above.")

In order to function correctly, this plugin needs a few permissions.
`FlutterBackground.initialize(...)` will request permissions from the user if necessary.
You can call initialize more than one time, so you can call `initalize()` every time before you call
`enableBackgroundExecution()` (see below).
The notification icon is for the small icon displayed in the top left of a notification and must be a drawable Android Resource (see [here](https://developer.android.com/reference/android/app/Notification.Builder#setSmallIcon(int,%20int)) for more).
Check out the example app or the [Android documentation for creating notification icons](https://developer.android.com/studio/write/image-asset-studio#create-notification) for more information how to create and store an icon.

In order to notify the user about upcoming permission requests by the system, you need to know,
whether or not the app already has these permissions. You can find out by calling
In order to function correctly, this plugin needs a few permissions.
`FlutterBackground.initialize(...)` will request permissions from the user if necessary.
You can call initialize more than one time, so you can call `initalize()` every time before you call `enableBackgroundExecution()` (see below).

In order to notify the user about upcoming permission requests by the system, you need to know, whether or not the app already has these permissions. You can find out by calling

```dart
bool hasPermissions = await FlutterBackground.hasPermissions;
```

before calling `FlutterBackground.initialize(...)`. If the app already has all necessary permissions,
no permission requests will be displayed to the user.
before calling `FlutterBackground.initialize(...)`. If the app already has all necessary permissions, no permission requests will be displayed to the user.

### Run app in background

Expand All @@ -84,17 +81,15 @@ With
bool success = await FlutterBackground.enableBackgroundExecution();
```

you can try to get the app running in the background. You must call `FlutterBackground.initialize()`
before calling `FlutterBackground.enableBackgroundExecution()`.
you can try to get the app running in the background. You must call `FlutterBackground.initialize()` before calling `FlutterBackground.enableBackgroundExecution()`.

With

```dart
await FlutterBackground.disableBackgroundExecution();
```

you can stop the background execution of the app. You must call `FlutterBackground.initialize()`
before calling `FlutterBackground.disableBackgroundExecution()`.
you can stop the background execution of the app. You must call `FlutterBackground.initialize()` before calling `FlutterBackground.disableBackgroundExecution()`.

To check whether background execution is currently enabled, use

Expand Down
Binary file added images/notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3da1865

Please sign in to comment.