moberwasserlechner / capacitor-filesharer

Capacitor plugin to download and share files for the Web, Android and iOS! Stop the war in Ukraine!
MIT License
82 stars 20 forks source link

Capacitor 4.0 support #39

Closed AshleyMedway closed 1 year ago

AshleyMedway commented 2 years ago

I think #38 is missing the podspec and gradle changes

Additional if you want to install this early in your project you can run npm i ProteanSoftware/capacitor-filesharer#master

tho-masn commented 2 years ago

@AshleyMedway: Did you have any troubles with this Branch, Capacitor 4 and Android so far? I keep getting the following error. Not sure if it's because of the Capacitor 4 upgrade though.

E/DatabaseUtils: Writing exception to parcel
    java.lang.SecurityException: Permission Denial: reading com.byteowls.capacitor.filesharer.FileSharerProvider uri content://com..... from pid=27862, uid=1000 requires the provider be exported, or grantUriPermission()
        at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:912)
        at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:830)
        at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:708)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:247)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:107)
        at android.os.Binder.execTransactInternal(Binder.java:1215)
        at android.os.Binder.execTransact(Binder.java:1179)
moberwasserlechner commented 2 years ago

If you are confident that this works I'm happy to merge and release a new version asap, but I do not have the time to test it myself. BR

AshleyMedway commented 2 years ago

Let me do some further testing today. I've got to do a regression of our app in Capacitor 4 today. Will report back :)

tho-masn commented 2 years ago

I've tested the branch with a few devices (iOS and Android) and everything looks good so far. The error I mentioned above is still happening on Android as soon as a file gets shared, but it doesn't seem to have any negative consequences.

hermitdemschoenenleben commented 2 years ago

in addition to the error mentioned above, my android app also crashes after sharing with the following exception:

     Caused by: java.lang.IllegalArgumentException: method com.byteowls.capacitor.filesharer.FileSharerPlugin.callbackComplete argument 2 has type android.app.Instrumentation$ActivityResult, got androidx.activity.result.ActivityResult
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.Plugin.triggerActivityCallback(Plugin.java:155)
        at com.getcapacitor.Plugin.lambda$initializeActivityLaunchers$0$com-getcapacitor-Plugin(Plugin.java:117)
        at com.getcapacitor.Plugin$$ExternalSyntheticLambda0.onActivityResult(Unknown Source:6)
        at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:409)
        at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:366)
        at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:712)
        at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:140)
        at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:173)
        at android.app.Activity.dispatchActivityResult(Activity.java:8613)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:5340)

Does anybody know how to fix this? A naive fix by changing the type of result in callbackComplete to androidx.activity.result.ActivityResult didn't work, because I can't import this.

tho-masn commented 1 year ago

@hermitdemschoenenleben Did you install the PR with npm i ProteanSoftware/capacitor-filesharer#master as mentioned in the first post? The description is a bit misleading and actually doesn't work. You need to install the #v4 branch in order to get the latest version, which fixes the ActivityResult.

hermitdemschoenenleben commented 1 year ago

@tho-masn you're right, I was indeed misled by the description and checked out the wrong branch, sorry for that! With the v4 branch, it works fine. Thank you very much for your work and quick response!

moberwasserlechner commented 1 year ago

I'm in the middle of releasing. Which version did you try. 4.0.0 is not released yet.

moberwasserlechner commented 1 year ago

@sander-spruit One more thing: I have no connection to ProteanSoftware. I have planned to do the release this weekend so your rather disrespectful behavior is for sure not the reason I'm releasing. Such comments are not motivating me to spend my spare time in providing open source software.