Hi, I am trying to add in a push notification but the send push notifications function does not seem to be working. Can someone help?
func sendNotification() {
print("Bluetooth device disconnected. Sending notification.")
let content = UNMutableNotificationContent()
content.title = "Car Disconnected"
content.body = "Please key in where you have left your car"
content.sound = UNNotificationSound.default
// Create a trigger to send the notification immediately
let request = UNNotificationRequest(identifier: "BluetoothDisconnected", content: content, trigger: nil)
UNUserNotificationCenter.current().add(request) { error in
if let error = error {
print("Error adding notification request: \(error.localizedDescription)")
} else {
print("Notification request added successfully.")
}
}
}