Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #3186: Remove any prior scheduled or delivered ad grant reminders (
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson authored Jan 12, 2021
1 parent ab0b0ff commit 827b27b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Client/Application/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati

// Schedule Brave Core Priority Tasks
self.braveCore?.scheduleLowPriorityStartupTasks()
browserViewController.removeScheduledAdGrantReminders()

log.info("startApplication end")
return true
Expand Down
15 changes: 15 additions & 0 deletions Client/Frontend/Browser/BrowserViewController/BVC+Rewards.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ extension BrowserViewController {
tabManager.addTabAndSelect(request, isPrivate: isPrivate)
}
}

/// Removes any scheduled or delivered ad grant reminders which may have been added prior to
/// removal of those reminders.
func removeScheduledAdGrantReminders() {
let idPrefix = "rewards.notification.monthly-claim"
let center = UNUserNotificationCenter.current()
center.getPendingNotificationRequests { requests in
let ids = requests
.filter { $0.identifier.hasPrefix(idPrefix) }
.map(\.identifier)
if ids.isEmpty { return }
center.removeDeliveredNotifications(withIdentifiers: ids)
center.removePendingNotificationRequests(withIdentifiers: ids)
}
}
}

extension Tab {
Expand Down

0 comments on commit 827b27b

Please sign in to comment.