How to open the companion app and go back in from a keyboard extension in iOS - ios

So, I have this requirement where a keyboard extension must be able to open it's companion app and have the user take a specific action in there and then be able to go back to whatever previous app was opened and input some text in the previously selected text field.
Basically, if you take a look at Scandit Keyboard Wedge you'll see that behaviour: the user opens can press the "Scan" button on the custom keyboard and is taken in the companion app. Once a barcode is scanned the app automatically goes back to the previous opened app and inputs the barcode string into the text field that was being edited.
Now, reading through Apple's documentation I see a mention saying that a keyboard extension is not permitted to open another apps. Does this include it's own companion app?
Also, even so, I'm not really sure how I can have the keyboard extension open a custom URL since UIApplication.shared is not available in the keyboard extension.
Now, my second problem is, how does the companion app go back to the previously opened app?
Same goes for Google's own custom keyboard. Now, I found a question about this one here on SO. The answer suggests that this is using a private API to handle this thing. But then I'm curious: how did this even go throw Apple's review process? Am I expected to have my app rejected?

Related

iOS app deep linking: Return to previous app or access current url scheme of current app

I'm developing a custom keyboard for iOS. When I'm e.g. in Safari using my custom keyboard, I have a button in my keyboard to jump to to keyboard containing app. Then in my keyboard app I have the iOS specific "<- Safari" button in the top left corner to jump back to Safari.
Is it possible to programmatically jump back to the source application (in my example Safari)?
Or can I send the original url scheme to my containing app and then open the previous app (could be ANY) by the url scheme?
It must be somehow possible, because the app Scandit Wedge does exactly what I want. I created an empty test app without any url scheme and with the Scandit Wedge keyboard I can go to Scandit app, read barcode and it goes automatically back to the source app.
Here's a video I recorded:
https://www.youtube.com/watch?v=UiHH4NanlkA
To achieve this you have to implement inter-app two way communication using x-callback-url. x-callback is just a "protocol" to format the NSURL to ease the data processing at the receiver end and also allowed the source app to receive the correct callback function. You can explore more this with evernote and this tutorial.

How to dismiss iOS camera Access popup?

My app requests access to the iPhone/iPad camera. This results in the native iOS popup to appear, asking for user confirmation.
Is there a way in which I can dismiss this iOS popup (so before the user has made the OK / Don't Allow choice)?
For recent versions of iOS this popup automatically appears when you request write or read access for iOS Photo Library or use some of the AVFoundation framework components.
You can not dismiss it programmatically but you sure can create your own alert before showing the system one so you can have more control over what the user does.
It is the case in many 3rd party apps because when the user declines the access, it's not easy to ask them to go to settings and re-enable it from there. One of the easiest examples to implement would be something like this.

SKStoreReviewController requestReview does not work in iMessage extension

I tried calling SKStoreReviewController.requestReview() in my iMessage extension, but it never shows the UI. I know the system controls whether or not this appears, but based on the documentation (https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview) it seems like it should appear at least once.
If I move the call to the containing app, it works as expected. The entire user experience is based out of the imessage extension, so this is not really a viable solution

Open the manage tab on the iMessage App Store from a button in an iOS App?

The title pretty much says it all. I need to explain to the user how to add my iMessage App to their phone, is there a way to simply link them straight to it?

Detect when user opens file in app

I was reading this documentation on how to preview a file on my iOS app.
https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html#//apple_ref/doc/uid/TP40010410-SW1
Is there any to detect which app did the user choose? Or any way to kno if he actually tapped on any option?
My problem: iBooks large file (> 700mb). User chooses preview, then taps on the top right corner and chooses to open on iBooks. It takes between 20 to 45 seconds until it jumps to iBooks. If I know that the user tapped any app I could at least show a loading or whatever so he knows something is about to happen.
You can use UIDocumentInteractionControllerDelegate methods to achieve this. Here are the list of methods:
Apple document link

Resources