How to open file from another app using appium (Open with Option)

I have built a document viewer mobile app for both Android and iOS. Whenever user select a file, if my app supports that file, then in open with context menu my app will be populated. As soon as user selects that file, then that file will be opened in my viewer app.

Which appium script I need to write to test above scenario?