cordova-plugin-openwith icon indicating copy to clipboard operation
cordova-plugin-openwith copied to clipboard

[iOS 13] Sharing attachments from the Apple mail app no longer works

Open cinnamon-doge opened this issue 5 years ago • 11 comments

Affected iOS Versions: 13.0 and newer

Summary: when attempting to share attachments from the Apple mail app to my Ionic v1 app in iOS 13.0 or newer, I receive the following console printout: "[OpenWithPlugin.m][checkForFileToShare] Sharing text "" and a 0 bytes image". It appears that the file data is no longer passed to my app. On iOS 12 this is working perfectly, and the "bytes" printout has a value.

Making things more interesting, the sharing functionality in gallery and files, as well as Google Drive, Gmail and Outlook, is working on iOS 13 just fine. The issue seems to be isolated to the default mail app. I've tested this on an iPhone 6 (iOS 12.3.1) and an iPhone X (iOS 13.3.1).

Steps to reproduce:

  1. Install your app with cordova-plugin-openwith configured on a device with iOS 13.0 or newer
  2. Open the default Apple mail app and locate an email with an attachment
  3. Open the attachment in the quick preview by tapping it and attempt to share it to your app
  4. Console should log "[OpenWithPlugin.m][checkForFileToShare] Sharing text "" and a 0 bytes image", at least with the plugin verbosity set to debug

cinnamon-doge avatar Jan 31 '20 15:01 cinnamon-doge

I observed the same behaviour, except my ShaeExtension crashes when sharing from Mail App, when Sharing from "Files", the PDF is shared to my App, but i have to manually put my App in Foreground to "make it happen". Pre iOS 13 my App was automatically pulled to front.

My "Customizations" were remove "LoggedIn" Featre, and change this

`- (void) viewDidAppear:(BOOL)animated { [self.view endEditing:YES]; }

- (void) viewDidLoad { [self setup]; [self debug:@"[viewDidLoad]"];`

to this

- (void) viewDidAppear:(BOOL)animated { [self.view endEditing:YES]; [self setup]; [self debug:@"[viewDidLoad]"];

bendspoons avatar Feb 04 '20 13:02 bendspoons

Hi, havent seen your fix from Dec '19. Implemented it, and works with Sharing from Files (iCloud) and Photos. But when trying to share from Mail - my Shareextension crashes, right at

NSDictionary *dict = @{ (according to Device Logs Crash report)

When sharing from e.g. outlook everything works fine. Im testing on iOS 13.3.1.

Anyone experienced this too?

bendspoons avatar Feb 05 '20 13:02 bendspoons

Affected iOS Versions: 13.0 and newer

Summary: when attempting to share attachments from the Apple mail app to my Ionic v1 app in iOS 13.0 or newer, I receive the following console printout: "[OpenWithPlugin.m][checkForFileToShare] Sharing text "" and a 0 bytes image". It appears that the file data is no longer passed to my app. On iOS 12 this is working perfectly, and the "bytes" printout has a value.

Making things more interesting, the sharing functionality in gallery and files, as well as Google Drive, Gmail and Outlook, is working on iOS 13 just fine. The issue seems to be isolated to the default mail app. I've tested this on an iPhone 6 (iOS 12.3.1) and an iPhone X (iOS 13.3.1).

Steps to reproduce:

1. Install your app with cordova-plugin-openwith configured on a device with iOS 13.0 or newer

2. Open the default Apple mail app and locate an email with an attachment

3. Open the attachment in the quick preview by tapping it and attempt to share it to your app

4. Console should log "[OpenWithPlugin.m][checkForFileToShare] Sharing text "" and a 0 bytes image", at least with the plugin verbosity set to debug

CHeck the Updated version, uninstall and reinstall this plugin should work for you!

bendspoons avatar Feb 05 '20 13:02 bendspoons

Ok, just 2 full days of try/error, crying and weeping - i think i managed to solve most of those problems. Now i can (with ios 13):

  • Share from "Files"
  • Share from "Outlook Mail"
  • Share without crash from Mail

Im currentyl testing the whole thing through, ill make a new post when its done!

bendspoons avatar Feb 06 '20 16:02 bendspoons

Ok, just 2 full days of try/error, crying and weeping - i think i managed to solve most of those problems. Now i can (with ios 13):

* Share from "Files"

* Share from "Outlook Mail"

* Share without crash from Mail

Im currentyl testing the whole thing through, ill make a new post when its done!

I'm currently testing your fork of the plugin, and sharing from the Apple mail app doesn't seem to work - it fails without error on iOS 13.3.1 with my app. Sharing from Gmail results in "Nothing to share" being logged.

cinnamon-doge avatar Feb 10 '20 13:02 cinnamon-doge

Im shocked. I changed the lines to work with iOS 13 Mail etc. directly in Xcode - it worked. So i transferred the data to the repo. Done. Today i created a new app with it - and you're right, it does not work at all. I currently have no idea what went wrong, especially because the app where i directly changed the code still works ???

Im looking into it...

bendspoons avatar Feb 13 '20 19:02 bendspoons

Im shocked. I changed the lines to work with iOS 13 Mail etc. directly in Xcode - it worked. So i transferred the data to the repo. Done. Today i created a new app with it - and you're right, it does not work at all. I currently have no idea what went wrong, especially because the app where i directly changed the code still works ???

Im looking into it...

Any progress to report?

cinnamon-doge avatar Mar 09 '20 11:03 cinnamon-doge

@bendspoons did you fix this?

sou2 avatar May 18 '20 09:05 sou2

Im on it, currently it works (tested with many Apps), but i have to do some things manually:

  • copy App Identifier manually to ShareExtension.h (replace dynamic placeholder)
  • change the Identifier in XCode to your.rdn.identifier_.shareextension_ (not applied automatically)
  • sometimes when running "cordova prepare" the .shareextension part is removed again (i do not know why)

Works with ios 11 till iOS 13.4 (tested iPad, iPhone X, iPhone 8)

I think i will publish the approach and instructions at the weekend, ill try to keep you guys posted here

bendspoons avatar May 18 '20 14:05 bendspoons

Any chance for a pull request to this repo? I'm also interested in removing the share ui and just directly open my app. Am I the only one?

HarelM avatar Nov 06 '20 11:11 HarelM

Hey Dominic @bendspoons, I'm wondering if you would be able to share your change as a PR ? Were you able to get it all to work reliability if not maybe some of us can help also and build on top of your work ? Cheers!

IllusionVK avatar Feb 18 '21 12:02 IllusionVK