首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EKEventStore请求访问不起作用

EKEventStore请求访问不起作用
EN

Stack Overflow用户
提问于 2015-11-25 03:24:39
回答 2查看 2K关注 0票数 1

EKEventStore eventStore: var?

代码语言:javascript
复制
@IBAction func bbbbbbb(sender: UIButton) {
        if eventStore == nil {
            eventStore = EKEventStore()
        }
        self.eventStore?.requestAccessToEntityType(EKEntityType.Event, completion: { (aBool, error) -> Void in
            print(error, aBool)
        })
}

打印结果为零,始终为假...它的行为就像用户已经拒绝了访问,但提示永远不会显示。当然,相同的代码可以在相同设备上的新空白应用程序中运行。我尝试过的事情:在设备上休息设置,模拟器,使用一个从未安装过应用程序的新设备,当然还有清理项目,但没有成功。另外,在应用程序设置中,日历权限也没有显示出来。你知道是怎么回事吗?

EN

回答 2

Stack Overflow用户

发布于 2016-09-30 23:30:43

使用iOS 10时,您需要在plist中添加以下密钥,以允许应用程序访问日历(否则,应用程序将在请求访问时崩溃):

代码语言:javascript
复制
key: "Privacy - Calendars Usage Description"
value: "$(PRODUCT_NAME) calendar events"

请看这里:

https://iosdevcenters.blogspot.com/2016/09/infoplist-privacy-settings-in-ios-10.html

票数 7
EN

Stack Overflow用户

发布于 2016-09-26 06:30:17

尝试以下代码

代码语言:javascript
复制
    let eventStore = EKEventStore()
    eventStore.requestAccessToEntityType(EKEntityType.Event) { (granted: Bool, error: NSError?) -> Void in

        if granted{
            print("Got access")
            let defaultCalendar = eventStore.defaultCalendarForNewEvents
            print("\(defaultCalendar.calendarIdentifier)")
        }else{
            print("The app is not permitted to access reminders, make sure to grant permission in the settings and try again")
        }
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33902113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档