Closed masus04 closed 7 months ago
I can confirm that happens also on my side, eventhough that despite the error it keeps working on my app and the ongoing activity is ok.
I was able to reproduce it, not in a constant way, but seems that is when the app is unexpected closed (like stopping the debugger or forcing the exit without calling the WearOngoingActivity.stop()
function. On the further launchments of the app after making the init, if we WearOngoingActivity.update()
I have the same error, it doesn't find the initialized ongoing activity.
my implementation:
import 'package:wear_ongoing_activity/wear_ongoing_activity.dart';
class OngoingActivityService {
/// Initialize the ongoing activity
static Future<void> init(String message) async {
return WearOngoingActivity.start(
channelId: 'ongoing_activity',
channelName: 'Ongoing Activity',
notificationId: 12345,
category: NotificationCategory.status,
foregroundServiceTypes: {
ForegroundServiceType.dataSync,
},
smallIcon: 'ic_notification',
staticIcon: 'ic_notification',
animatedIcon: 'ic_notification',
status: OngoingActivityStatus(
templates: [
'#type#',
],
parts: [
TextPart(name: 'type', text: message),
],
),
);
}
/// Update the ongoing activity text
static Future<void> update(String message) async {
return WearOngoingActivity.update(
OngoingActivityStatus(
templates: [
'#type#',
],
parts: [
TextPart(
name: 'type',
text: message
),
],
),
);
}
/// Dispose the ongoing activity
static Future<void> dispose() {
return WearOngoingActivity.stop();
}
}
The icons are supposed to be Android resource IDs, not Flutter assets. That's probably why the first code example isn't working
I'm going to need a code sample that reliable reproduces this in order to look into it
Ok, while trying to reproduce the error in an example project, I figured out that I had never called the WearOngoingActivity.start
method, and therefore calling the WearOngoingActivity.update
method resulted in an error.
Thanks for your support :+1:
This was probably caused by calling update
too soon after calling start
. I pushed a new version 0.1.4
that adds an isOngoing
method so that you can check if the activity is running before attempting to update it.
I configured an ongoing activity as follows:
AndroidManifest.xml
notification_controller.dart
When I run it, the following error is thrown and no notification is shown:
Any idea what this could be about?