Skip to content

Commit

Permalink
Modify logic on enx notification check (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxMarkowitz committed May 21, 2022
1 parent 1a85317 commit a64d1d7
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions ios/BT/ExposureManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,28 +196,29 @@ final class ExposureManager: NSObject {
let defaults = UserDefaults.standard
let lastEnxTimestamp = defaults.double(forKey: "lastEnxTimestamp")
let enxCount = defaults.double(forKey: "enxCount")
let sameDay = self.hasBeenTwentyFourHours(lastSubmitted: lastEnxTimestamp)
var sameDay = self.hasBeenTwentyFourHours(lastSubmitted: lastEnxTimestamp)

if (lastEnxTimestamp == 0 || sameDay != nil) {
if (enxCount <= 3) {
let newDate = Date.init().timeIntervalSince1970;
defaults.set(enxCount + 1, forKey: "enxCount");
defaults.set(newDate, forKey: "lastEnxTimestamp");

let identifier = String.enxMigrationIdentifier
let content = UNMutableNotificationContent()
content.title = String.enxMigrationNotificationTitle.localized
content.body = String(ReactNativeConfig.env(for: .enxNotificationText))
//content.body = String.enxMigrationNotificationContent.localized
content.userInfo = [String.notificationUrlKey: "\(String.notificationUrlBasePath)"]
content.sound = .default

let request = UNNotificationRequest(identifier: identifier, content: content, trigger: nil)
userNotificationCenter.add(request) { error in
DispatchQueue.main.async {
if let error = error {
print("Error showing error user notification: \(error)")
}
if (lastEnxTimestamp == 0) {
sameDay = false;
}
if (enxCount <= 3 && sameDay == false) {
let newDate = Date.init().timeIntervalSince1970;
defaults.set(enxCount + 1, forKey: "enxCount");
defaults.set(newDate, forKey: "lastEnxTimestamp");

let identifier = String.enxMigrationIdentifier
let content = UNMutableNotificationContent()
content.title = String.enxMigrationNotificationTitle.localized
content.body = String(ReactNativeConfig.env(for: .enxNotificationText))
//content.body = String.enxMigrationNotificationContent.localized
content.userInfo = [String.notificationUrlKey: "\(String.notificationUrlBasePath)"]
content.sound = .default

let request = UNNotificationRequest(identifier: identifier, content: content, trigger: nil)
userNotificationCenter.add(request) { error in
DispatchQueue.main.async {
if let error = error {
print("Error showing error user notification: \(error)")
}
}
}
Expand Down

0 comments on commit a64d1d7

Please sign in to comment.