Skip to content

Instantly share code, notes, and snippets.

@chengyang1380
Created April 9, 2018 14:50
Show Gist options
  • Save chengyang1380/aa7a0bcf588b837f4ff111302a75d1f2 to your computer and use it in GitHub Desktop.
Save chengyang1380/aa7a0bcf588b837f4ff111302a75d1f2 to your computer and use it in GitHub Desktop.
// 創建觸發條件,這裡是設定每天8:30
var date = DateComponents()
date.hour = 8
date.minute = 30
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)
// 創建觸發條件,這裡是設定座標經緯度
let center = CLLocationCoordinate2D(latitude: 37.335400, longitude: -122.009201)
let region = CLCircularRegion(center: center, radius: 2000.0, identifier: "Headquarters")
region.notifyOnEntry = true
region.notifyOnExit = false
let trigger = UNLocationNotificationTrigger(region: region, repeats: false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment