Ahmad Abbas
Ahmad Abbas

Reputation: 1

how to change icon of initialize flutter_background_service?

how to change icon of initialize flutter_background_service?

`Future initializeService() async { final service = FlutterBackgroundService();

const AndroidNotificationChannel channel = AndroidNotificationChannel( 'my_app_id', // id 'Check out', // title description: 'in Progress', importance: Importance.high, // showBadge: true, enableVibration: true, // importance must be at low or higher level );

final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();

if (Platform.isIOS || Platform.isAndroid) { await flutterLocalNotificationsPlugin.initialize( const InitializationSettings( iOS: DarwinInitializationSettings(), android: AndroidInitializationSettings('@mipmap/ic_launcher'), ), );

}

await flutterLocalNotificationsPlugin .resolvePlatformSpecificImplementation() ?.createNotificationChannel(channel);

await service.configure( androidConfiguration: AndroidConfiguration( onStart: onStart, autoStart: true, isForegroundMode: true, notificationChannelId: 'my_app_id', initialNotificationTitle: 'Check out', initialNotificationContent: 'In Progress . . .', foregroundServiceNotificationId: 888, ), iosConfiguration: IosConfiguration( autoStart: true, onForeground: onStart, onBackground: onIosBackground, ), );

service.startService(); }`

Upvotes: 0

Views: 273

Answers (1)

Sebastian celis
Sebastian celis

Reputation: 1

hi i have the same isssue the solution work for me comment this :

        await flutterLocalNotificationsPlugin
        .resolvePlatformSpecificImplementation<
            AndroidFlutterLocalNotificationsPlugin>()
        ?.createNotificationChannel(channel);

and replace for this :

    await flutterLocalNotificationsPlugin.show(
        notificationId,
        'Tripcar se ejecuta en segundo plano',
        'Solo para recibir carreras',
        NotificationDetails(
          android: AndroidNotificationDetails(
            channel.id,
            channel.name,
            channelDescription: channel.description,
            icon: '@mipmap/ic_launcher',
            importance: Importance.max,
            priority: Priority.max,
            playSound: true,
          ),
        )); 

Upvotes: 0

Related Questions