macOS, iOS

[iOS] push alert λ³΄λ‚΄λŠ” 법: UserNotifications

SweetDev 2019. 5. 11. 00:47
import UserNotifications

func goPushAlarm(){
        let content = UNMutableNotificationContent()
        content.title = "πŸŽ™βœ¨κ°•μ˜ λ…ΉμŒν•  μ‹œκ°„μ΄μ—μš”πŸŽ™βœ¨"
        content.subtitle = "μ§€κΈˆμ€ 미적뢄학 μˆ˜μ—…μ„ λ…ΉμŒν•  μ‹œκ°„μž…λ‹ˆλ‹€! μ‹œν—˜κΈ°κ°„μ„ μœ„ν•΄μ„œ 미리 λ…ΉμŒν•΄μ£Όμ„Έμš”πŸ˜š"
        content.body = "11:00 AM ~ 1:00 PM 미적뢄학"
        
        
        var date = DateComponents()
        date.hour = 00
        date.minute = 40
        let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)
        let request = UNNotificationRequest(identifier: "timerdone", content: content, trigger: trigger)
        UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
    }

    

μ΄λŸ°μ‹μœΌλ‘œ 짜면 λœλ‹€ :)