Skip to content

Commit

Permalink
Merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jul 1, 2016
2 parents 03f1269 + 99c5ae9 commit be3b6ab
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 80 deletions.
59 changes: 50 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ This plugin allows you to add events to the Calendar of the mobile device.
### iOS specifics
* Supported methods: `find`, `create`, `modify`, `delete`, ..
* All methods work without showing the native calendar. Your app never loses control.
* Tested on iOS 6 and 7.
* Tested on iOS 6+.
* On iOS 10+ you need to provide a reason to the user for Calendar access. This plugin adds an empty `NSCalendarsUsageDescription` key to the /platforms/ios/*-Info.plist file which you can override with your custom string [per Apple's guideline](https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW15).

### Android specifics
* Supported methods on Android 4: `find`, `create` (silent and interactive), `delete`, ..
Expand Down Expand Up @@ -143,8 +144,7 @@ deleteEventFromNamedCalendar | | yes |
openCalendar | | yes | yes

Basic operations, you'll want to copy-paste this for testing purposes:

```javascript
```js
// prep some variables
var startDate = new Date(2015,2,15,18,30,0,0,0); // beware: month 0 = january, 11 = december
var endDate = new Date(2015,2,15,19,30,0,0,0);
Expand Down Expand Up @@ -246,25 +246,65 @@ Basic operations, you'll want to copy-paste this for testing purposes:
```

Creating an all day event:

```javascript
```js
// set the startdate to midnight and set the enddate to midnight the next day
var startDate = new Date(2014,2,15,0,0,0,0,0);
var endDate = new Date(2014,2,16,0,0,0,0,0);
```

Creating an event for 3 full days

```javascript
```js
// set the startdate to midnight and set the enddate to midnight 3 days later
var startDate = new Date(2014,2,24,0,0,0,0,0);
var endDate = new Date(2014,2,27,0,0,0,0,0);
```

Example Response IOS getCalendarOptions
```js
{
calendarId: null,
calendarName: "calendar",
firstReminderMinutes: 60,
recurrence: null,
recurrenceEndDate: null,
recurrenceInterval: 1,
secondReminderMinutes: null,
url: null
}
```

Exmaple Response IOS Calendars
```js
{
id: "258B0D99-394C-4189-9250-9488F75B399D",
name: "standard calendar",
type: "Local"
}
```

Exmaple Response IOS Event
```js
{
calendar: "Kalender",
endDate: "2016-06-10 23:59:59",
id: "0F9990EB-05A7-40DB-B082-424A85B59F90",
lastModifiedDate: "2016-06-13 09:14:02",
location: "",
message: "my description",
startDate: "2016-06-10 00:00:00",
title: "myEvent"
}
```

### Android 6 (M) Permissions
On Android 6 you need to request permission to use the Calenda at runtime when targeting API level 23+.
Even if the uses-permission tags the Calendar are present in `AndroidManifest.xml`.
On Android 6 you need to request permission to use the Calendar at runtime when targeting API level 23+.
Even if the `uses-permission` tags for the Calendar are present in `AndroidManifest.xml`.

Since plugin version 4.5.0 we transparently handle this for you in a just-in-time manner.
So if you call `createEvent` we will pop up the permission dialog. After the user granted access
to his calendar the event will be created.

You can also manually manage and check permissions if that's your thing.
Note that the hasPermission functions will return true when:

- You're running this on iOS, or
Expand All @@ -273,6 +313,7 @@ Note that the hasPermission functions will return true when:
- You've already granted permission.

```js
// again, this is no longer needed with plugin version 4.5.0 and up
function hasReadWritePermission() {
window.plugins.calendar.hasReadWritePermission(
function(result) {
Expand Down
2 changes: 1 addition & 1 deletion demo/www/js/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function createCalendarEventInteractivelyWithOptions() {
}

function createCalendarEventWithOptions() {
window.plugins.calendar.createEventWithOptions(title, loc, notes, startDate, endDate, options, onSuccess, onError)
window.plugins.calendar.createEventWithOptions(title, loc, notes, startDate, endDate, options, onSuccess, onError);
}

function findEventWithFilter() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-calendar",
"version": "4.4.7",
"version": "4.5.1",
"description": "This plugin allows you to manipulate the native calendar.",
"cordova": {
"id": "cordova-plugin-calendar",
Expand Down
18 changes: 16 additions & 2 deletions 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.4.7">
version="4.5.1">

<name>Calendar</name>

Expand Down Expand Up @@ -39,6 +39,20 @@
<param name="ios-package" value="Calendar"/>
</feature>
</config-file>
<!-- Localization of the interactive Calendar widget -->
<config-file target="*-Info.plist" parent="CFBundleLocalizations">
<array>
<string>en</string>
<string>de</string>
<string>nl</string>
<string>fr</string>
<string>it</string>
</array>
</config-file>
<!-- Usage description of the Calendar for iOS 6+, mandatory since iOS 10 -->
<config-file target="*-Info.plist" parent="NSCalendarsUsageDescription">
<string/>
</config-file>
<header-file src="src/ios/Calendar.h"/>
<source-file src="src/ios/Calendar.m"/>
<framework src="EventKit.framework"/>
Expand All @@ -63,6 +77,6 @@
target-dir="src/nl/xservices/plugins/accessor"/>
<source-file src="src/android/nl/xservices/plugins/accessor/LegacyCalendarAccessor.java"
target-dir="src/nl/xservices/plugins/accessor"/>
<framework src="com.android.support:support-v4:+" />
<dependency id="cordova-plugin-compat" version="^1.0.0" />
</platform>
</plugin>
Loading

0 comments on commit be3b6ab

Please sign in to comment.