Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

setting a local notification at specific time every day swift

let notificationContent = UNMutableNotificationContent()
notificationContent.title = "Title"
notificationContent.body = "This is a test"
notificationContent.badge = NSNumber(value: 1)
notificationContent.sound = .default

var datComp = DateComponents()
datComp.hour = 8
datComp.minute = 0
let trigger = UNCalendarNotificationTrigger(dateMatching: datComp, repeats: true)
let request = UNNotificationRequest(identifier: "ID", content: notificationContent, trigger: trigger)
                UNCenter.add(request) { (error : Error?) in
                    if let theError = error {
                        print(theError as! String)
                    }
                }
Comment

PREVIOUS NEXT
Code Example
Swift :: swift check if array values are equal 
Swift :: swift split string into array of 2 characters 
Swift :: swift double v float 
Swift :: and or in swift 
Swift :: Swift for-in Loop 
Swift :: make text autoresize swiftui 
Swift :: sort list ios swift 
Swift :: adding label to navigation bar 
Swift :: string to array swift 
Swift :: two integer variable in swift 
Swift :: swift protocols 
Swift :: Swift Omit Argument Labels 
Swift :: bold world in text swift 
Swift :: Swift Access Struct Properties Swift 
Swift :: rotate sfsymbol horizontal flip swiftui 
Swift :: ios tableview hide empty cells 
Swift :: swift if let 
Swift :: on edit input field provide default value if textfield get empty swift 
Swift :: how to get list of value from specific keys in array object in swift 
Swift :: Swift Find Number of Dictionary Elements 
Swift :: Swift String and Character Literals 
Swift :: How to Hide Password in Text field Swift 
Swift :: swift overlay view 
Swift :: enum Associated Values Swift 
Swift :: allowed filename characters swift 
Ruby :: ruby string to date 
Ruby :: how to check ruby version 
Ruby :: rails validators 
Ruby :: ruby check if a file exists 
Ruby :: ruby unshift method 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =