v0.8.0
flutter_foreground_plugin
Flutter के लिए एक फ्रंटग्राउंड सर्विस प्लगइन। केवल Android (Oreo का समर्थन) को समर्थन देता है। iOS अभी के लिए समर्थित नहीं है।
52लाइक 12030-दिन डाउनलोड150Pub अंक
Android
ChangJoo-Park/flutter_foreground_service_plugin open-source repository details.
{"sdk":"flutter"}{"sdk":"flutter"}यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
dependencies:
...
flutter_foreground_plugin: ^0.4.0
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
</activity><service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService"/>
application <uses-sdk
android:minSdkVersion="23"
tools:overrideLibrary="changjoopark.com.flutter_foreground_plugin" />
Notification Icon Generator will be helpful.
path: android/app/src/main/res/drawable-*
void main() {
runApp(MyApp());
startForegroundService();
// if you need to stop foreground service,
// await FlutterForegroundPlugin.stopForegroundService();
}
void startForegroundService() async {
await FlutterForegroundPlugin.setServiceMethodInterval(seconds: 5);
await FlutterForegroundPlugin.setServiceMethod(globalForegroundService);
await FlutterForegroundPlugin.startForegroundService(
holdWakeLock: false,
onStarted: () {
print("Foreground on Started");
},
onStopped: () {
print("Foreground on Stopped");
},
title: "Flutter Foreground Service",
content: "This is Content",
iconName: "ic_stat_hot_tub",
);
}
void globalForegroundService() {
debugPrint("current datetime is ${DateTime.now()}");
}