Skip to content

Instantly share code, notes, and snippets.

@susanna2222
Last active August 21, 2019 05:59
Show Gist options
  • Save susanna2222/84f60d92e2bbc22951e9f4922ec128fe to your computer and use it in GitHub Desktop.
Save susanna2222/84f60d92e2bbc22951e9f4922ec128fe to your computer and use it in GitHub Desktop.
import UIKit
import CoreLocation
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate, UNUserNotificationCenterDelegate{
var window: UIWindow?
let locationManager = CLLocationManager()
let notificationCenter = UNUserNotificationCenter.current()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
}
// called if app is running in foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// show alert while app is running in foreground
return completionHandler(UNNotificationPresentationOptions.alert)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment