Created
June 27, 2017 04:16
-
-
Save ArchieR7/85ee0a2d8cdd652d78d6c08eebfd0fae to your computer and use it in GitHub Desktop.
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 = UILocalNotification() | |
notification.alertAction = "推播滑動的動作名稱" | |
notification.alertBody = "推播的內容" | |
notification.alertTitle = "推播的標題" | |
notification.soundName = UILocalNotificationDefaultSoundName | |
// 觸發條件以使用者的位置為主 | |
let region = CLCircularRegion(center: center, radius: radius, identifier: ID) | |
// 可以設定當使用者進入或離開區域的時候,是否要跳出通知 | |
region.notifyOnExit = false | |
region.notifyOnEntry = true | |
// 如上方的寫法便是,當使用者進入範圍內的時候,跳出通知。而離開指定範圍時,則不會跳。 | |
notification.region = region | |
// 設定是否只會通知一次,若為 false 則會每次進入區域都跳通知出來。 | |
notification.regionTriggersOnce = false | |
// 最後可以放一些自己需要的資訊進來 | |
notification.userInfo = ["id": ID] | |
// 最後,放進排程之內。 | |
UIApplication.shared.scheduledLocalNotifications?.append(notification) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment