@@ -3,7 +3,7 @@ import 'dart:core';
3
3
import 'package:flutter/foundation.dart'
4
4
show debugDefaultTargetPlatformOverride;
5
5
import 'package:flutter/material.dart' ;
6
- import 'package:flutter_foreground_plugin/flutter_foreground_plugin .dart' ;
6
+ import 'package:flutter_background/flutter_background .dart' ;
7
7
import 'package:flutter_webrtc/flutter_webrtc.dart' ;
8
8
9
9
import 'src/data_channel_sample.dart' ;
@@ -24,25 +24,15 @@ void main() {
24
24
}
25
25
26
26
Future <bool > startForegroundService () async {
27
- await FlutterForegroundPlugin .setServiceMethodInterval (seconds: 5 );
28
- await FlutterForegroundPlugin .setServiceMethod (globalForegroundService);
29
- await FlutterForegroundPlugin .startForegroundService (
30
- holdWakeLock: false ,
31
- onStarted: () {
32
- print ('Foreground on Started' );
33
- },
34
- onStopped: () {
35
- print ('Foreground on Stopped' );
36
- },
37
- title: 'Tcamera' ,
38
- content: 'Tcamera sharing your screen.' ,
39
- iconName: 'ic_stat_mobile_screen_share' ,
27
+ final androidConfig = FlutterBackgroundAndroidConfig (
28
+ notificationTitle: 'Title of the notification' ,
29
+ notificationText: 'Text of the notification' ,
30
+ notificationImportance: AndroidNotificationImportance .Default ,
31
+ notificationIcon: AndroidResource (
32
+ name: 'background_icon' ,
33
+ defType: 'drawable' ), // Default is ic_launcher from folder mipmap
40
34
);
41
- return true ;
42
- }
43
-
44
- void globalForegroundService () {
45
- debugPrint ('current datetime is ${DateTime .now ()}' );
35
+ return FlutterBackground .initialize (androidConfig: androidConfig);
46
36
}
47
37
48
38
class MyApp extends StatefulWidget {
0 commit comments