mixpanel / mixpanel-iphone

Official iOS (Objective-C) Tracking Library for Mixpanel Analytics
http://mixpanel.com
Apache License 2.0
1.05k stars 565 forks source link

Is it possible to use the Mixpanel iOS library inside an application extension? #152

Closed barfoon closed 9 years ago

barfoon commented 10 years ago

If so, how? Currently there are many referenecs to [UIApplication sharedApplication], which is not accessible in application extensions.

Thanks,

piemonte commented 10 years ago

+1

official support would be nice. any uses of UIApplication aren't available so it would be nice to define a means for avoiding it or just updating the read me to explicitly state the install is different.

here was the issue tracking AFNetworking changes:

https://github.com/AFNetworking/AFNetworking/issues/2119

alex-hofsteede commented 10 years ago

@barfoon @piemonte, I will have a look into how we can do this. The main issue would appear to be with background tasks, as well as using a preprocessor #ifdef to remove all the non-relevant parts of the Mixpanel SDK such as Surveys and Notifications. It does seem possible in theory.

mmezzacca commented 10 years ago

At the moment we're firing a call to our servers from the app extension which then will manually ping Mixpanel server-side, but would be much nicer to do natively. Looking forward to a solution, thanks!

benpious commented 10 years ago

It is actually possible to use Mixpanel inside an extension with Cocoapods presently, in case that helps anyone.

barfoon commented 10 years ago

@alex-hofsteede Just wondering if there were any updates on this one?

alex-hofsteede commented 10 years ago

@barfoon Sorry I haven't had the time to work on this one yet. Will update when I do.

transitive-bullshit commented 10 years ago

+1 while it is possible to use Mixpanel inside of an extension, Mixpanel does not properly send events making it useless for my use case.

Note that I'm referencing a custom keyboard extension, and having added MIXPANEL_DEBUG/MIXPANEL_LOG to the preprocessor, it appears that Mixpanel falsely views its state as offline and queues / archives all events instead of reporting them. Here's a gist with verbose mixpanel output showing the issue (note that this is on a device with full connectivity).

JosephLin commented 9 years ago

@fisch0920 I'm seeing the exact same thing. Manually calling 'flush' seems to work for me. Does doing that have any serious downside?

iamtony commented 9 years ago

@alex-hofsteede - Hello, are there any updates to this?

athasach commented 9 years ago

Looks like it's fixed in v2.8.0. https://github.com/mixpanel/mixpanel-iphone/releases/tag/v2.8.0

arittr commented 9 years ago

@iamtony @athasach yes, this is now fixed as of v2.8.0 - let us know if you run into any issues

alex-hofsteede commented 9 years ago

yep use pod "Mixpanel/AppExtension" for your app extension target in your Podfile. I'll put up some docs on the site about this.

piemonte commented 9 years ago

nice :ok_hand:

JoeFerrucci commented 6 years ago

This thread is outdated. The latest solution is to use pod 'Mixpanel-swift-appex' and can be referenced here: https://github.com/mixpanel/mixpanel-swift/issues/75#issuecomment-289661136