Comments (3)
Hey @Prudwell, are you waiting for the authorizeEventStore
methods promise to fulfill before trying to save the event?
from react-native-calendar-events.
Yes sir, the render function shouldn't even display the option to save a new event unless the authorizeEventStore has fulfilled as authorized in the componentDidMount
componentDidMount() {
RNCalendarEvents.authorizationStatus()
.then(status => {
this.setState({authorizationStatus: status})
if(status == 'undetermined'){
RNCalendarEvents.authorizeEventStore()
.then((res) => {
if(res == "authorized"){
this.setState({authorizationStatus: res})
}
})
}
})
.catch(error => {
// handle error
});
}
render(){
if(this.state.authorizationStatus == "authorized") {
let singleItemFromState = this.props.items.get(this.props.rowID)
return (
<Animated.View key={this.props.reminderObject.reminderRowID}
style={[styles.container, {backgroundColor: "rgba(52,52,52,0.5)"},
{transform: [{translateY: this.state.offset}]}]}>
<View style={{
width: 450,
height: 320,
justifyContent: "center",
alignItems: "center",
backgroundColor: "white"
}}>
<DatePickerIOS
style={{height: 200, width: 450}}
date={this.state.dateValue}
mode="datetime"
minuteInterval={1}
onDateChange={(newDateObject) => this.setState({dateValue: newDateObject})}
/>
<View style={{flexDirection:"row", justifyContent:"space-between"}}>
<Button style={appStyle.itemReminderButton} onPress={this.closeModal.bind(this)}>Go back</Button>
<Button style={[appStyle.itemReminderButton]}
onPress={this.deleteAndCloseModal.bind(this, singleItemFromState, this.props.reminderObject.reminderRowID, this.state)}>Delete</Button>
<Button style={appStyle.itemReminderButton}
onPress={this.saveAndCloseModal.bind(this, singleItemFromState, this.props.reminderObject.reminderRowID, this.state)}>Save</Button>
</View>
</View>
</Animated.View>
);
}
else{
return(
//some code displaying a link to the iOS settings to enable calendar permission
)
}
}
Even more strange is that this appears to be intermittent (oh joy). I can delete that app in simulator, reinstall it via xcode, complete the authorizeEventStore()
action, and sometimes it works right away, other times it throws the promise rejection until I restart the app.
Possible Unhandled Promise Rejection (id: 1):
No calendar has been set.
Error: No calendar has been set.
at createErrorFromErrorData (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7245:11)
at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7208:35
at MessageQueue.__invokeCallback (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7593:10)
at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7444:8
at guard (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7363:1)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7443:1)
at http://localhost:8081/debuggerWorker.js:71:58
The function that saves the event is now wrapped with RNCalendarEvents.authorizationStatus
and it shows the status as authorized even when it throws that no calendar set promise rejection.
I'll update if I find anything new
from react-native-calendar-events.
Alright it seems to be caused by another part of my code that's running on an interval. When my app starts up, it attempts to sync events that it sees in its own database with the events stored in iOS calendar events. That interval attempted to read and save events with no regard for authorizationStatus()
and when those failed it somehow made it impossible to save events even after I completed authorizeEventStore()
.
I don't know how those failures caused future actions to fail (maybe not catching those promise rejections properly) but it's been resolved by just wrapping that code in authorizationStatus()
and only running when authorized
.
The intermittency of the issue for me I believe depended on whether I authorized the event store before that interval ran.
from react-native-calendar-events.
Related Issues (20)
- [Error: Calendar entityType (null) is not supported]
- Android 9/10 - not saving to google calendar, no errors, no crashing HOT 3
- Is this library going to support web anytime in the future or does it already?
- Unable to save calendar event in Android. HOT 3
- Unable to use API on Android - "TypeError: null is not an object" for every API call HOT 2
- Ios Event Date Time wrong and confused HOT 1
- The application will crash when I set some items of the Recurrence rule
- Add event status property
- How to remove default 30mins reminder for event entry?
- when the next version will be released? the (long) addEvent is needed
- Error: you don't have permissions to add an event to the users calendar
- Events overlap not coming in horizontal direction
- Not able to save events to calendar in Android 13 HOT 3
- iOS 17 issues: unable to request permissions HOT 26
- Type error when updating event without startDate
- Events Saved on Wrong Calendar with No Alarm - Android HOT 1
- Ar you having write issues on Android, read this? HOT 2
- Patch for recurring events in Android HOT 1
- Problems with iOS 17 HOT 2
- Any alternatives or update plan? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-calendar-events.