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

Not able to save events to calendar in Android 13 #438

Open
anshdroid opened this issue May 22, 2023 · 3 comments
Open

Not able to save events to calendar in Android 13 #438

anshdroid opened this issue May 22, 2023 · 3 comments

Comments

@anshdroid
Copy link

anshdroid commented May 22, 2023

Using react-native-calendar-events latest version, Events are saved up to Android 12 and work well with iOS. But the same thing fails with Android 13.

Got success while writing events with event id but not visible in the default Calendar.

Environment

React Native: 0.66.3
React: 17.0.2
react-native-calendar-events: 2.2.0

Steps to Reproduce

import RNCalendarEvents from "react-native-calendar-events";

Request for permission

      RNCalendarEvents.requestPermissions(true).then(req => {
        // permission granted
      });

When permission is authorized

RNCalendarEvents.saveEvent(title,calParam, {})
    .then(value => {
// this block is executed when for success
    })
    .catch(error => {
 //error
    });

Even though checked for permissions too when saving events to the calendar, it says authorized for both Read and Write.

Run this in Android 13

Actual Behavior

error: you don't have permissions to add an event to the users calendar

Getting this error when saving the events to it.

Even tried with the calendar id to which modifications are allowed.

@anshdroid anshdroid changed the title Not able to write events to calendar in Android 13 Not able to save events to calendar in Android 13 May 22, 2023
@anshdroid
Copy link
Author

anshdroid commented May 23, 2023

Got to fix this issue.

In Android 13, it is seen that the end date must be one day after the start date. Therefore, the start and end dates cannot be the same.

But still getting this error in real device

Error: you don't have permissions to add an event to the users calendar

@anshdroid anshdroid reopened this May 23, 2023
@xdarkleonx
Copy link

Is this fixef? Any ideas how to fix this?

@anshdroid
Copy link
Author

anshdroid commented Jun 16, 2023

Is this fixef? Any ideas how to fix this?

Yes, Got to fix the issue somehow.

While asking for permission set the readOnly flag to false

    RNCalendarEvents.requestPermissions(false).then(req => {
       /** BODY */
    });

    RNCalendarEvents.findCalendars().then(resp => {
          // allowedCalPermission?.id;
    });

Add calendar id to the "RNCalendarEvents.saveEvent" along with the title

    const eventId = await RNCalendarEvents.saveEvent(data?.title, data?.calParam, {})
      .then(value => {
        return new Promise((resolve, reject) => {
          resolve(value);
        });
      })
      .catch(error => {
        console.log("error: ", error);
      });

If you are checking with the permission granted or not check with readOnly flag as true

RNCalendarEvents.checkPermissions(true)

Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants