forked from lichess-org/mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ios badge after receiving a data message
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/services.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
final badgeService = BadgeService(Logger('BadgeService')); | ||
|
||
class BadgeService { | ||
static const _channel = MethodChannel('mobile.lichess.org/badge'); | ||
|
||
const BadgeService(this._log); | ||
|
||
final Logger _log; | ||
|
||
Future<void> setBadge(int value) async { | ||
try { | ||
await _channel.invokeMethod<int>('setBadge', <String, dynamic>{ | ||
'badge': value, | ||
}); | ||
} on PlatformException catch (e) { | ||
_log.severe(e); | ||
} | ||
} | ||
|
||
Future<void> clearBadge() async { | ||
try { | ||
await _channel.invokeMethod<int>('setBadge', 0); | ||
} on PlatformException catch (e) { | ||
_log.severe(e); | ||
} | ||
} | ||
} |