Getting access to EKCalendar
up vote
0
down vote
favorite
In my app, I have a switch that allows the user to put certain events in their agenda. I handle that as such:
@IBAction func putInAgenda(_ sender: UISwitch)
let store = manager.store
if (sender.isOn)
store.requestAccess(to: EKEntityType.event, completion:
(accessGranted: Bool, error: Error?) in
if accessGranted == true
self.eventsHandler.importEventsInAgenda(id)
else
DispatchQueue.main.async
sender.isOn = false
)
else
//
shared?.set(sender.isOn, forKey: "putInAgenda")
shared?.synchronize()
However, against my expectation, "store.requestAccess" not only requests, but also SETS.
As a result, when the user CANCELS the dialog, the switch switches back (expected) but any consecutive attempt to switch the switch to the ON position is honored with an OFF position, without a new dialog.
What should I do?
swift calendar access
add a comment |
up vote
0
down vote
favorite
In my app, I have a switch that allows the user to put certain events in their agenda. I handle that as such:
@IBAction func putInAgenda(_ sender: UISwitch)
let store = manager.store
if (sender.isOn)
store.requestAccess(to: EKEntityType.event, completion:
(accessGranted: Bool, error: Error?) in
if accessGranted == true
self.eventsHandler.importEventsInAgenda(id)
else
DispatchQueue.main.async
sender.isOn = false
)
else
//
shared?.set(sender.isOn, forKey: "putInAgenda")
shared?.synchronize()
However, against my expectation, "store.requestAccess" not only requests, but also SETS.
As a result, when the user CANCELS the dialog, the switch switches back (expected) but any consecutive attempt to switch the switch to the ON position is honored with an OFF position, without a new dialog.
What should I do?
swift calendar access
Unrelated but the call tosynchronize
is obsolete. See its documentation.
– rmaddy
Nov 10 at 17:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In my app, I have a switch that allows the user to put certain events in their agenda. I handle that as such:
@IBAction func putInAgenda(_ sender: UISwitch)
let store = manager.store
if (sender.isOn)
store.requestAccess(to: EKEntityType.event, completion:
(accessGranted: Bool, error: Error?) in
if accessGranted == true
self.eventsHandler.importEventsInAgenda(id)
else
DispatchQueue.main.async
sender.isOn = false
)
else
//
shared?.set(sender.isOn, forKey: "putInAgenda")
shared?.synchronize()
However, against my expectation, "store.requestAccess" not only requests, but also SETS.
As a result, when the user CANCELS the dialog, the switch switches back (expected) but any consecutive attempt to switch the switch to the ON position is honored with an OFF position, without a new dialog.
What should I do?
swift calendar access
In my app, I have a switch that allows the user to put certain events in their agenda. I handle that as such:
@IBAction func putInAgenda(_ sender: UISwitch)
let store = manager.store
if (sender.isOn)
store.requestAccess(to: EKEntityType.event, completion:
(accessGranted: Bool, error: Error?) in
if accessGranted == true
self.eventsHandler.importEventsInAgenda(id)
else
DispatchQueue.main.async
sender.isOn = false
)
else
//
shared?.set(sender.isOn, forKey: "putInAgenda")
shared?.synchronize()
However, against my expectation, "store.requestAccess" not only requests, but also SETS.
As a result, when the user CANCELS the dialog, the switch switches back (expected) but any consecutive attempt to switch the switch to the ON position is honored with an OFF position, without a new dialog.
What should I do?
swift calendar access
swift calendar access
asked Nov 10 at 16:54
Sjakelien
87521129
87521129
Unrelated but the call tosynchronize
is obsolete. See its documentation.
– rmaddy
Nov 10 at 17:08
add a comment |
Unrelated but the call tosynchronize
is obsolete. See its documentation.
– rmaddy
Nov 10 at 17:08
Unrelated but the call to
synchronize
is obsolete. See its documentation.– rmaddy
Nov 10 at 17:08
Unrelated but the call to
synchronize
is obsolete. See its documentation.– rmaddy
Nov 10 at 17:08
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
A privacy request is only ever asked once. If you detect that it is currently denied, you could either update the UI or prompt the user to go to Settings and turn it on. You can use UIApplication openSettingsURLString
and UIApplication openURL
to take the user to your app's settings page in the Settings app.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
A privacy request is only ever asked once. If you detect that it is currently denied, you could either update the UI or prompt the user to go to Settings and turn it on. You can use UIApplication openSettingsURLString
and UIApplication openURL
to take the user to your app's settings page in the Settings app.
add a comment |
up vote
0
down vote
accepted
A privacy request is only ever asked once. If you detect that it is currently denied, you could either update the UI or prompt the user to go to Settings and turn it on. You can use UIApplication openSettingsURLString
and UIApplication openURL
to take the user to your app's settings page in the Settings app.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
A privacy request is only ever asked once. If you detect that it is currently denied, you could either update the UI or prompt the user to go to Settings and turn it on. You can use UIApplication openSettingsURLString
and UIApplication openURL
to take the user to your app's settings page in the Settings app.
A privacy request is only ever asked once. If you detect that it is currently denied, you could either update the UI or prompt the user to go to Settings and turn it on. You can use UIApplication openSettingsURLString
and UIApplication openURL
to take the user to your app's settings page in the Settings app.
answered Nov 10 at 17:07
rmaddy
235k27305371
235k27305371
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241222%2fgetting-access-to-ekcalendar%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Unrelated but the call to
synchronize
is obsolete. See its documentation.– rmaddy
Nov 10 at 17:08