EKErrorDomain Code=1 in EventKit in ios5.0 - iphone

I am getting following error in different places like when I am removing an event or when adding the an event.In that desccriptions it is showing that no calendar has been set but I debugged the event calendar and get the calendar is already set.I am confused.
Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0x756a8d0 {NSLocalizedDescription=No calendar has been set.}
Can any one suggest me if are there any chcekpoints or I am doing anything wrong?
Thanks in advance

I know the title of this question references iOS5, but I had an app running on iOS5 and greater. My iOS6 users were running into this issue for different reasons - you need to use the new iOS6 method if available to get access to the event store first.
- (void)requestAccessToEntityType:(EKEntityType)entityType completion:(EKEventStoreRequestAccessCompletionHandler)completion
Be sure to check availability of the API first, e.g.
EKEventStore* eventStore = [[EKEventStore alloc] init];
if([eventStore respondsToSelector:#selector(requestAccessToEntityType:completion:)]) {
// >= iOS 6
[eventStore requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *error) {
// may return on background thread
dispatch_async(dispatch_get_main_queue(), ^{
if (granted) {
// continue
} else {
// display error
}
});
}];
} else {
// < iOS 6
// continue
}

I figured it out, try this when creating a new EKEvent:
[event setCalendar:[eventStore defaultCalendarForNewEvents]];

Related

iPhone App Crash with error [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]

I have an iPhone App in the app store which is using Touch ID. If Touch ID is enabled, the user is authenticated with it, else user needs to enter his PIN to login to the application.
After IOS 10.1 release, when I checked the crash report, the crash count has increased. From the crash report, it is pointing on [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] and when I opened the app in Xcode, it is focussing on [self dismissViewControllerAnimated:YES completion:nil];.
The code I have written is as below:
-(void) showTouchIDAuthentication{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(#"User is authenticated successfully");
[self dismissViewControllerAnimated:YES completion:nil];
} else {
}];
}
}
When I tested in iPhone 6, IOS 10, everything is working fine. Don't know how to simulate the issue.
Can anyone please figure out if I am missing something? Please help me out in resolving this crash issue.
Usually completion handlers are not running on main thread. All UI related stuff must be done on main thread (including dismissing a view controller).
I suggest to add the dismiss line on a main thread block like this:
-(void) showTouchIDAuthentication{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(#"User is authenticated successfully");
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
[self dismissViewControllerAnimated:YES completion:nil];
}];
} else {
}];
}
}

Leaderboard "No Items"

I'm trying to implement GameCenter to my app.
This is to show me the GameCenter LeaderBoard but it's shows me: No Items.
-(IBAction) ShowLeader{
GKGameCenterViewController* gameCenterController = [[GKGameCenterViewController alloc] init];
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
gameCenterController.gameCenterDelegate = self;
[self presentViewController:gameCenterController animated:YES completion:nil];
}
The user is authenticate and that's show up when i connect.
when i report score in my GameViewController:
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKScore* scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier:#"GameHighScore"];
scoreReporter.value = HighScoreNbr;
scoreReporter.context = 0;
// NSArray *scores = #[scoreReporter];
[GKScore reportScores:#[scoreReporter] withCompletionHandler:^(NSError *error) {
if (error) {
NSLog(#"error: %#", error);
}
printf("no error: ");
}];
}
This shows me no error so i suppose it works.
I already tried with 2 accounts since i saw that on other answer but didn't help.
If you need any more info please comment.
Thanks.
I found out myself after reading and viewing tones of video.
if that can help someone who as the same problem:
you need to had your BundleID from Itunes connect to your xcode5 info playlist.
then it should work.
Hope it helps ;)
This can also happen if gamekit is missing from Required device capabilities in your plist.

FBDialogs presentShareDialog does not work in both 5.1 and 6.1

id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:#"https://example.com/book/Snow-Crash.html"
forKey:#"book"];
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:#"books.reads"
previewPropertyName:#"book"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
I use the above codes to present a facebook shareDialog in my application ,but it does not work in both ios 5.1 and 6.1.I want to know the reason.
From my understanding as of now (I might be wrong), this code invokes the facebook native iOS app. If you are testing this on the simulator and don't have the iOS app installed, this will not work. It is unlikely you will be able to test this on the simulator. Try it on a real device that has the facebook iOS app installed.
Do you have the latest Facebook app installed?
Also, you're trying to post an open graph action using facebook's example action, which I'm not sure even exists. If you have registered custom open graph actions with you app, I suggest you modify your code to invoke it instead. If you don't have custom actions, I suggest starting with posting simple urls to see if it works for you.
Use:
NSURL* url = [NSURL URLWithString:#"https://developers.facebook.com/"];
[FBDialogs presentShareDialogWithLink:url
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
} else {
NSLog(#"Success!");
}
}];
And lastly I suggest you read this: https://developers.facebook.com/ios/share-dialog/

How do I programmatically access reminders?

I may be wrong, but it looks like there is no public API to create/access programmatically reminders in iOS 5. However, there is an app for iPhone that can access them: see this video.
The question is: how they do this? Is there any undocumented way to access reminders ? I also looked at the relevant documentation for iCloud, but did not find anything related.
For iOS 6.0 there is Event Kit framework grants access to users’ Reminders.app information.
Refer ReadingAndWritingReminders link. Hope helpful
Get reminder list
EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
NSLog(#"acces to §Reminder granded %i ",granted);
}];
NSPredicate *predicate = [store predicateForRemindersInCalendars:nil];
[store fetchRemindersMatchingPredicate:predicate completion:^(NSArray *reminders) {
for (EKReminder *reminder in reminders) {
NSLog(#"reminder %#",reminder);
}
}];

Add data to native iPhone app from our application in iPhone

If I develop an app through which we can choose a date and time and enter a text and that text should be added for the corresponding date and time of the native I phone calendar. Is there any way to achieve that?
Yes, should be possible using the EventKit framework (introduced in iOS 4.0).
EKEvent is the class you're probably looking for.
I use this code
EKEventStore *eventStore = [[EKEventStore alloc] init];
if ([eventStore respondsToSelector:#selector(requestAccessToEntityType:completion:)])
{
// the selector is available, so we must be on iOS 6 or newer
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error)
{
// display error message here
}
else if (!granted)
{
// display access denied error message here
}
else
{
// access granted
// ***** do the important stuff here *****
}
});
}];
}
else
{
// this code runs in iOS 4 or iOS 5
// ***** do the important stuff here *****
}