Calendar does not open to date specified in URL unless it is already running

Originator:haugen.brandon
Number:rdar://41604453 Date Originated:June 28, 2018
Status:Open Resolved:
Product:iOS+SDK Product Version:11.4
Classification:Bug Reproducible:Always
 
Area:
Calendar

Summary: While the Calendar app is not listed on the Apple URL schemes page (https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html) it seems to be known that the Calendar can be opened using a URL. When doing so though the Calendar does not open to the specified date unless it is already in the background. If the Calendar is not in the background then the Calendar opens to the current date.

Also see this Stackoverflow post : https://stackoverflow.com/questions/48524378/swift-open-calendar-to-a-specific-date

Steps to Reproduce: Use the following code with a Date object initialized to any date that is not the current date while the Calendar app is not open (in the foreground/background)

let interval = date.timeIntervalSinceReferenceDate
let url = URL(string: "calshow:\(interval)")!

if #available(iOS 10.0, *) {
    UIApplication.shared.open(url, options: [:], completionHandler: {
        (success) in
        if success == false {
            let alert = UIAlertController(title: "Error", message: "Could not open Calendar.", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
            self.present(alert, animated: true, completion: nil)
        }
    })
} else {
    // Fallback on earlier versions
    if !UIApplication.shared.openURL(url) {
        let alert = UIAlertController(title: "Error", message: "Could not open Calendar.", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }
}

Expected Results: Calendar app opens to the date specified in the URL


Actual Results: Calendar app opens to the current date


Version/Build: iOS 11.4 and earlier


Configuration:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!