我有一個通用的iOS應用程序,努力使其與iOS 6兼容。我使用Cordova/Phonegap框架,因此我的應用程序是HTML,CSS和JS。我在github上使用了calenderPlugin,它在github上可用,在iOS 6之前工作正常。 問題從這裏開始, Apple從iOS 6開始,在對日曆和提醒進行任何操作之前,我們需要向用戶授予許可。對於這裏的示例代碼,
EKEventStore,我是否需要安全地使用iOS 6的EventKit.Framework?
EKEventStore *eventStore = [[EKEventStore alloc] init];
if([self checkIsDeviceVersionHigherThanRequiredVersion:@"6.0"]) {
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted){
//---- codes here when user allow your app to access theirs' calendar.
}else
{
//----- codes here when user NOT allow your app to access the calendar.
}
:
:
}];
}
//**********************************************************************************
// Below is a block for checking is current ios version higher than required version.
//**********************************************************************************
- (BOOL)checkIsDeviceVersionHigherThanRequiredVersion:(NSString *)requiredVersion
{
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:requiredVersion options:NSNumericSearch] != NSOrderedAscending)
{
return YES;
}
return NO;
}
當然,我已經加入EventKit.Framework和EventKitUI.Framework。現在的事情是, 用於開發iOS 6我下載並安裝了iOS6 SDK附帶的xCode 4.5。
xCode未找到此方法requestAccessToEntityType,EKEntityTypeEvent常量都不可用。
看來我缺少iOS 6的EventKit.Framework ?? !!但是如何?我有iOS 6的SDK附帶的xCode 4.5。有什麼建議嗎?
我的基礎SDK已經設置爲最新的iOS(6.0)。你用過EventKit.framework嗎?因爲我認爲我的框架中的EKEventStore類不包含方法-requestAccessToEntityType,所以iOS 6應該有單獨的新EventKit.framework。從哪裏獲得它?我瀏覽了我的系統,並且只有iPhoneOS5.0.sdk文件夾可用,我添加了這個框架。 –