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

you don't have permissions to add an event to the users calendar #147

Closed
rodrigofbm opened this issue May 21, 2018 · 10 comments
Closed

you don't have permissions to add an event to the users calendar #147

rodrigofbm opened this issue May 21, 2018 · 10 comments

Comments

@rodrigofbm
Copy link

rodrigofbm commented May 21, 2018

Environment

OS: Linux 4.13
Node: 9.10.1
Yarn: 1.6.0
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Steps to Reproduce

Add new event to calendar

Expected Behavior

Add new event to calendar

Actual Behavior

Possible Unhandled Promise Rejection (id: 0):
Error: you don't have permissions to retrieve an event to the users calendar
createErrorFromErrorData@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2039:17
fn/</<@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:1991:27
__invokeCallback@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2433:9
invokeCallbackAndReturnFlushedQueue/<@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2178:11
__guardSafe@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2346:11
invokeCallbackAndReturnFlushedQueue@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2177:9
onmessage@http://localhost:8081/debugger-ui/debuggerWorker.js:70:25
Possible Unhandled Promise Rejection (id: 1):
Error: you don't have permissions to add an event to the users calendar
createErrorFromErrorData@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2039:17
fn/</<@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:1991:27
__invokeCallback@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2433:9
invokeCallbackAndReturnFlushedQueue/<@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2178:11
__guardSafe@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2346:11
invokeCallbackAndReturnFlushedQueue@blob:http://localhost:8081/6f5fdccd-b770-44d4-97c5-a9d63e0414ef:2177:9
onmessage@http://localhost:8081/debugger-ui/debuggerWorker.js:70:25

settings.gradle

rootProject.name = 'PetShop'
include ':react-native-calendar-events'
project(':react-native-calendar-events').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-calendar-events/android')

include ':app'

build.gradle

dependencies {
    compile project(':react-native-calendar-events')
...
    
}

MainActivity.java

package com.petshop;

import com.facebook.react.ReactActivity;
import com.calendarevents.CalendarEventsPackage;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "PetShop";
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        CalendarEventsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.petshop">
  ...
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
   ...

</manifest>

Can someone help me? I can't see what I did wrong

@wmcmahan
Copy link
Owner

Hey @rodrigofbm, which Android SDK is your app targeting? If 23+, you will need to have the app request permission:

RNCalendarEvents.authorizeEventStore()

@fachrinfl
Copy link

fachrinfl commented Jun 28, 2018

hello @rodrigofbm , how cant i use RNCalendarEvents.authorizeEventStore() for target api 27, i tried but no working

import Permissions from 'react-native-permissions';
import RNCalendarEvents from 'react-native-calendar-events';

requestPermission () {
      console.log('*** _requestPermission');
      Permissions.checkMultiple([ 'eventWrite']).then((response) => {
        console.log(response);
        if (response.eventWrite === 'undetermined') {
          Permissions.request('eventWrite').then((response) => {
            console.log(response);
            this.createEvent(response);
          });
        }
      });
    }

createEvent = async (respone) => {
      if (respone === 'authorized') {
        await RNCalendarEvents.authorizeEventStore();
        await RNCalendarEvents.saveEvent('Pinjam Modal Event', {
          calendarId: '141',
          startDate: '2018-06-29T19:26:00.000Z',
          endDate: '2018-06-30T19:26:00.000Z'
        });
      }
    }

@confusingbits
Copy link

@fachrinfl I was missing

import com.calendarevents.CalendarEventsPackage;

public class MainActivity extends ReactActivity {
  ...

  @Override
  public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
      CalendarEventsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }

  ...
}

from the installation docs.

@wmcmahan wmcmahan closed this as completed Apr 8, 2019
@jsuhangita
Copy link

@wmcmahan bro i get this error again in 2020, do i still need RNCalendarEvents.authorizeEventStore()
?

altough i tried it, the function are undefined

@MoOx
Copy link
Collaborator

MoOx commented Nov 30, 2020

bro you still need to read the doc in 2020 https://github.com/wmcmahan/react-native-calendar-events#api

@jsuhangita
Copy link

bro you still need to read the doc in 2020 https://github.com/wmcmahan/react-native-calendar-events#api

i already implement it, working fine on ios, but i did not get permission to add an event on android. im already set targetSDKversion>23. the pop up permission appears but after i choose allow, the permission status on checkPermission() method return 'restricted'. and requestAuthorization() return 'denied'. any ideas?

@wmcmahan
Copy link
Owner

@jsuhangita It's difficult to know why your permissions are denied without knowing the full context of your use. Also, requestPermissions is the method used to prompt the permissions acceptance. If permission is denied, I believe it will remain denied unless specifically changed in the app's settings.

@mubashiralisiddiqui
Copy link

I have the same error in Android while saving the events in the android calendar working fine in Ios
Error: you don't have permissions to add an event to the users calendar
"react-native-calendar-events": "^2.1.2"
"react-native": "0.63.3"

@mubashiralisiddiqui
Copy link

@wmcmahan can we please re open this issue

@DavidAPears
Copy link

The iOS seems fine, but i am also getting

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

on Android

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

8 participants