日历不会在隐私设置中显示应用

时间:2013-02-20 07:21:43

标签: iphone calendar

在我的应用中,我添加了一个按钮,可以向iPhone calendar添加提醒功能。我使用了EKEventEditViewController.它已呈现给用户和用户add to calender。它正在我的iPhone上工作,我也找到calender privacy setting中列出的应用程序。但客户找不到`iPhone日历隐私设置中列出的应用程序。我必须做plist中的任何设置吗?

1 个答案:

答案 0 :(得分:0)

我将假设该应用针对iOS 6

请记住,应用必须“询问”用户该应用是否可以访问日历。

[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        [self performSelectorOnMainThread:@selector(showCalendarEventViewControllerWithEventStore:) withObject:eventStore waitUntilDone:YES];
    }] ;

-(void) showCalendarEventViewControllerWithEventStore: (EKEventStore *) eventStore
{
    EKEventEditViewController * vc = [[EKEventEditViewController alloc] init];

    EKEvent* event = [EKEvent eventWithEventStore:eventStore];
    event.title = [NSString stringWithFormat:@"Take %@" , self.prescription.lastFilledLabelName];
    event.startDate = [[NSDate date] dateByRoundingToNextMinute:15];
    event.endDate = [event.startDate dateByAddingTimeInterval:15*60];
    event.notes = self.prescription.directions;
    EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-15*60] ;
    event.alarms = [NSArray arrayWithObject:alarm];

    vc.eventStore = eventStore;
    vc.event = event;

    vc.editViewDelegate = self;
    vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:vc animated:YES completion:nil];

}

用户运行应用程序一次后,该应用程序将显示在隐私设置中。