Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with iOS Extensions #54

Closed
wants to merge 58 commits into from
Closed

Make compatible with iOS Extensions #54

wants to merge 58 commits into from

Conversation

andyyc
Copy link

@andyyc andyyc commented Oct 16, 2015

I'm trying to use the sdk with a keyboard extension. Unfortunately, sharedApplication is unavailable in iOS extensions.

This diff replaces calls to sharedApplication with performSelector. This has been done in other places like SDWebImage here: SDWebImage/SDWebImage#1082 and doesn't appear to present any issues with App Store review.

@andyyc
Copy link
Author

andyyc commented Jan 22, 2016

@djih any chance you could take a look at this?

@djih
Copy link
Member

djih commented Feb 9, 2016

@andyyc I can take a look next week. Have you tested this with your extension?

@andyyc
Copy link
Author

andyyc commented Feb 12, 2016

thanks @djih. I've been using it in my app and haven't ran into any
issues, i.e. it runs fine without crashing and events are being logged. I
am a little concerned, though, that some metrics are logged incorrectly due
to the fact that 'enterForeground' is never called. I'm wondering if a
better solution would be simply to remove background uploading in the
extension entirely or switching to using NSURLSession to create a
background task as suggested here in "Performing Uploads and Downloads":
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html

On Tue, Feb 9, 2016 at 3:05 PM, djih [email protected] wrote:

@andyyc https://github.com/andyyc I can take a look next week. Have you
tested this with your extension?


Reply to this email directly or view it on GitHub
#54 (comment)
.

@djih
Copy link
Member

djih commented Feb 19, 2016

@andyyc so regarding the enterForeground, what kind of metrics are incorrect? All events logged will be in the "background" state, so if more than 5 minutes passes between logEvent calls, then it will start a new session. Maybe one temporary solution is just to increase the 5 min to something like 30 min.

Also it looks like in iOS 8.2 they added NSExtensionHostWillEnterForegroundNotification, which might be useful: http://stackoverflow.com/a/29988550, although our SDK currently has to support iOS 6.0. I wonder if it might be possible to still use those 8.2 methods if available.

Are there any issues with the background uploading? Do you need access to the app's data? Otherwise I don't think the NSURLSession and shared container is necessary.

Also, can you update from master (looks like there aren't any conflicts)? I fixed a bunch of flakey tests so your tests should pass now.

@andyyc andyyc closed this Mar 3, 2016
@andyyc andyyc deleted the make_extension_compatible branch March 3, 2016 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants