4

I am playing around with the idea of Airdrop. There is an error while running the sample code by Apple:

https://developer.apple.com/library/ios/samplecode/sc2273/Introduction/Intro.html

The error message is:

LaunchServices: invalidationHandler called

The problem is obviously caused by UIActivityViewController. The related code is under #pragma mark - Actions of this file if you could have a look.

It only show the error message when running on devices (both iPhone and iPad). It is all fine if running on simulator (both iPhone and iPad). What's the cause of this? Any idea about how to resolve it? Could it be possibly a bug?

Similar questions are asked by the following, none of which seems to be able to answer this quesition:

LaunchServices: invalidationHandler called - iOS 8 share sheet

Sharing via UIActivityViewController to Twitter/Facebook etc. causing crash

Present UIActivityViewController- LaunchServices:invalidationHandler called

Community
  • 1
  • 1
Yuchen
  • 30,852
  • 26
  • 164
  • 234

2 Answers2

12

This is a bug on Apple's side. From the developer forums:

That log message does not indicate any error on your part.

Imanou Petit
  • 89,880
  • 29
  • 256
  • 218
Eric
  • 3,301
  • 4
  • 33
  • 39
1

You have to get rid of the if statement that calls "isAvailableForServiceType:". It should look something like this. Good luck!

    SLComposeViewController *tweetSheet = [SLComposeViewController
                                           composeViewControllerForServiceType:SLServiceTypeTwitter];

    [tweetSheet setInitialText:@"Great fun to learn iOS programming at appcoda.com!"];
    [self presentViewController:tweetSheet animated:YES completion:nil];

    if ([tweetSheet respondsToSelector:@selector(popoverPresentationController)])
    {
        // iOS 8+
        UIPopoverPresentationController *presentationController = [tweetSheet popoverPresentationController];

        presentationController.sourceView = sender; // if button or change to self.view.
    }
rjm226
  • 1,203
  • 1
  • 11
  • 21