Skip to content

Commit

Permalink
Disable notification non-show due to URL check
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunicorn committed Dec 16, 2024
1 parent 025dd7b commit f923e2d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/acter_notifify/lib/acter_notifify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef HandleMessageTap = FutureOr<bool> Function(Map<String?, Object?> data);
/// we should continue or not bother the user. Just a user based switch
typedef IsEnabledCheck = FutureOr<bool> Function();

/// Given the target url of the notifiction, should this notification be shown
/// Given the target url of the notification, should this notification be shown
/// or just be ignored. Useful to avoid showing push notification if the user
/// is on that same screen
typedef ShouldShowCheck = FutureOr<bool> Function(String url);
Expand Down Expand Up @@ -68,7 +68,18 @@ Future<String?> initializeNotifify({
if (usePush && pushServer.isNotEmpty) {
await initializePush(
handleMessageTap: handleMessageTap,
shouldShowCheck: shouldShowCheck,
shouldShowCheck: (a) async {
/// FIXME: to ensure we see failures after, this is being ignored for now
try {
if (shouldShowCheck != null) {
final res = await shouldShowCheck(a);
_log.info('Should show $a: $res');
}
} catch (e, s) {
_log.severe('Checking whether $a should be shown failed', e, s);
}
return true;
},
isEnabledCheck: isEnabledCheck,
currentClientsGen: currentClientsGen,
appIdPrefix: appIdPrefix,
Expand Down

0 comments on commit f923e2d

Please sign in to comment.