Skip to content

The second "open in" menu is not shown on iOS #305

Closed
@aleksilahis

Description

@aleksilahis

Expected Behaviour

If showOpenWithDialog is called multiple times, the native "open in" menu is displayed for each files.

Actual Behaviour

The menu is displayed only for the first file. The following error is displayed in console:

2020-08-13 16:08:40.107951+0300 App[14160:747672] Warning: Attempt to present <_UIDICActivityViewController: 0x7faaaa92d800> on <Capacitor.CAPBridgeViewController: 0x7faaa960be90> which is already presenting <_UIDICActivityViewController: 0x7faaa98c7600>

So it doesn't wait until the menu is closed before attempting to open it for the next file(s).

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Call showOpenWithDialog for different files one after the other.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iPad Pro (iOS 12.2)
iPhone SE (2nd gen) simulator (iOS 13.6)

Cordova CLI info

Using this plugin with Capacitor (https://github.com/ionic-team/capacitor).

Versions:

@capacitor/cli: 2.4.0
@capacitor/core: 2.4.0
@capacitor/ios: 2.4.0

Plugin version

cordova plugin version | grep cordova-plugin-file-opener2

Here is the output:

"cordova-plugin-file-opener2": 3.0.4

Sample Code that illustrates the problem

public async showOpenWithDialogs(): Promise<void> {
  const fileWriteResult = await this.saveFileInMobile(`data:application/pdf;base64,' randomData`, ‘File1’, FilesystemEncoding.UTF8);
  const fileWriteResult2 = await this.saveFileInMobile(`data:application/pdf;base64,' randomData`, ‘File2’, FilesystemEncoding.UTF8);

  await this.fileOpener.showOpenWithDialog(fileWriteResult.uri, ‘application/pdf’);
  console.log(‘first file was opened’);

  await this.fileOpener.showOpenWithDialog(fileWriteResult2.uri, ‘application/pdf’);
  console.log(‘second file opened');
}

Logs taken while reproducing problem

[log] - first file was opened 
2020-08-31 13:39:42.477618+0300 App[84907:13446735] Path parameter not encoded. Building file URL encoding it...
2020-08-31 13:39:42.477946+0300 App[84907:13446735] looking for file at file:///Users/aleksi/Library/Developer/CoreSimulator/Devices/ED160F57-3CF7-4337-98CA-B3519E3FC723/data/Containers/Data/Application/78236FAA-28D3-48D3-A456-232E46613E2B/Documents/File2
[log] - second file opened
[log] - Done opening files2020-08-31 13:39:43.440226+0300 App[84907:13446735] Warning: Attempt to present <_UIDICActivityViewController: 0x7fdfdc008c00> on <Capacitor.CAPBridgeViewController: 0x7fdfda609120> which is already presenting <_UIDICActivityViewController: 0x7fdfdc022000>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions