Reputation: 35
I've a timer who's checking every 10 seconds for e new Message (awesome_notifications). So this works on Android and the iOS-Simulator, no matter if the app is opened or runs in the background. Only installed in the physically iPhone it's working just when the app is open - the push notification appears as soon as the app is opened. What to do?
@override
void dispose() {
timer?.cancel();
super.dispose();
}
Timer? timer;
@override
void initState() {
super.initState();
timer = Timer.periodic(Duration(seconds: 10), (Timer t) =>
NotificationController().notificationCheck());
}
Upvotes: 0
Views: 68
Reputation: 2256
You need to use some background mode to keep the app running in the background. Timers are not enough for that. I think, in your case you have 2 options:
Usually for message system push notifications are used. Background fetch is more for less frequent information, like daily news.
Upvotes: 1