Instantly share code, notes, and snippets.

@3DEsprit /app.js
Last active Jun 6, 2018

Embed
What would you like to do?
react-native-calendar-events authorization setup
import RNCalendarEvents from 'react-native-calendar-events'
export default App extends Componemnt {
constructor() {
super();
this.state = {
cal_auth: ''
}
}
componentWillMount ()
// iOS
RNCalendarEvents.authorizationStatus()
.then(status => {
// if the status was previous accepted, set the authorized status to state
this.setState({ cal_auth: status })
if(status === 'undetermined') {
// if we made it this far, we need to ask the user for access
RNCalendarEvents.authorizeEventStore()
.then((out) => {
if(out == 'authorized') {
// set the new status to the auth state
this.setState({ cal_auth: out })
}
})
}
})
.catch(error => console.warn('Auth Error: ', error));
// Android
RNCalendarEvents.authorizeEventStore()
.then((out) => {
if(out == 'authorized') {
// set the new status to the auth state
this.setState({ cal_auth: out })
}
})
.catch(error => console.warn('Auth Error: ', error));
}
...
@ArthurInTheShell

This comment has been minimized.

Copy link

ArthurInTheShell commented Jun 6, 2018

Thanks for writing the tutorial helping me to setup the permission request for Calendar!
I found few things that might need attention.

  1. is 'class ' missed in line3?
  2. will line 11 have curly braces?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment