-
Notifications
You must be signed in to change notification settings - Fork 266
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
Comments
@FangPro have you checked that the calendar you are trying to modify is not readonly? |
This is the calendar on the iOS simulator. What additional information do I need to provide |
well, when calling |
Did you follow the steps to integrate iOS? |
Step configuration for integrating iOS: NSContactsUsageDescription |
Hello author, it's my problem. I have summarized the following reasons:
|
Hi, how did you solve this issue? I meet this problem too. |
Have you encountered the same error message? On which platform, Android or iOS?
…------------------ 原始邮件 ------------------
发件人: "builttoroam/device_calendar" ***@***.***>;
发送时间: 2024年4月17日(星期三) 下午5:16
***@***.***>;
抄送: "Billows Bear ***@***.***>;"State ***@***.***>;
主题: Re: [builttoroam/device_calendar] ios flutter: PlatformException(401, The user has not allowed this application to modify their calendar(s), null, null) (Issue #485)
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.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
Yes, same error log happened on iOS platform. |
Have you applied for permission before creating a subscription event,Then you can take a look at my code below:
_createEvent({required ScheduleModel model}) async{
var currentLocation = getLocation(await FlutterNativeTimezone.getLocalTimezone());
setLocalLocation(currentLocation);
await DeviceCalendarPlugin().retrieveCalendars().then((list) async{
if(list.data!.isNotEmpty){
for(var v in list.data!){
debugPrint("name===>${v.name!}");
debugPrint("id===>${v.id!}");
debugPrint("accountName===>${v.accountName!}");
debugPrint("accountType===>${v.accountType!}");
debugPrint("isReadOnly===>${v.isReadOnly!}");
debugPrint("isDefault===>${v.isDefault!}");
if(v.isDefault! && !v.isReadOnly!){
calenderId = v.id!;
} else if(v.accountType == "LOCAL"){
calenderId = v.id!;
}
}
}
debugPrint("calenderId-------------->$calenderId");
await DeviceCalendarPlugin().createOrUpdateEvent(Event(
calenderId,
title: "${model.course!}直播课",
start: TZDateTime.fromMillisecondsSinceEpoch(currentLocation, model.liveStart!),
end: TZDateTime.fromMillisecondsSinceEpoch(currentLocation, model.liveEnd!),
availability: Availability.Free,
attendees: [],
allDay: false,
status: EventStatus.Confirmed,
location: currentLocation.name,
reminders: [
Reminder(minutes: 60),
Reminder(minutes: 30),
Reminder(minutes: 10),
Reminder(minutes: 5),
],
)).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("当前直播提醒开启失败");
}
});
});
}
…------------------ 原始邮件 ------------------
发件人: "builttoroam/device_calendar" ***@***.***>;
发送时间: 2024年4月18日(星期四) 上午9:34
***@***.***>;
抄送: "Billows Bear ***@***.***>;"State ***@***.***>;
主题: Re: [builttoroam/device_calendar] ios flutter: PlatformException(401, The user has not allowed this application to modify their calendar(s), null, null) (Issue #485)
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.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>
|
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("当前直播提醒开启失败");
}
});
}`
The text was updated successfully, but these errors were encountered: