Skip to content

Commit

Permalink
#168 Add URL - nullsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Apr 23, 2015
1 parent 5f28dc7 commit 3426d3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="nl.x-services.plugins.calendar"
version="4.3.3">
version="4.3.4">

<name>Calendar</name>

Expand Down
8 changes: 5 additions & 3 deletions src/ios/Calendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,19 +384,21 @@ - (void)createEventWithOptions:(CDVInvokedUrlCommand*)command {
NSString* calendarName = [calOptions objectForKey:@"calendarName"];
NSString* url = [calOptions objectForKey:@"url"];

NSURL* myUrl = [NSURL URLWithString:url];
EKEvent *myEvent = [EKEvent eventWithEventStore: self.eventStore];
if (url != (id)[NSNull null]) {
NSURL* myUrl = [NSURL URLWithString:url];
myEvent.URL = myUrl;
}

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

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

EKEvent *myEvent = [EKEvent eventWithEventStore: self.eventStore];
myEvent.title = title;
myEvent.location = location;
myEvent.notes = notes;
myEvent.startDate = myStartDate;
myEvent.URL = myUrl;

int duration = _endInterval - _startInterval;
int moduloDay = duration % (60*60*24);
Expand Down

0 comments on commit 3426d3d

Please sign in to comment.