Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS中的google日历中添加用户事件_Ios_Objective C_Google Calendar Api - Fatal编程技术网

如何在iOS中的google日历中添加用户事件

如何在iOS中的google日历中添加用户事件,ios,objective-c,google-calendar-api,Ios,Objective C,Google Calendar Api,我正在将谷歌日历集成到我的应用程序中。它已成功集成,现在我想将用户事件添加到Google日历中。如果我在Google日历中添加users事件,该事件应该反映在jSon响应中 在json响应中获取用户事件时遇到问题 -(void)updateCalendar { //NSString *calendarId = @"XXXX-fr62agepgso9n50s9nhv7c2g27inhqg6.apps.googleusercontent.com"; N

我正在将谷歌日历集成到我的应用程序中。它已成功集成,现在我想将用户事件添加到Google日历中。如果我在Google日历中添加users事件,该事件应该反映在jSon响应中

在json响应中获取用户事件时遇到问题

-(void)updateCalendar    
{    
    //NSString *calendarId = @"XXXX-fr62agepgso9n50s9nhv7c2g27inhqg6.apps.googleusercontent.com";        
    NSString *calendarId =  @"47ou48fasc70l0758i9lh76sr8@group.calendar.google.com";        
    NSString *apiKey = @"XXX";        
    NSString *urlFormat = @"https://www.googleapis.com/calendar/v3/calendars/%@/events?key=%@&fields=items(id,start,summary,status)";        
    NSString *calendarUrl = [NSString stringWithFormat:urlFormat, calendarId, apiKey];        
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];        
    manager.responseSerializer = [AFJSONResponseSerializer serializer];        
    [manager GET:calendarUrl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) 
    {            
    [ADManagedObjectContext updateEvents:responseObject[@"items"]];            
    [self.refreshControl endRefreshing];            
    }

    failure:^(AFHTTPRequestOperation *operation, NSError *error) {                 
    [self.refreshControl endRefreshing];                 
    }];    
}

首先从设备中检索所有日历。然后使用此代码将所有日历存储在NSArray中

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
caleandarsArray = [[NSArray alloc] init];
EKCalendar *calendar = [caleandarsArray objectAtIndex:1];
[events setCalendar:calendar];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
然后使用此代码将事件添加到所选日历

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
caleandarsArray = [[NSArray alloc] init];
EKCalendar *calendar = [caleandarsArray objectAtIndex:1];
[events setCalendar:calendar];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
通过使用上述代码,我们可以将事件添加到desire日历中

您不应该使用Google API,而应该使用EventKit(),它很简单,您可以在用户想要的地方同步到日历


检查此链接:

首先从设备中检索所有日历。然后使用此代码将所有日历存储在NSArray中

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
caleandarsArray = [[NSArray alloc] init];
EKCalendar *calendar = [caleandarsArray objectAtIndex:1];
[events setCalendar:calendar];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
然后使用此代码将事件添加到所选日历

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
caleandarsArray = [[NSArray alloc] init];
EKCalendar *calendar = [caleandarsArray objectAtIndex:1];
[events setCalendar:calendar];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
通过使用上述代码,我们可以将事件添加到desire日历中

您不应该使用Google API,而应该使用EventKit(),它很简单,您可以在用户想要的地方同步到日历


查看此链接:

感谢您的回复。但我使用的是谷歌日历API。。所以使用谷歌日历API如何发布事件。。我不想要EKEvent kit bro.@Abinandan Pratap你能帮我吗。事实上,我只需要整合谷歌日历这是我的项目要求谢谢你的回复。但我使用的是谷歌日历API。。所以使用谷歌日历API如何发布事件。。我不想要EKEvent kit bro.@Abinandan Pratap你能帮我吗。实际上,我需要整合谷歌日历只有这是我的项目requirement@Dalm如果你有任何想法,请帮我。帮帮我,你有试过跟踪谁吗?@luc谢谢你的回复。我遵循了这个教程。。。。但我想在谷歌日历中添加事件。。接下来,相关添加的事件应反映在我的json响应中。这里是创建事件指南:没有目标C代码,但我相信您可以根据其他语言之一进行调整。@Dalm如果您有任何想法,请帮助我。帮帮我,你有试过跟踪谁吗?@luc谢谢你的回复。我遵循了这个教程。。。。但我想在谷歌日历中添加事件。。接下来,相关添加的事件应该反映在我的json响应中。这里是创建事件指南:没有目标C代码,但我相信您可以根据其他语言之一进行调整。