CNContactStore authorization status check triggers user permission dialog

Originator:dk
Number:rdar://34158737 Date Originated:August 30 2017
Status:Open Resolved:
Product:macOS + SDK Product Version:
Classification:Bug Reproducible:Always
 
Summary:
Calling class method `CNContactStore .authorizationStatus(for entityType: CNEntityType)` triggers permission dialog when the status is `notDetermined`. This should not happen because according to the documentation "Based upon the access, the application could display or hide its UI elements". In current implementation it is not possible to show a button only when state is `notDetermined`.

Steps to Reproduce:
Add button to the window. Change button’s title according to the current authorization status.

let status = CNContactStore.authorizationStatus(for: .contacts)
button.title = status == .notDetermined ? "Not determined" : "Determined"

Expected Results:
The button’s title is "Not determined".

Observed Results:
The button’s title is "Not determined", but there is a dialog asking the user for contacts permission and the app is blocked.

Version:
macOS Sierra Version 10.12.6.

Attached project:
New macOS project with a button added to the main window. 
Code in AppDelegate.swift:

import Cocoa
import Contacts

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!
    @IBOutlet weak var button: NSButton!

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        let status = CNContactStore.authorizationStatus(for: .contacts)
        button.title = status == .notDetermined ? "Not determined" : "Determined"
    }
}

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!