-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
176 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Keys.swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// RegionsListVC+CoreLocationsDelegate.swift | ||
// GeofenceTester | ||
// | ||
// Created by Alexander von Below on 30.06.22. | ||
// | ||
|
||
import UIKit | ||
import CoreLocation | ||
|
||
extension RegionsListViewController: CLLocationManagerDelegate { | ||
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { | ||
process(event: .ENTER, region: region) | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { | ||
process(event: .EXIT, region: region) | ||
} | ||
|
||
private func process (event: EventRecord.EventType, region: CLRegion) { | ||
let content = UNMutableNotificationContent() | ||
let title: String | ||
switch event { | ||
case .ENTER: | ||
title = NSLocalizedString("Region Entered", | ||
comment: "Push Notificaton Title") | ||
case .EXIT: | ||
title = NSLocalizedString("Region Exited", | ||
comment: "Push Notificaton Title") | ||
} | ||
content.title = title | ||
content.body = "\(region.identifier) \(Date())" | ||
|
||
let eventRecord = EventRecord(event: event, | ||
identifier: region.identifier, | ||
date: Date()) | ||
do { | ||
try storage.store(eventRecord) | ||
} | ||
catch let error { | ||
self.handleError(error) | ||
} | ||
let request = UNNotificationRequest(identifier: region.identifier, | ||
content: content, | ||
trigger: nil) | ||
UNUserNotificationCenter.current().add(request) | ||
} | ||
|
||
func locationManager( _ manager: CLLocationManager, | ||
monitoringDidFailFor region: CLRegion?, | ||
withError error: Error | ||
) { | ||
self.handleError(error) | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, | ||
didChangeAuthorization status: CLAuthorizationStatus) { | ||
switch status { | ||
case .restricted, .denied: | ||
// Disable your app's location features | ||
self.handleError("Warning: Location restricted or denied") | ||
|
||
case .authorizedWhenInUse: | ||
// Enable your app's location features. | ||
self.handleError("Warning: Location InUse Only") | ||
|
||
case .authorizedAlways: | ||
self.mapView.showsUserLocation = true | ||
// Enable or prepare your app's location features that can run any time. | ||
|
||
case .notDetermined: | ||
self.handleError("Warning: Location Not Determined") | ||
default: | ||
self.handleError("Warning: Switch fell through") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* Privacy - Location Always and When In Use Usage Description */ | ||
"NSLocationWhenInUseUsageDescription" = "Der Zweck dieser App ist Region Monitoring. Dazu benötigt sie Ortungsdienste im Hintergrund"; | ||
"NSLocationAlwaysAndWhenInUseUsageDescription" = "Der Zweck dieser App ist Region Monitoring. Dazu benötigt sie Ortungsdienste im Hintergrund"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Accessibilty label for add button */ | ||
"Add Monitored Region at current location" = "Füge eine überwachte Region am aktuellen Ort hinzu"; | ||
|
||
/* New Region Alert */ | ||
"Cancel" = "Abbrechen"; | ||
|
||
/* New Region Alert */ | ||
"New Region" = "Neue Region"; | ||
|
||
/* Alert: Authorization to Localization denied */ | ||
"No authorization" = "Keine Authorization"; | ||
|
||
/* New Region Alert */ | ||
"OK" = "OK"; | ||
|
||
/* New Region Alert */ | ||
"Please enter a name" = "Name für die Region"; | ||
|
||
/* Push Notificaton Title */ | ||
"Region Entered" = "Region betreten"; | ||
|
||
/* Push Notificaton Title */ | ||
"Region Exited" = "Region verlassen"; | ||
|
||
/* Alert: Authorization to Localization denied */ | ||
"This app requires the location services to be authorised" = "Die Ortungsdienste müssen für diese App zugelassen sein"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* Class = "UIButton"; configuration.title = "Delete"; ObjectID = "pRa-cH-jsG"; */ | ||
"pRa-cH-jsG.configuration.title" = "Löschen"; | ||
|
||
/* Class = "UIButton"; normalTitle = "Button"; ObjectID = "pRa-cH-jsG"; */ | ||
"pRa-cH-jsG.normalTitle" = "Button"; | ||
|
||
/* Class = "UILabel"; text = "Label"; ObjectID = "YxR-jO-lcY"; */ | ||
"YxR-jO-lcY.text" = "Label"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Privacy - Location When In Use Usage Description */ | ||
"NSLocationWhenInUseUsageDescription" = "This is a region monitoring testing app. It needs background location updates"; | ||
"NSLocationAlwaysAndWhenInUseUsageDescription" = "This is a region monitoring testing app. It needs background location updates"; |