这是我实现的代码:
beaconRegion.notifyOnEntry = true
beaconRegion.notifyOnExit = true
self.beaconManager.delegate = self
self.beaconManager.requestAlwaysAuthorization()
self.beaconManager.startMonitoring(for: beaconRegion)
func beaconManager(_ manager: Any, didEnter region: CLBeaconRegion) {
if isAuthenticated == nil {
return
}
let notification = UILocalNotification()
notification.alertBody = "You are in beacon range."
notification.fireDate = Date.init(timeIntervalSinceNow: 2)
notification.userInfo = ["enterInBeaconRange":true]
UIApplication.shared.presentLocalNotificationNow(notification)
}
现在,如果我设置“cancelAllLocalNotifications”的方法通知之前,它不清除从通知中心所有以前的通知。
请分享您的代码,看看您可能会做错什么。 –