Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios flutter: PlatformException(401, The user has not allowed this application to modify their calendar(s), null, null) #485

Closed
FangPro opened this issue May 8, 2023 · 10 comments
Labels
bug Something isn't working more information required The issue requires more information before it can be actioned

Comments

@FangPro
Copy link

FangPro commented May 8, 2023

I ran my program on the iOS simulator, but this error occurred

flutter: PlatformException(401, The user has not allowed this application to modify their calendar(s), null, null)

This is my code:
`void createAlarmCalendar({required ScheduleModel model}) async{
var hasPermissions = await DeviceCalendarPlugin().hasPermissions();
if(hasPermissions.isSuccess){
_createEvent(model: model);
} else {
await DeviceCalendarPlugin().requestPermissions().then((result){
if(result.isSuccess){
_createEvent(model: model);
}
});
}
}

_createEvent({required ScheduleModel model}) async{
await DeviceCalendarPlugin().createOrUpdateEvent(Event(
calenderId,
eventId: model.id!,
title: "${model.course!}直播课",
start: TZDateTime.fromMillisecondsSinceEpoch(tz.local, model.liveStart!),
end: TZDateTime.fromMillisecondsSinceEpoch(tz.local, model.liveEnd!),
availability: Availability.Free,
attendees: [],
allDay: false,
status: EventStatus.Tentative,
location: tz.local.name,
reminders: [],
)).then((result){
if(result!.data!=null&&result.data!=""){
debugPrint(result.data!);
isCalendars = true;
StorageManage.sp!.setString(model.id!, result.data!);
bus.emit("REFRESH_CALENDAR");
ToastUtil.showText("当前直播提醒已开启");
notifyListeners();
} else {
ToastUtil.showText("当前直播提醒开启失败");
}
});
}`

@FangPro FangPro added the bug Something isn't working label May 8, 2023
@IVLIVS-III
Copy link
Contributor

@FangPro have you checked that the calendar you are trying to modify is not readonly?

@IVLIVS-III IVLIVS-III added the more information required The issue requires more information before it can be actioned label May 8, 2023
@FangPro
Copy link
Author

FangPro commented May 8, 2023

This is the calendar on the iOS simulator. What additional information do I need to provide

@IVLIVS-III
Copy link
Contributor

well, when calling retrieveCalendars, how many calendars are returned?

@IVLIVS-III
Copy link
Contributor

Did you follow the steps to integrate iOS?

@FangPro
Copy link
Author

FangPro commented May 8, 2023

Step configuration for integrating iOS:
`NSCalendarsUsageDescription
Access most functions for calendar viewing and editing.

NSContactsUsageDescription
Access contacts for event attendee editing.`
Do I need any additional configurations?

@FangPro
Copy link
Author

FangPro commented May 15, 2023

Hello author, it's my problem. I have summarized the following reasons:

  1. Before creating an event on iOS, it is necessary to directly request permissions, rather than first determining whether permissions exist
  2. Before creating an event, you need to traverse and query the calendar to obtain a specified calendar ID
  3. In the creation event method parameters, do not specify the event ID yourself. The callback method for creating the event will help us return
    The above is what I have found to be worth noting. Thank you to the plugin author.

@FangPro FangPro closed this as completed May 15, 2023
@mbcHans
Copy link

mbcHans commented Apr 17, 2024

Hello author, it's my problem. I have summarized the following reasons:

  1. Before creating an event on iOS, it is necessary to directly request permissions, rather than first determining whether permissions exist
  2. Before creating an event, you need to traverse and query the calendar to obtain a specified calendar ID
  3. In the creation event method parameters, do not specify the event ID yourself. The callback method for creating the event will help us return
    The above is what I have found to be worth noting. Thank you to the plugin author.

Hi, how did you solve this issue? I meet this problem too.

@FangPro
Copy link
Author

FangPro commented Apr 17, 2024 via email

@mbcHans
Copy link

mbcHans commented Apr 18, 2024

Hello author, it's my problem. I have summarized the following reasons: Before creating an event on iOS, it is necessary to directly request permissions, rather than first determining whether permissions exist Before creating an event, you need to traverse and query the calendar to obtain a specified calendar ID In the creation event method parameters, do not specify the event ID yourself. The callback method for creating the event will help us return The above is what I have found to be worth noting. Thank you to the plugin author. Hi, how did you solve this issue? I meet this problem too.

Yes, same error log happened on iOS platform.

@FangPro
Copy link
Author

FangPro commented Apr 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more information required The issue requires more information before it can be actioned
Projects
None yet
Development

No branches or pull requests

3 participants