Ich habe eine Reihe von Wörterbüchern. Die Wörterbücher enthalten Namen/Länge/Breite für verschiedene Balken.Mass lokale Benachrichtigungen swift 3
Ich möchte standortbasierte Benachrichtigungen für jede Leiste in meiner App erstellen.
Hier ist die Funktion, die ich verwende, aber aus irgendeinem Grund erstellt es nur eine Benachrichtigung für den ersten Balken in der Liste. Der Rest funktioniert nicht.
Irgendeine Idee, was ist daran falsch? Ich bin mir nicht sicher, wofür content.badge ist.
// Register location based notifications for all bars
func setupNotifications(){
if(CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedAlways || CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse){
for i in 0...(allBars.count - 1){
let lat = (allBars[i])["Latitude"] as? Double
let long = (allBars[i])["Longitude"] as? Double
let name = (allBars[i])["Name"] as! String
let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: lat!, longitude: long!), radius: 60, identifier: "\(name)")
region.notifyOnEntry = true
region.notifyOnExit = false
let trigger = UNLocationNotificationTrigger(region: region, repeats: true)
let content = UNMutableNotificationContent()
content.title = "Rate \(name) in the app!"
content.badge = 1
content.sound = UNNotificationSound.default()
let request = UNNotificationRequest(identifier: "LN\(name)", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request) {(error) in
if let error = error{
print("Need notification permissions... \(error)")
}
else{
//success
}
}
}
}
}