flutter_boot_receiver

Creator: coderz1093

Last updated:

Add to Cart

Description:

flutter boot receiver

flutter_boot_receiver #
A Flutter plugin for registering Dart callbacks when the Android device boots up.
Contents #

Platform Support
Installation
Usage

Platform Support #



Platform
Supported




Android
✔️ Yes


iOS
❌ No


Web
❌ No


Windows
❌ No


Linux
❌ No


MacOS
❌ No



Installation #

flutter pub add flutter_boot_receiver

In your AndroidManifest.xml:

Add android:installLocation="internalOnly" in your manifest tag. Only devices installed in internal storage can receive the BOOT_COMPLETE broadcast in Android.

<manifest
android:installLocation="internalOnly"
>
copied to clipboard

Add the following permission:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
copied to clipboard

Add the following service and receiver inside your application tag:

<service
android:name="com.flux.flutter_boot_receiver.BootHandlerService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"
/>
<receiver
android:enabled="true"
android:exported="true"
android:name="com.flux.flutter_boot_receiver.BootBroadcastReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
copied to clipboard
Your AndroidManifest.xml should now have a structure similar to this:
<manifest
android:installLocation="internalOnly"
>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- Other permissions... -->
<application>
<!-- Other activities, services etc... -->
<service
android:name="com.flux.flutter_boot_receiver.BootHandlerService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"
/>
<receiver
android:enabled="true"
android:exported="true"
android:name="com.flux.flutter_boot_receiver.BootBroadcastReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
copied to clipboard
Usage #
import 'package:flutter_boot_receiver/flutter_boot_receiver.dart';

@pragma('vm:entry-point')
void callback() async {
// Code here will be executed when the device boots up
}

await BootReceiver.initialize(callback);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.