Skip to content

Instantly share code, notes, and snippets.

import UIKit
import Firebase
import FirebaseAuth
class ViewController: UIViewController {
var microsoftProvider : OAuthProvider?
let kGraphURI = "https://graph.microsoft.com/v1.0/me/"
override func viewDidLoad() {
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
<?xml version="1.0"?>
<gpx version="1.1">
<wpt lat="35.658626" lon="139.745471">
</wpt>
</gpx>
func isAllowReceiveNotification() -> Bool{
var isAllow = true
notificationCenter.getNotificationSettings { (settings) in
// Do not schedule notifications if not authorized.
if (settings.authorizationStatus != .authorized || settings.alertSetting != .enabled){
isAllow = false
}
func setupLocalNotificationByRegion(){
if !isAllowReceiveNotification() {
return
}
// setup notification content
let content = UNMutableNotificationContent()
content.title = "Tokyo Tower"
content.body = "Welcome to Tokyo Tower, A symbol of Japan's post-war rebirth as a major economic power!"
func setupUserNotificationCenter(){
notificationCenter.delegate = self
// request to receive notification
notificationCenter.requestAuthorization(options: [.alert, .sound, .badge, .carPlay], completionHandler: { (granted, error) in
if (error != nil) {
print("Notification Authorization Error: " + error!.localizedDescription)
}else{
func setupLocationManager(){
if CLLocationManager.authorizationStatus() != CLAuthorizationStatus.authorizedAlways{
// Request to get alwayls location authorization
locationManager.requestAlwaysAuthorization()
}
// set delegate for location manager
locationManager.delegate = self
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) {
let span = MKCoordinateSpan(latitudeDelta: 0.001, longitudeDelta: 0.001)
let region = MKCoordinateRegion(center: userLocation.coordinate, span: span)
mapView.region = region
}
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let circleRenderer = MKCircleRenderer(overlay: overlay)
circleRenderer.strokeColor = UIColor(red: 66/255, green: 133/255, blue: 244/255, alpha: 0.80)
circleRenderer.lineWidth = 1.0
circleRenderer.fillColor = UIColor(red: 66/255, green: 133/255, blue: 244/255, alpha: 0.20)
return circleRenderer
}