How to use Crashlytics with iMessage Extensions?
Asked Answered
H

1

3

I have an iMessage extension within my iOS app. Can Crashlytics capture its crashes?

I've tried adding the same Fabric entry from my main app's Info.plist into my iMessage extension's Info.plist, and adding the following to my MSMessagesAppViewController subclass (as recommended for Today widget intregation):

- (instancetype _Nonnull)initWithNibName:(NSString * _Nullable)nibNameOrNil
                                  bundle:(NSBundle * _Nullable)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil
                           bundle:nibBundleOrNil];
    if (self)
    {
        // Start up Answers and Crashlytics
        [Fabric with:[NSArray<id> arrayWithObjects:
                      [Answers class],
                      [Crashlytics class],
                      nil]];
    }

    return self;
}

But when I start iMessage and choose my iMessage extension, it just hangs on the previous screenshot. It never starts.

Heavenly answered 4/11, 2016 at 15:12 Comment(0)
R
6

Mike from Fabric here.

We have experimental support for only Crashlytics on iMessage Extensions. To get things working:

  1. Add your Fabric Run Script Build Phase to your extension's target. Copy and paste the one in your main app.
  2. Add the Fabric and Crashlytics.framework to your extension's linked libraries
  3. Add the Crashlytics.startWithAPIKey("YourActualApiKey") to your extension's view controller's initWithCodermethod. If you don't have an initWithCoder method currently, it should look like this in the end:

    required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) Crashlytics.startWithAPIKey("yourApiKey") }

Reference: https://mcmap.net/q/490590/-how-to-use-crashlytics-with-ios-os-x-today-view-extensions

Revkah answered 4/11, 2016 at 15:52 Comment(6)
The link appears to be broken. Any update on iMessage extension support?Florid
Modified my answer @Florid to provide more details.Revkah
Does is it also work for iMessage app (not extension)?Rubyeruch
I haven't tested it explicitly, but would expect it to work. Again, I've done no testing on it yet.Revkah
I just finished adding this to our iMessage extension and it appears to work just fine. I would just note that now we use Fabric.with([Crashlytics.self]) rather than Crashlytics.startWithAPIKey("yourApiKey").Catalepsy
Does Crashlytics call CrashlyticsDelegate when a previous crash occurred on an app extension? https://mcmap.net/q/503832/-does-crashlytics-call-crashlyticsdelegate-when-a-previous-crash-occurred-on-an-app-extension/9636Heavenly

© 2022 - 2024 — McMap. All rights reserved.