Platforms to show: All Mac Windows Linux Cross-Platform
/Mac64bit/EventKit/MBS iOS EventKit demo
Required plugins for this example: MBS Mac64bit Plugin, MBS MacBase Plugin, MBS MacCloud Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Mac64bit/EventKit/MBS iOS EventKit demo
This example is the version from Mon, 16th May 2021.
Project "MBS iOS EventKit demo.xojo_binary_project"
Class App Inherits MobileApplication
End Class
Class LaunchScreen Inherits iosView
End Class
ExternalFile Info
End ExternalFile
Module EventKit
Protected Sub getEventStore()
if EventKit.EventStore = Nil then
EventKit.EventStore = new ourEventStore
if EventKit.EventStore.authorizationStatusForEntityType( EKEventStoreMBS.kEntityTypeEvent ) = EKEventStoreMBS.kAuthorizationStatusNotDetermined then
EventKit.EventStore.requestAccessToEntityType( EKEventStoreMBS.kEntityTypeEvent )
elseif EventKit.EventStore.authorizationStatusForEntityType( EKEventStoreMBS.kEntityTypeEvent ) = EKEventStoreMBS.kAuthorizationStatusAuthorized then
EventKit.bEventPermissionGranted = True
else
EventKit.bEventPermissionGranted = False
end if
end if
End Sub
Property EventStore As ourEventStore
Property bEventPermissionGranted As Boolean
End Module
Class ourEventStore Inherits EKEventStoreMBS
EventHandler Sub requestAccessToEntityTypeCompleted(entityType as Integer, granted as Boolean, error as NSErrorMBS, tag as variant)
if (entityType = EKEventStoreMBS.kEntityTypeEvent) then
Break
EventKit.bEventPermissionGranted = granted
end if
End EventHandler
End Class
Class msEventKitDemo Inherits MobileScreen
Control mbGetCalendars Inherits MobileButton
ControlInstance mbGetCalendars Inherits MobileButton
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
EventHandler Sub Pressed()
dim calendars() as EKCalendarMBS
dim msgBox as New MobileMessageBox
if not EventKit.bEventPermissionGranted = True then
msgBox.Title = "You must give the app access to calendar events to be able to get the calendars on this device."
msgBox.Show
Return
end if
calendars = EventKit.EventStore.calendarsForEntityType( EKEventStoreMBS.kEntityTypeEvent )
msgBox.Title = calendars.LastIndex.ToString + " calendars found"
msgBox.Buttons = Array( "OK" )
msgBox.Show
End EventHandler
End Control
Control mbGetEvents Inherits MobileButton
ControlInstance mbGetEvents Inherits MobileButton
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
EventHandler Sub Pressed()
dim msgBox as New MobileMessageBox
dim iCalEvents() as EKEventMBS
dim thePredicate as NSPredicateMBS
dim dateStart, dateEnd as DateTime
dim theInterval as DateInterval
if not EventKit.bEventPermissionGranted = True then
msgBox.Title = "You must give the app access to calendar events to be able to get the events on this device."
msgBox.Show
Return
end if
dateStart = New DateTime( DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0, 0, TimeZone.Current )
theInterval = New DateInterval( 0, 1, 0, 0, 0, -1 )
dateEnd = dateStart + theInterval
// Have to ask for events finishing the day after the one we're after or all-day events on the last day don't get included
thePredicate = EventKit.EventStore.predicateForEvents( dateStart, dateEnd )
iCalEvents = EventKit.EventStore.eventsMatchingPredicate( thePredicate )
msgBox.Title = iCalEvents.LastIndex.ToString + " events found for this month"
msgBox.Buttons = Array( "OK" )
msgBox.Show
End EventHandler
End Control
EventHandler Sub Opening()
EventKit.getEventStore
End EventHandler
End Class
End Project
The items on this page are in the following plugins: MBS Mac64bit Plugin.