Closed swissfritz closed 1 year ago
you don't have to inject capacitor plugins in the constructor. Remove it from there. Just import and use it directly
Danke Hans, that's what I tried first and which gave me the TS-error "'EmailComposerPlugin' refers to an object but is being used as a value here." (see first part of my issue). How can I get around that?
please create a minimal reproducable repo
Gerne, https://github.com/swissfritz/einfach.git
Danke Hans!
Fritz
From: Hans @.> Sent: Dienstag, 27. Juni 2023 14:50 To: EinfachHans/capacitor-email-composer @.> Cc: Fritz Frei @.>; Author @.> Subject: Re: [EinfachHans/capacitor-email-composer] EmailComposerPlugin.open gibes error, doesn't compile (Issue #29)
please create a minimal reproducable repo
— Reply to this email directly, view it on GitHub https://github.com/EinfachHans/capacitor-email-composer/issues/29#issuecomment-1608975475 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADT4E4UO27MXC56P6BB4NFTXNKGBLANCNFSM6AAAAAAZU6O7SY . You are receiving this because you authored the thread.Message ID: @.***>
I wondered why OpenOptions didn't provoke a TS error, so I tried tinkering with the Plugins name and ... voilà: EmailComposer worked. So, if I import EmailComposer, OpenOptions from capacitor-email-composer and use them this way in the code, everything works fine. You may have a silent contributor who changed the plugins name to use?
your absolutly right, the plugin is exported as EmailComposer
. I will adjust the readme
Thank you and sorry for the circumstances. Readme is adjusted 😊
Great! Thanks to you for this awesome plugin!
From: Hans @.> Sent: Mittwoch, 28. Juni 2023 15:19 To: EinfachHans/capacitor-email-composer @.> Cc: Fritz Frei @.>; Author @.> Subject: Re: [EinfachHans/capacitor-email-composer] EmailComposerPlugin.open gibes error, doesn't compile (Issue #29)
Thank you and sorry for the circumstances. Readme is adjusted 😊
— Reply to this email directly, view it on GitHub https://github.com/EinfachHans/capacitor-email-composer/issues/29#issuecomment-1610975122 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADT4E4SWMZE7VTH2H6FW6RLXNPSJBANCNFSM6AAAAAAZU6O7SY . You are receiving this because you authored the thread.Message ID: @.***>
`import { Camera, CameraResultType, CameraSource } from '@capacitor/camera'; import { EmailComposerPlugin, OpenOptions } from 'capacitor-email-composer'; ... async sendMail() { const options: OpenOptions = { to: ['fritzfrei45@gmail.com'], subject: 'Unfall', body: 'Meine Unfallfotos', attachments: [{ type: "base64", path: 'data:image/jpeg;base64,${this.imageData}', name: 'Unfallfotos' }] };
}
`gives a TS error (2693): 'EmailComposerPlugin' refers to an object but is being used as a value here.
When I initiate them in the cinstructor ...
constructor(public plug:EmailComposerPlugin, public opts: OpenOptions)
and
await this.plug.open(this.opts);
... npm run build gives the following error:
This type does not have a value, so it cannot be used as injection token. node_modules/capacitor-email-composer/dist/esm/definitions.d.ts:1:1 1 export interface EmailComposerPlugin {