-
Notifications
You must be signed in to change notification settings - Fork 52
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
Use of UIApplication.shared prevents usage within ios extensions #47
Comments
This is very interesting and I will probably run into the same bottleneck very soon. Thanks |
I solved it, but it's probably not the ideal way, not even sure a pull request would work with this. It's not ideal, not fully tested, but I've made progress with this so far. I honestly think some documentation on this would be better but after it's tested further. Especially since with different targets for different classes, it's not exactly something I would suggest baking in the repo. You could add the #ifdef to the repo, but then you'd need to document what macro/define I as the user would need to set in my target's build settings. I believe AFNetworking does this, maybe you can use the same define as they do. Again, I haven't tested this further than seeing that it compiles and runs. There may be some functions/features I'm not aware of where this breaks/falls apart. Also, the keyboard hiding code you have will not execute on an extension, I'm not sure how to address that. With that said, here's what I did: I edited PasscodeLockPresenter.swift to make the toggle method overridable.
Then I override that method in my class that implements PasscodeLockPresenter and added some C compile flags -DTARGET_APP_EXTENSION and macro TARGET_APP_EXTENSION=1 under the build settings for my app extensions.
Then for repository which requires "group" capabilities:
And a special display class for extensions since the window object cannot be retrieved.
And finally, in my UIViewController for the extension (e.g., share):
It works for me in my limited testing with the Share extension using my own UIViewController (instead of SLComposeViewController or whatever the default is). I'm not too sure how you could handle this and what a pull request would even look like with this. It's really just documentation and then supporting that documentation for app extensions like Share and Document Provider. |
Thanks for the shared info @fuji7l. Any suggestion, in code or documentation form, is welcomed. Feel free to make a PR. I wasn't able to test your code because of lack of time. If you can also add this in a demo, this will be great. Otherwise, your advice above is also helpful, if somebody requests the same. I might have a look at some point. |
I'll see what I can do. I only have access to a mac while at work, so I'll try to get something together - can't guarantee when though. |
I am running into this now. Looking forward to see a solution for app extension in the repository! |
IOS extensions like share, document provider, etc do not allow access to UIAplication.shared.
This results in a compile time error due to
PasscodeLockPresenter.swift line 55.
The text was updated successfully, but these errors were encountered: