Repost:: How to access iOS native calendars?

Startbeitrag von John Fligg am 25.10.2014 17:25

Hi, I have my appointments in WM and want to send them to the iOS NATIVE calendars. I can do it in Android WM supports that but WM does not support it in iOS. So presumably I have to use Java? I do not have any experience of that.

Does anyone have an example of how to do that please or can they offer any guidance please so I can choose a native calendar and export/import the appointments.

Many thanks.

John

Antworten:

I did find this site https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin/blob/bcd27c9e60ef92a6eb9a6b5f4674ee917f31580d/README.md but not sure how I would add this to WM so if anyone could guide me it would be a good learning exercise for all sorts of things.

Thx.

von John Fligg - am 25.10.2014 17:28
//import du framework EventKit natif iOS
#import
#import
#import
#import
#import
#import

void iOS() {};

@class EKEventStore,EKReminder;

--------------
BOOL iOS_AddEvent(NSString* Montitre,NSString* startDate)
{
//Retraitement de la date
//définit l'objet NSDateFormatter df et lui réserve un emplacement en mémoire
NSDateFormatter* df = [[NSDateFormatter alloc]init];
//définit le format utilisé dans l'objet NSDateFormatter on y indique le meme format que pcsoft AAAAMMJJ (AAAA : année, MM : Mois, JJ : Jour)
[df setDateFormat:@"yyyyMMdd"];
//affectation de la chaine startdate a la date uneDate
NSDate *uneDate = [df dateFromString:startDate];

//définit l'objet EKEventStore eventStore et lui réserve un emplacement en mémoire
EKEventStore *eventStore = [[EKEventStore alloc] init];
//définit l'objet EKEvent event base rendez-vous
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
//On rempli la structure de la base rendez-vous
event.calendar = [eventStore defaultCalendarForNewEvents];
event.title = Montitre;
event.location = @"CALHEB";
event.startDate = uneDate;
event.endDate = [uneDate dateByAddingTimeInterval:3600 * 2];
event.notes = @"Événement créé par l'application \'Calheb\'";
event.allDay = YES;

[event setCalendar:[eventStore defaultCalendarForNewEvents]];
if([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
// iOS 6 and later
// This line asks user's permission to access his calendar
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
if (granted) // user user is ok with it
{
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
if(err)
NSLog(@"unable to save event to the calendar!: Error= %@", err);
}
else // if he does not allow
{
[[[UIAlertView alloc]initWithTitle:nil message:@"plzAlowCalendar" delegate:nil cancelButtonTitle:NSLocalizedString(@"plzAlowCalendar", nil) otherButtonTitles: nil] show];
return;
}
}];
}
// iOS < 6
else
{
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
if(err)
NSLog(@"unable to save event to the calendar!: Error= %@", err);
}
return TRUE;
}
-----------
void iOs_DelEvents(NSString* startDate, NSString* endDate)
{
//Retraitement de la date startDate
//définit l'objet NSDateFormatter df et lui réserve un emplacement en mémoire
NSDateFormatter* df = [[NSDateFormatter alloc]init];
//définit le format utilisé dans l'objet NSDateFormatter on y indique le meme format que pcsoft AAAAMMJJ (AAAA : année, MM : Mois, JJ : Jour)
[df setDateFormat:@"yyyyMMdd"];
//affectation de la chaine startdate a la date uneDateDebut
NSDate *uneDateDebut = [df dateFromString:startDate];
//-----------------meme chose pour endDate
//affectation de la chaine endDate a la date uneDateFin
NSDate *uneDateFin = [df dateFromString:endDate];
uneDateFin = [uneDateFin dateByAddingTimeInterval:3600 * 2];

//définit l'objet EKEventStore eventStore et lui réserve un emplacement en mémoire
EKEventStore *eventStore = [[EKEventStore alloc] init];
//recherche des evenements
NSPredicate *predicateForEvents = [eventStore predicateForEventsWithStartDate:uneDateDebut endDate:uneDateFin calendars:[NSArray arrayWithObject:[eventStore defaultCalendarForNewEvents]]];
//set predicate to search for an event of the calendar(you can set the startdate, enddate and check in the calendars other than the default Calendar)
NSArray *events_Array = [eventStore eventsMatchingPredicate: predicateForEvents];
//get array of events from the eventStore
for (EKEvent *eventToCheck in events_Array)
{
if( [eventToCheck.location isEqualToString: @"CALHEB"] )
{
NSError *err;
BOOL success = [eventStore removeEvent:eventToCheck span:EKSpanThisEvent error:&err];
NSLog( @"event deleted success if value = 1 : %d", success );
}
}
}
----------------
//wlanguage
sTitre est chaîne = "RV PERSO"
sDatesDebut est une chaîne ANSI = "20141130"

iOS_AddEvent(sTitre,sDatesDebut)

or
sDatesDebut est une chaîne ANSI = "20141130"
sDatesFin est une chaîne ANSI = "20141130"
iOs_DelEvents(sDatesDebut,sDatesFin)
-----

Add the name of the library
EventKit.framework and EventKitUI.framework
when generating the project

von popoy - am 30.11.2014 10:21
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.