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
import CoreLocation | |
struct LocationNotificationInfo { | |
// Identifiers | |
let notificationId: String | |
let locationId: String | |
// Location | |
let radius: Double |
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
// | |
// LocationNotificationScheduler.swift | |
// LocationNotifier | |
// | |
// Created by Jonathan Samudio on 5/8/19. | |
// Copyright © 2019 Jonathan Samudio. All rights reserved. | |
// | |
import CoreLocation | |
import UserNotifications |
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
// Setup request and add request to the Notification Center. | |
let request = UNNotificationRequest(identifier: "destination_notif_id", | |
content: notification, | |
trigger: trigger) | |
UNUserNotificationCenter.current().add(request, withCompletionHandler: { error in | |
if error == nil { | |
print("Successfully Added") | |
print(request) | |
} else { |
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
let notification = UNMutableNotificationContent() | |
notification.title = "Welcome!" | |
notification.body = "You are in a custom circular region" | |
notification.sound = UNNotificationSound.default | |
notification.userInfo = ["destinationId": 1234] |
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
let center = CLLocationCoordinate2D(latitude: 40.700212, longitude: -73.987238) | |
let region = CLCircularRegion(center: center, radius: 2000.0, identifier: "unique_location_id") | |
region.notifyOnEntry = true | |
region.notifyOnExit = false | |
let trigger = UNLocationNotificationTrigger(region: region, repeats: false) |
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
let notificationCenter = UNUserNotificationCenter.current() | |
let options: UNAuthorizationOptions = [.alert, .sound, .badge] | |
notificationCenter.requestAuthorization(options: options, completionHandler: { (granted, error) in | |
// Check if user granted location permissions here. | |
}) |
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
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key> | |
<string>Location description</string> | |
<key>NSLocationWhenInUseUsageDescription</key> | |
<string>Location description</string> | |
<key>NSLocationAlwaysUsageDescription</key> | |
<string>Location description</string> | |
<key>NSLocationUsageDescription</key> | |
<string>Location description</string> |
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
import CoreLocation | |
import UserNotifications | |
final class GeoLocationNotificationProvider: NSObject { | |
// MARK: - Private Properties | |
// Made By We's coordinates center | |
private let officeCenterLocation = CLLocationCoordinate2D(latitude: 40.739357, longitude: -73.989711) | |
private let locationManager = CLLocationManager() |
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
// | |
// CredentialValidator.swift | |
// UnitTesting | |
// | |
// Created by Jonathan Samudio on 1/21/19. | |
// Copyright © 2019 Jonathan Samudio. All rights reserved. | |
// | |
import Foundation |
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
// | |
// SampleEdgeCase.swift | |
// UnitTesting | |
// | |
// Created by Jonathan Samudio on 1/21/19. | |
// Copyright © 2019 Jonathan Samudio. All rights reserved. | |
// | |
import Foundation |