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

Testing on Physical Device - no error, no share menu #31

Closed jake-newsom closed 1 year ago

jake-newsom commented 3 years ago

Description

I'm using the code below and on my computer's web browser it just downloads the image (I assume that's fine, idk) but on my android device, nothing happens. I've used the device inspector and checked the console log, I see the console.log() messages all showing up fine and it does end up showing the final "test" meaning there was no error, however no share menu pops up at all. Any idea what I'm doing wrong here?

    shareBlog: async function(){
        const imageUrl = "https://i.imgur.com/hrpUdJp.jpeg";

        const b64data = await this.getBase64FromUrl(imageUrl);
        const fb64 = b64data.replace(/^data:image\/[a-z]+;base64,/, "");
        console.log(fb64);

        const contentType =  b64data.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0];
        console.log(contentType);

        const resp = await FileSharer.share({
            filename: "test.jpeg",
            base64Data: fb64,
            contentType: contentType,
        }).then(() => {
            console.log("test");
        }).catch(error => {
            console.error("File sharing failed", error.message);
        });

        console.log(resp);

    }

Capacitor version:

Run npx cap doctor:

Latest Dependencies:

  @capacitor/cli: 3.2.0
  @capacitor/core: 3.2.0
  @capacitor/android: 3.2.0
  @capacitor/ios: 3.2.0

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 3.1.2
  @capacitor/core: 3.2.0
  @capacitor/android: 3.2.0

[success] Android looking great! 👌

Library version:

Your Plugin Configuration

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": false,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
moberwasserlechner commented 3 years ago

The current version 2.0.0 of this plugin does NOT support Capacitor 3.x. I hope to release the new version before October.

jake-newsom commented 3 years ago

@moberwasserlechner Ah ok! Thanks for the quick response! I assumed without errors showing up that my current set up was correct. Apologies, very new to the whole ionic ecosystem.

moberwasserlechner commented 2 years ago

I released the new version 3.0.0 today

If you can and it is still relevant please test this issue with the new version. (Capacitor 3.0.0 required)

I keep this issue open a few days and close it afterwards if there is no feedback.

BR Michael

moberwasserlechner commented 1 year ago

Closed as outdated.