How to use Crashlytics with iOS / OS X today view extensions?

前端 未结 5 1533
旧巷少年郎
旧巷少年郎 2020-12-08 10:34

Since today extensions run as separated a process I am sure they will not log any crashes out of the box. I assume we need to initialize Crashlytics on the widget separately

5条回答
  •  既然无缘
    2020-12-08 11:01

    Thanks for all instructions, it works fine in my Share Extension.

    I did notice that for my Share Extension, the Fabric Answers dashboard did not show actual data for:

    1. Active Users
    2. Median Total Time Spent in App per User

    It does for the companion app. So I was wondering how the Answers SDK would determine this. The most logical seems to monitor the UIApplication notifications. Since the Lifecycle of an Extension is related to a ViewController, these UIApplication notifications are not posted. And hence Fabric doesn't know when the Extension is active.

    So I implemented the following solution, which provides the above data in the Fabric Dashboard:

    1. In 'viewDidLoad' of the Extensions main ViewController, post UIApplicationDidBecomeActiveNotification which will trigger the start for Fabric.
    2. Prior before closing the Extension (via completeRequestReturningItems:completionHandler: or cancelRequestWithError:) post UIApplicationWillResignActiveNotification. This will trigger the stop for Fabric.

    Please note there is a delay between the action on device, and when the data becomes visible in the Dashboard. Especially for Active Users. It takes around 20-30 seconds after the Extension is presented. But when the Extension is closed, it might take up to 5 minutes before the Active Users is decremented.

提交回复
热议问题