countly-sdk-ios icon indicating copy to clipboard operation
countly-sdk-ios copied to clipboard

Log events to Countly from App Extension

Open awe-mt opened this issue 4 years ago • 5 comments

Expected Behavior

I expect to be able to add the Countly SDK to an App Extension target (E.g. Siri Intents) and log events to Countly.

Current Behavior

When trying to add the Countly SDK, I encounter multiple errors related to the use of sharedApplication:

'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

Screenshots (if appropriate):

Possible Solution

Most of these are wrapped in #if TARGET_OS_IOS preprocessor directives. Is it possible to identify when the target is an app extension?

Steps to Reproduce (for bugs)

  1. Create an app extension
  2. Add the Countly SDK to it

More Description

We are trying to add analytics to our various Siri Intents to get an idea of how many customers actually use them.

Your Environment

  • Countly iOS SDK version: 19.02
  • Your iOS version: 13.1
  • Any changes you have made to this SDK: none

awe-mt avatar Oct 02 '19 10:10 awe-mt

👍 Any news about this issue? I also need tu send events from several extensions. Action Extension, Credential Provider Extension ...

Ekhoo avatar Nov 07 '19 09:11 Ekhoo

Work in progress. Thanks.

erkanyildiz avatar Jan 13 '20 08:01 erkanyildiz

Any updates on this? We need to use it in an extension as well.

jrendel avatar Oct 21 '20 17:10 jrendel

Same, an update of the progress made since Jan would be appreciated. Extensions are the primary point of access to our app, so not having Countly working in the extension effectively causes us to miss most activity. I'm sure this is not a unique situation for us, especially given the prevalence of widgets.

From a naive look into the situation, it seems most access to UIApplication.shared can be simply disabled.

The best way to make a singular API that works for both App Extensions and Apps is to have two start methods; one that takes a UIApplication? parameter and one that takes a UIViewController. open(url) is accessible through the UIViewController's extensionContext.

lhunath avatar Nov 23 '20 20:11 lhunath

Sorry, this one was left behind due to internal complexities and other prioritizations. This year plan to focus on this more.

Thank you for your understanding.

erkanyildiz avatar Jan 24 '21 06:01 erkanyildiz

What's the state of using Countly in app extension targets? I tried using it by calling start and recordEvent but nothing gets logged. After digging through the code it seems events are batched locally and sent if UIApplication goes to background or is terminated. I don't think either of these happen in extension targets as there isn't an UIApplication. Is there anything that I am missing?

itskoBits avatar Jan 21 '23 16:01 itskoBits

Hello, this SDK still does not support integration in App Extensions.

ArtursKadikis avatar Jan 23 '23 09:01 ArtursKadikis