Skip to main content

EventKitパーミッション関連

事前準備

  1. Project> General> Frameworks> EventKit.framework
  2. Target> Info> Privacy - Calendars Usage Description (NSCalendarsUsageDescription)
  3. Target> Info> Privacy - Reminders Usage Description (NSRemindersUsageDescription)

NSReminderFullAccessUsageDescription になった

Info.plist ではなく Targets からたどるようになったようだ

  • TODO: ここをローカライズする方法

Deny されると再度ダイアログは出ないので、設定画面に飛ばす必要あり

  • TODO: 設定画面を開く方法 調べる

アクセス

swift
store.requestAccess(to: type) { granted, error in
// ...
}
  • type には EKEntityType を渡す
    • .calendar
    • .reminder

Mac の場合のメモ

以下の設定もオンにする必要あり

  • Targets > Signing & Capabilities > App Sandbox > Calendar

EKEntityType.reminder が反応していない。 -> EKEntityType.calendar で良い?

エラー

上の設定をしたあと iOS でビルドしたらエラーになった。

Entitlements file "xxxxxxx.entitlements" was modified during the build, which is not supported. You can disable this error by setting 'CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION' to 'YES', however this may cause the built product's code signature or provisioning profile to contain incorrect entitlements.

-> メニューから Clean Build Folder すれば良い