My application has permission to display critical notifications (remote and local). The application has logic configured to display critical notifications at a certain interval if the application is in the background
Log.i(">noti #\(i) next \(i * self.preEpisodeInterval)s")
self.scheduleLocalNoti(
title: LanguageHelper.getTranslationByKey(LanguageKey.ALARM) ?? "",
body: data.preEpisodeWarnMessage ?? "",
isCritical: true,
timeInterval: TimeInterval(i * self.preEpisodeInterval),
soundName: self.preAlarmModel?.data?.preEpisodeTone ?? "melodie.wav",
userInfo: [MotionTrackingManager.LOCAL_NOTI_PREALARM_USERINFO: ""]
)
private func scheduleLocalNoti(title: String,
body: String,
isCritical: Bool = false,
timeInterval: TimeInterval = 0,
soundName: String? = nil,
userInfo: [AnyHashable: Any]? = nil) {
let content = UNMutableNotificationContent()
content.title = title
content.body = body
if isCritical {
if soundName != nil {
let notiSound = UNNotificationSoundName(rawValue: soundName!)
content.sound = UNNotificationSound.criticalSoundNamed(notiSound, withAudioVolume: 1.0)
} else {
content.sound = UNNotificationSound.defaultCriticalSound(withAudioVolume: 1.0)
}
} else {
if soundName != nil {
let notiSound = UNNotificationSoundName(rawValue: soundName!)
content.sound = UNNotificationSound(named: notiSound)
} else {
content.sound = UNNotificationSound.default
}
}
if userInfo != nil {
content.userInfo = userInfo!
}
// Create the trigger
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: timeInterval + 1, repeats: false)
let uuidString = UUID().uuidString
Log.i("Schedule local noti for: \(timeInterval + 1) with uuid: \(uuidString)")
// Create the request
let request = UNNotificationRequest(
identifier: uuidString,
content: content,
trigger: trigger
)
// Schedule the request with the system.
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.add(request) { error in
if error != nil {
// Handle any errors.
Log.e("errr: \(String(describing: error?.localizedDescription))")
}
}
}
The application also has logic that requires geolocation tracking with the Background Modes Location update
mark in Signing & Capabilities
. If permission to track geolocation is denied, the local notification is not displayed (with remote ones, it still works correctly).
What's also interesting: this ONLY happens with builds in testFlight/appStore. The release build on the emulator directly from XCode works correctly and continues to display the notification even when access to geolocation is denied
How can geolocation affect the display of local critical notifications?