Hi,
here's a snippet of my code. It's just a test, it's a bit (well much
more than a bit) messed up, different pieces "glued" toghether, just
to see if everything works.
I compiled gdata successfully into my xcode project, technically
everything seems correct.
With this code, the event (using a textfield and a datepicker) is
inserted correctly in google calendar - i can see and modify
correctly it ! - , but it doesn't trigger any alert, neither email,
nor sms.
Please help, and sorry for my poor english (and really poor
programming skills too ) :)
TheMac
---
//iCale.m
// Copyright 2011 themac inc. All rights reserved.
//
#import "iCale.h"
#import "GTMOAuth2WindowController.h"
#import "GData.h"
#import "GTMOAuth2Authentication.h"
#import "GTMOAuth2ViewControllerTouch.h"
#import "GTMOAuth2SignIn.h"
//#import "GTMHTTPFetcher.h"
GDataServiceGoogleCalendar *service;
NSURL *cal;
@implementation iCalenDayAppDelegate
@synthesize datario;
@synthesize window=_window;
@synthesize bottoneTastiera;
@synthesize bottoneInserisci;
@synthesize casellaTesto;
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//impostiamo la data di oggi nel calendario//
//[setDate:[NSDate date] animated:NO];
[datario setDate:[NSDate date]];
[self.window makeKeyAndVisible];
return YES;
}
#pragma mark -
// get a calendar service object with the current username/password
//
// A "service" object handles networking tasks. Service objects
// contain user authentication information as well as networking
// state information (such as cookies and the "last modified" date for
// fetched data.)
- (GDataServiceGoogleCalendar *)calendarService {
// Override point for customization after application launch.
service = [[GDataServiceGoogleCalendar alloc] init];
[service setUserCredentialsWithUsername:@"//SNIP//"
password:@"//SNIP//"];
cal = [GDataServiceGoogleCalendar calendarFeedURLForUsername:@"//
SNIP//"];
/*
GDataServiceTicket *ticket;
ticket = [service fetchFeedWithURL:cal
delegate:self
didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
*/
return service;
}
- (void) inizializzaCal {
NSLog(@"sono in inizializzaCal ");
GTMOAuth2Authentication *auth;
auth = [GTMOAuth2ViewControllerTouch
authForGoogleFromKeychainForName:@"Calendar"
clientID:@"//SNIP//"
clientSecret:@"//SNIP//"];
[[self calendarService] setAuthorizer:auth];
// Override point for customization after application launch.
// fetcha il nome del calendario - funziona ! - inizio !
service = [[GDataServiceGoogleCalendar alloc] init];
[service setUserCredentialsWithUsername:@"//SNIP//"
password:@"//SNIP//"];
NSURL *cal = [GDataServiceGoogleCalendar
calendarFeedURLForUsername:@"//SNIP//"];
GDataServiceTicket *ticket;
NSLog(@"chieddo ticket inizio ");
ticket = [service fetchFeedWithURL:cal
delegate:self
didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
NSLog(@"chiedo ticket fine ");
}
- (void)addAnEventToCalendar:(GDataEntryCalendar *)calendar {
NSLog(@"sono in add an event ");
GDataEntryCalendarEvent *newEvent = [GDataEntryCalendarEvent
calendarEvent];
// set a title, description, and author
[newEvent setTitleWithString:[casellaTesto text]];
[newEvent setContentWithString:@"Today's discussion"];
// l'esempio toglie queste due sotto
//GDataPerson *authorPerson = [GDataPerson personWithName:@"//
SNIP//"
// email:@"//
SNIP//"];
//[newEvent addAuthor:authorPerson];
// ora attuale, noi vogliamo prendere l'ora dal datepicker nella
view - INIZIO
/*
// start time now, end time in an hour
NSDate *anHourFromNow = [NSDate dateWithTimeIntervalSinceNow:
60*60];
GDataDateTime *startDateTime = [GDataDateTime dateTimeWithDate:
[NSDate date]
timeZone:
[NSTimeZone systemTimeZone]];
*/
// ora attuale, noi vogliamo prendere l'ora dal datepicker nella
view - FINE
// prende l'ora attuale INIZIO
GDataDateTime *startDateTime = [GDataDateTime dateTimeWithDate:
[datario date]
timeZone:
[NSTimeZone systemTimeZone]];
// prende ora attuale
NSDate *anHourFromNow = [datario date];
// aggiunge 3600 secondi - crea intrv
NSTimeInterval intrv = 3600;
// aggiunge 3600 secondi con intrv ad anhourfromnow
anHourFromNow = [anHourFromNow dateByAddingTimeInterval:intrv];
GDataDateTime *endDateTime = [GDataDateTime
dateTimeWithDate:anHourFromNow
timeZone:
[NSTimeZone systemTimeZone]];
// reminder 10 minutes before the event
GDataReminder *reminder = [GDataReminder reminder];
[reminder setMinutes:@"10"] ;
[reminder setMethod:kGDataReminderMethodEmail];
GDataWhen *when = [GDataWhen whenWithStartTime:startDateTime
endTime:endDateTime];
[when addReminder:reminder];
[newEvent addTime:when];
NSLog(@"inserito, forse");
// display the event edit dialog
// add it to the user's calendar
NSURL *feedURL = [[calendar alternateLink] URL];
//not sure about this
// GDataEntryCalendar *calendar = [self cal]; // [self
selectedCalendar];
GDataServiceGoogleCalendar *service = [self calendarService];
[service fetchEntryByInsertingEntry:newEvent
forFeedURL:feedURL
delegate:self
didFinishSelector:@selector(aticket:finishedWithFeed:error:)];
/* PARTE OLD - INIZIO
// add it to the user's calendar
NSURL *feedURL = [[calendar alternateLink] URL];
GDataServiceGoogleCalendar *service = [self calendarService];
[service fetchEntryByInsertingEntry:newEvent
forFeedURL:feedURL
delegate:self
didFinishSelector:@selector(addTicket:addedEntry:error:)];
[service fetchEntryByInsertingEntry:newEvent
forFeedURL:feedURL
delegate:self
didFinishSelector:@selector(aticket:finishedWithFeed:error:)];
PARTE OLD - FINE */
NSLog(@"oki");
UIAlertView *oki = [[UIAlertView alloc] initWithTitle:
@"Informazioni" message: @"Inserimento OK !" delegate:self
cancelButtonTitle: @"ok"
otherButtonTitles:nil];
[oki show];
[oki release];
}
- (void)aticket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedCalendar *)feed
error:(NSError *)error {
NSLog(@"aticket");
}
- (void)ticket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedCalendar *)feed
error:(NSError *)error {
if (error == nil) {
NSArray *entries = [feed entries];
if ([entries count] > 0) {
GDataEntryCalendar *firstCalendar = [entries objectAtIndex:
0];
GDataTextConstruct *titleTextConstruct = [firstCalendar
title];
NSString *title = [titleTextConstruct stringValue];
NSLog(@"first calendar's title: %@", title);
[self addAnEventToCalendar:firstCalendar];
} else {
NSLog(@"the user has no calendars");
}
} else {
NSLog(@"fetch error: %@", error);
}
}
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
// self.window.rootViewController = self.navigationController;
// fetcha il nome del calendario . funziona - FINE !
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to
inactive state. This can occur for certain types of temporary
interruptions (such as an incoming phone call or SMS message) or when
the user quits the application and it begins the transition to the
background state.
Use this method to pause ongoing tasks, disable timers, and
throttle down OpenGL ES frame rates. Games should use this method to
pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data,
invalidate timers, and store enough application state information to
restore your application to its current state in case it is terminated
later.
If your application supports background execution, this method is
called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the
inactive state; here you can undo many of the changes made on entering
the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the
application was inactive. If the application was previously in the
background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
- (void)dealloc
{
[_window release];
[bottoneTastiera release];
[datario release];
[bottoneInserisci release];
[casellaTesto release];
[super dealloc];
}
- (IBAction)dragOutside:(id)sender {
[casellaTesto resignFirstResponder];
}
- (IBAction)dragExit:(id)sender {
[casellaTesto resignFirstResponder];
}
- (IBAction)valoreCambiato:(id)sender {
}
- (IBAction)bottoneTastieraPremuto:(id)sender {
}
- (IBAction)casellaTestoDidEndExit:(id)sender {
NSLog(@"premuto ok didendexit");
[casellaTesto resignFirstResponder];
}
- (IBAction)clicTesto:(id)sender {
[casellaTesto setText:@""];
}
- (IBAction)casellaTestoEditingEnd:(id)sender {
NSLog(@"premuto ok editingend");
}
- (IBAction)inserisciEvento:(id)sender {
//chiama inizializza cal.
[self inizializzaCal];
}
- (IBAction)testoFuori:(id)sender {
[casellaTesto resignFirstResponder];
}
- (IBAction)testoDentro:(id)sender {
[casellaTesto resignFirstResponder];
}
@end
--
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html