Skip to content

Commit 3426d3d

Browse files
#168 Add URL - nullsafe
1 parent 5f28dc7 commit 3426d3d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns="http://apache.org/cordova/ns/plugins/1.0"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
id="nl.x-services.plugins.calendar"
6-
version="4.3.3">
6+
version="4.3.4">
77

88
<name>Calendar</name>
99

src/ios/Calendar.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,19 +384,21 @@ - (void)createEventWithOptions:(CDVInvokedUrlCommand*)command {
384384
NSString* calendarName = [calOptions objectForKey:@"calendarName"];
385385
NSString* url = [calOptions objectForKey:@"url"];
386386

387-
NSURL* myUrl = [NSURL URLWithString:url];
387+
EKEvent *myEvent = [EKEvent eventWithEventStore: self.eventStore];
388+
if (url != (id)[NSNull null]) {
389+
NSURL* myUrl = [NSURL URLWithString:url];
390+
myEvent.URL = myUrl;
391+
}
388392

389393
NSTimeInterval _startInterval = [startTime doubleValue] / 1000; // strip millis
390394
NSDate *myStartDate = [NSDate dateWithTimeIntervalSince1970:_startInterval];
391395

392396
NSTimeInterval _endInterval = [endTime doubleValue] / 1000; // strip millis
393397

394-
EKEvent *myEvent = [EKEvent eventWithEventStore: self.eventStore];
395398
myEvent.title = title;
396399
myEvent.location = location;
397400
myEvent.notes = notes;
398401
myEvent.startDate = myStartDate;
399-
myEvent.URL = myUrl;
400402

401403
int duration = _endInterval - _startInterval;
402404
int moduloDay = duration % (60*60*24);

0 commit comments

Comments
 (0)