Open tomholub opened 3 years ago
@tomholub should it works exactly as compose view controller does?
It should be the compose view controller itself used for this
yes, I understand, but taking ComposeViewController to extension leads to chain of files that needed as well, that's why I was asking that question.
anyway, answer received, thank you :)
Unfortunately I'm not sure I understand the question (or your answer).
but taking ComposeViewController to extension leads to chain of files that needed as well
Could you explain more? What do you mean by "taking to extension" - what does it mean, what kind of extension?
Or "chain of files" - chain of what files?
in this task, we need to add flow crypt app as an option from iOS to share file within our app.
it is developed by adding share extension for iOS app. Share extension, is different target with its own limitations, etc.
we cannot just open ComposeViewController there. we need:
so basically, its a big "chain" of files and problems that we need to solve.
in some cases, as apple recommend, special lightweight copies of that classes are created only for share extension. that's why I asked if we need exact same controller there.
Thank you for the explanation. This is a much bigger task than I thought.
Unfortunately, since we're composing an email like any other, I think we actually need the whole composeviewcontroller (and its dependencies) in that target.
This is a much bigger task than I thought.
yes, that's why I have started from solving dependencies that we have in our app for share extension. this will probably not require big code change and I hope that big refactoring PR will be merged soon.
Thank you for clarifications
While working on sharing frameworks for share extension ( which I am working on in scope of current task ) I am stuck with problem:
After adding GoogleAPIClientForRest_Gmail
to Frameworks & Libraries
of share extension, I am getting error:
could not build Objective-C module 'GoogleAPIClientForREST_Gmail'
.
MBProgressHUD
)related discussions: https://github.com/google/google-api-objectivec-client-for-rest/issues/388 https://github.com/google/google-api-objectivec-client-for-rest/issues/478
maybe you have any ideas, @sosnovsky @ivan-ushakov ? I will really appreciate any ideas/tips.
@ekievsky I think I fixed this issue in the main FlowCrypt
target by adding SWIFT_PACKAGE=1
flag to Preprocessor Macros
setting in Build Settings
configuration. Can you try to add it to sharing extension too?
@sosnovsky works for me! thank you
@tomholub status update:
currently created app share extension itself ( part that will allow sharing ) and shared most common files/classes with this app extension. ( it took a while because that chain is really big )
right now I have several issues that are not easy to solve.
GmailService
is using GmailUserService
inside, and GmailUserService
uses AppAuth
framework which has UIApplication
related code inside. Unfortunately we cannot use this framework in app extension because of that code, that's why I will look about a solution.
Also, there are a few todos left, to solve that dependencies problems as well.
Why is it that UIApplication cannot be used in app extension?
Some APIs Are Unavailable to App Extensions:
Because of its focused role in the system, an app extension is ineligible to participate in certain activities. An app extension cannot:
Access a sharedApplication object, and so cannot use any of the methods on that object
....
sharedApplication object: https://developer.apple.com/documentation/uikit/uiapplication/1622975-shared
there are some workarounds, that I will try to check/review them and I will look for general solution as well
@ekievsky
I think that using current JavaScript code in extension could be a problem. Maybe we could go with old school URL scheme? For now we could add public.image
and maybe some other types. This allows to stay with current code base, no need for extension.
That sounds a lot simpler, if it can achieve a similar result
@ivan-ushakov currently I have already spent some ( a lot ) of time of working in extension. I will try to finish it, and if its not working correctly and some more work needed I will try to do that with URL scheme
If the functioning of the extension requires that it communicates with the main app - because some functionality (google session) is only available on the main app - then you'll need to add a message mechanism between the extension and the app. Which is complex (high chance of bugs).
@ivan-ushakov as far as I understand, you are offering:
after user taps on our app from share menu, we need to open custom url schema ( with params, skip that for now ) from didAppear of that @objc(ShareExtensionViewController) class?
@ivan-ushakov ^
(wrong tag, sorry)
if I understood correctly, we wont be able to get rid of transition screen. we need to add some spinner/ui there, like "flow crypt app will be opened in a while" and after that, when our app is opened, act with that image/(some other file) inside flow crypt app.
but it sounds less job than support of share extension as @tomholub mentioned.
@tomholub are we ok with this flow?
if we are fine - I can discard all those shared files and move forward with this solution
I would wait and discuss it some more time. From the look of it, I'd rather avoid building the extension (with all of the dependencies and some possible restrictions that we have to work around) if we can avoid it.
It's not the most urgent issue. Now that we know that building an extension that includes the full compose screen may be problematic, let's discuss and explore other ways. Ivan and Roman may have some input.
@tomholub sure. as far as I see after @ivan-ushakov proposal:
@ivan-ushakov let me know if everything looks fine for you, and thank you very much for your proposal
PS: @tomholub meanwhile switching back to finalize #942, and than to #902. thank you
PS: @tomholub meanwhile switching back to finalize #942, and than to #902. thank you
sounds good - thanks
@ekievsky Looks you are right, for some reason UTI does not work with Share menu in iOS. So the only way to have our app in Share menu is to have share extension. Your approach looks fine, the only problem I see:
The dotted line in Figure 2-2 represents the limited interaction available between an app extension and its containing app. A Today widget (and no other app extension type) can ask the system to open its containing app by calling the openURL:completionHandler: method of the NSExtensionContext class.
So maybe it is not possible to open our app from extension.
Maybe we could just copy resource in extension and say to user something like "Please continue composing in FlowCrypt app".
There is some hack but not sure if Apple reviewers allow this.
I used hack from @ivan-ushakov comment in another app - https://apps.apple.com/us/app/transom-note-taker-for-writers/id927983947 and it works well there, user can open app after creating new note from share extension.
Let's try that approach, but later. I've mis-prioritized this issue earlier.
When I open a photo or screenshot (or other file) and click the iOS share icon, I'd like FlowCrypt to be one of the options alongside WhatsApp, Gmail etc.
Tapping that will open a new compose screen with that file attached. The caret should be on recipient field.