LaunchServices: invalidationHandler called - iOS 8 share sheet
Asked Answered
B

6

25

Seeing this error message in the logs, though not consistently, around the time that I use SLComposeViewController to open a Twitter or Facebook share sheet. I am not using any new iOS 8 API, just testing existing code on iOS 8. I see others have had this problem and even seen crashes when using other modal view controllers from the Cocoa Touch SDK.

LaunchServices: invalidationHandler called

Are there new precautions to take with SLComposeViewController and UIActivityViewController in iOS 8? Something else to consider?

Battledore answered 10/9, 2014 at 7:14 Comment(5)
Seeing same log just opening and closing a share sheet in iOS 8.0 GM. No answer yet.Epochmaking
Same thing here. UIActivityViewController is very buggy.Bess
This guy figured it out for Objective-C...but i'm not sure how to follow his answer in Swift. #25192813Leatherjacket
Check out my answer on the other thread: https://mcmap.net/q/539303/-sharing-via-uiactivityviewcontroller-to-twitter-facebook-etc-causing-crashTottering
I was getting this error too and realized it was coming when calling [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook] and no facebook accounts were in settings. I just stopped checking for this since it automatically handles not having accounts and presents a message.Chyack
C
26

Add this code after you present your activity view controller:

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

    presentationController.sourceView = sender; // if button or change to self.view.
}
Clipping answered 18/9, 2014 at 1:0 Comment(4)
I got a same problem... this answer solves the crashing problem but still am getting "LaunchServices: invalidationHandler called" in consoleSaltish
This is apple side bug Check <devforums.apple.com/message/1049415#1049415> , so don't care about console warning.Explication
I would have literally never, ever figured this out. Go Apple.Scuttlebutt
or: presentationController.barButtonItem = sender;Tanana
K
5

Looking at the developer forums: "That log message does not indicate any error on your part."

Kirshbaum answered 4/10, 2014 at 4:24 Comment(1)
I guess you are specifically referring to this post: devforums.apple.com/message/1049415#1049415Worden
S
2

I had a similar problem with a UIDocumentInteractionController, where when I tapped outside it to dismiss it, or selected another app to open the document in, it would crash with the "LaunchServices: invalideationHandler called" console message displayed twice (only using iOS 8).

A workaround is to add the call to presentOpenInMenuFromRect:inView:animated to the main queue, i.e.

dispatch_async(dispatch_get_main_queue(), ^() {

[self.documentInteraction presentOpenInMenuFromRect:theRect inView:self.view animated:YES];

});
Sendal answered 22/10, 2014 at 19:21 Comment(0)
H
0

You may also need to define the sourceRect. I used the following code to display a SLComposeViewController from a tableView.

if ([controller respondsToSelector:@selector(popoverPresentationController)]) {
    //get rect for this row in table
    CGRect frame = [self.tableView rectForRowAtIndexPath:indexPath];

    //convert table row frame to view reference
    CGRect frameInView = [self.tableView convertRect:frame toView:self.view];

    [controller popoverPresentationController].sourceRect = frameInView;
    [controller popoverPresentationController].sourceView = self.view;
}
Hemianopsia answered 18/9, 2014 at 5:36 Comment(0)
C
0

Regarding the auto-closing (not the crash): I think it's probably related to the link you are trying to share. I'm seeing the same thing when trying to post music links (Spotify, SoundCloud,...). The same tweet works if I replace the link by a link to some non-media-content. I'll file radar on this to see whether it's intentional...

Compliment answered 27/9, 2014 at 3:13 Comment(0)
B
0

This gets rid of the Error message for me and works as expected. You have to get rid of the if statement that calls "isAvailableForServiceType:"

It should look like this. Happy coding.

    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.
    }
Banish answered 30/10, 2014 at 3:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.