Search code examples
ioscocoa-touchwebcal

ios webcal request - completion callback?


NSURL *url = [NSURL URLWithString:@"valid_webcal_url"];
if (![[UIApplication sharedApplication] openURL:url])
{
    // failure callback
    NSLog(@"%@%@",@"Failed to open url:",[url description]);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:LCHLocalizedString(@"SUBSCRIBE_ERROR", nil) message:nil delegate:self cancelButtonTitle:@"Okay" otherButtonTitles: nil];
    [alert show];
}

So I've figured out how to see if there was an error loading the webcal, but how can I know when the webcal was loaded successfully? I display a loader when the "subscribe" button is tapped and just need to know when to turn it off.


Solution

  • Because this is using openURL to retrieve an item using the webcal protocol, there is no visual separation of app and webcal retrieval.

    What I'm having to do is listen for the notification UIApplicationWillResignActiveNotification after calling openURL and when the notification is fired I assume it's the webcal taking over from my openURL call.

    This is tricky business and a rudimentary fix but hey, it works! Thanks for all help/suggestions.