Git Product home page Git Product logo

capacitor-email-composer's Introduction

Hi there, i'm Hans 👋

I believe in the power of the web 💯 My passion is building mobile Apps with the Ionic Framework.

capacitor-email-composer's People

Contributors

einfachhans avatar ikosta avatar jzubero avatar sreejith-mv avatar tobium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

capacitor-email-composer's Issues

Gradle 9 incompatibility warning

Just upgraded to latest android studio and gradle

I get the below warning. Just thought to share it in advance, before it becomes an issue.


Configure project :capacitor-email-composer
The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 9.0. JFrog announced JCenter's sunset in February 2021. Use mavenCentral() instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.0.2/userguide/upgrading_version_6.html#jcenter_deprecation
at build_2ipo04td9ux7yf2iiwh1495i2$_run_closure1$_closure2.doCall(C:\projects\truckMate\truckmateII_cap\node_modules\capacitor-email-composer\android\build.gradle:11)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
at build_2ipo04td9ux7yf2iiwh1495i2$_run_closure1.doCall(C:\projects\truckMate\truckmateII_cap\node_modules\capacitor-email-composer\android\build.gradle:9)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)

Thanks, wim

Unable to inject Capacitor, Plugins won't work

I have used this plugin for a while in a Capacitor/Angular app I have developed for Android. I am updating this app to Capacitor 4 now but I am experiencing issues with the email-composer plugin.

I have updated the capacitor-email-composer to version 1.2.1, and building the app works fine. But when I am trying to call the EmailComposer.open() function I get in Logcat: Unable to inject Capacitor, Plugins won't work.

This project also uses the capacitor-native-biometric plugin and that one seems to work fine.

I have tried rebuilding the Android project, reïnstalling the dependency but this doesn't seem to work.

Any clue on what the problem could be?

Feature Request - Callback on Email send/cancel

Love the plugin...much better than trying to use a Cordova plugin in an all Capacitor app.

I have a request if this is possible. I ran across this when testing an email send. After a user sends an email, I clear the form and display a success message. However, if the user cancels the action instead of clicking send, the form still clears and the success message displays because I don't know that they cancelled it...just that the email window has been closed.

Would it be possible to add a callback to the open() method to determine whether the email window was cancelled or if the email was actually sent?

Let me know what you think.
Thanks!

App Crash due to android.os.TransactionTooLargeException

Android 12
Ionic 6
Capacitor 4

I'm taking a screenshot using Capacitor Screenshot, and attempting to email it via Capacitor Email Composer.

I'm using the following code

let openOptions: OpenOptions = {
	attachments: [{
			name: 'screenshot.png',
			path: this.dataurl.split(",")[1],
			type: 'base64',
		}],
	body: 'Screenshot attached',
	bcc: [],
	cc: [],
	isHtml: false,
	subject: 'Screenshot',
	to: [],
};
EmailComposer.open(openOptions);

Gmail opens and I see the attached screenshot, and everything appears to of populated correctly for roughly 1 second before the app crashes. I can still send the email as all the data is correctly inserted. I don't see any console log errors. Removing the attached image prevents the crash.

----- Below is the DEBUG log generated by Android Studio -----

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: *removed*, PID: 5935
    java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 710264 bytes
        at android.app.ActivityClient.activityStopped(ActivityClient.java:86)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8663)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
     Caused by: android.os.TransactionTooLargeException: data parcel size 710264 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:635)
        at android.app.IActivityClientController$Stub$Proxy.activityStopped(IActivityClientController.java:1358)
        at android.app.ActivityClient.activityStopped(ActivityClient.java:83)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:313) 
        at android.app.ActivityThread.main(ActivityThread.java:8663) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 
I/Process: Sending signal. PID: 5935 SIG: 9
Disconnected from the target VM, address: 'localhost:53579', transport: 'socket'

The screenshot image is only 693kb. Shouldn't this be a try/catch that generates a console.log? Also, how do I discover the file size limit? If it exceeds the limit, why is it still correctly populated in gmail?

Error when launching Android "package android.content does not exist"

I seem to be running into an issue launching with the build error:

error: package android.content does not exist
import android.content.Context;

This seems to be the only package causing an issue, if I remove it the app launches fine.

I have attempted on two Android devices:

  • Pixel 5 API 31 (emulated)
  • Pixel 5 API 32 (physical device)

Here's my Ionic info and some Android settings, let me know if you have a solution or need more info. Thanks!

Ionic:

Ionic CLI : 6.19.1
Ionic Framework : @ionic/angular 6.2.6
@angular-devkit/build-angular : 13.3.9
@angular-devkit/schematics : 13.3.9
@angular/cli : 13.3.9
@ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 3.7.0
@capacitor/android : 3.7.0
@capacitor/core : 3.7.0
@capacitor/ios : 3.7.0

variables.gradle

minSdkVersion = 22
compileSdkVersion = 32
targetSdkVersion = 33
androidxActivityVersion = '1.2.0'
androidxAppCompatVersion = '1.2.0'
androidxCoordinatorLayoutVersion = '1.1.0'
androidxCoreVersion = '1.3.2'
androidxFragmentVersion = '1.3.0'
junitVersion = '4.13.1'
androidxJunitVersion = '1.1.2'
androidxEspressoCoreVersion = '3.3.0'
cordovaAndroidVersion =  '10.1.1'
// capacitor-background-geolocation variables
googlePlayServicesLocationVersion = '18.0.0'

Fixed versions prevent installation

% ionic start foo blank --type=angular --capacitor

% npm install capacitor-email-composer
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @capacitor/[email protected]
npm ERR! node_modules/@capacitor/core
npm ERR!   @capacitor/core@"5.0.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @capacitor/core@"5.0.0" from [email protected]
npm ERR! node_modules/capacitor-email-composer
npm ERR!   capacitor-email-composer@"*" from the root project

iOS Compiler Version issue in Capacitor 4.01 and Ionic 6.2.2

On Capacitor 4.01 and Ionic 6.2.2, I am getting an error in iOS for Plugin Compiler version. Could you please able to update the compiler version to 13?

❌ /Users/runner/work/-----/node_modules/capacitor-email-composer/ios/Plugin/EmailComposer.swift:2:8: compiling for iOS 12.0, but module 'Capacitor' has a minimum deployment target of iOS 13.0: /Users/runner/Library/Developer/Xcode/DerivedData/App-evsdlgyukodovrgtwbzbgondoaey/Build/Intermediates.noindex/ArchiveIntermediates/App/BuildProductsPath/Release-iphoneos/Capacitor/Capacitor.framework/Modules/Capacitor.swiftmodule/arm64-apple-ios.swiftmodule

JSON as attachment

Would it be possible to add the possibility to attach a large text i.e. a stringified JSON object,

I would like to avoid the cycle through the file system.

Kind regards
wim

open() is not a function

Following the example from npm runkit https://npm.runkit.com/capacitor-email-composer and modifying the code to be as such:

require("@capacitor/core/package.json"); // @capacitor/core is a peer dependency. 
var capacitorEmailComposer = require("capacitor-email-composer")
capacitorEmailComposer.open({})

I receive the error 'TypeError: capacitorEmailComposer.open is not a function’

When importing and using like this:

import { EmailComposerPlugin } from 'capacitor-email-composer';
EmailComposerPlugin.open({})

I receive the same error 'TypeError: capacitorEmailComposer.open is not a function’

Thank you for your help.

Error if no email account on device

Just tested with an iPhone with iOS 15 and no email account.

To Native -> EmailComposer open 126488619 2021-10-02 18:44:50.261700+0200 App[434:10379] [MFMailComposeViewController] Unable to initialize due to + [MFMailComposeViewController canSendMail] returns NO. 2021-10-02 18:44:50.263913+0200 App[434:10379] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <Capacitor.CAPBridgeViewController: 0x10540b540>.' *** First throw call stack: (0x181f0b05c 0x19a425f54 0x1847f237c 0x1845dc9b4 0x184578dfc 0x1846ef638 0x184601de0 0x104cce438 0x104cce4dc 0x105124a20 0x105126700 0x105136a90 0x181ec3ce4 0x181e7debc 0x181e913c8 0x19d6a238c 0x1848370bc 0x1845b4be8 0x104b60ddc 0x104df5a24) libc++abi: terminating with uncaught exception of type NSException dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <Capacitor.CAPBridgeViewController: 0x10540b540>.' terminating with uncaught exception of type NSException

EmailComposerPlugin.open gibes error, doesn't compile

`import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
import { EmailComposerPlugin, OpenOptions } from 'capacitor-email-composer';
...
async sendMail() {
const options: OpenOptions = {
to: ['[email protected]'],
subject: 'Unfall',
body: 'Meine Unfallfotos',
attachments: [{
type: "base64",
path: 'data:image/jpeg;base64,${this.imageData}',
name: 'Unfallfotos'
}]
};

await EmailComposerPlugin.open(options?: OpenOptions);

}

`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 {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 /**
~~~~~~~``

Error to import interface in angular app

I tried to inject with a simple "public emailComposer: EmailComposerPlugin" in my constructor but I get this error:
RROR Error: Uncaught (in promise): Error: This constructor is not compatible with Angular Dependency Injection because its dependency at index 1 of the parameter list is invalid.
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.

Please check that 1) the type for the parameter at index 1 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.
Error: This constructor is not compatible with Angular Dependency Injection because its dependency at index 1 of the parameter list is invalid.
This can happen if the dependency type is a primitive like a string or if an ancestor of this class is missing an Angular decorator.

Please check that 1) the type for the parameter at index 1 is correct and 2) the correct Angular decorators are defined for this class and its ancestors.

Not working on iOS

Hi @EinfachHans !

First of all thank you very much for the plugin! Sadly it doesn't work on iOS for me. When I try to call EmailComposer.open(...) I get this error message:

Error: "EmailComposer" plugin is not implemented on ios

I'm for sure using the latest version (1.1.3). From my understanding this plugin should be implemented on iOS as well, at least I can see some iOS source files. Any idea what's causing this issue for me?

Best,
Sven

Attachments

How much work would it be to support attachments? We would like to migrate from cordova-email-composer but require attachments being sent.

App crashes on IOS

Hi,
I have configured outlook as default mail provider.
When I try to open email composer the app is crashing with below error.

⚡️ To Native -> EmailComposer hasAccount 88263923
⚡️ TO JS {"hasAccount":false}
⚡️ To Native -> EmailComposer open 88263924
[MFMailComposeViewController] Unable to initialize due to + [MFMailComposeViewController canSendMail] returns NO.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <Capacitor.CAPBridgeViewController: 0x10610be80>.'
*** First throw call stack:
(0x1aba21e88 0x1a4dc38d8 0x1adefc898 0x1adefb7ec 0x1aded9984 0x1adca7af0 0x1adca792c 0x105044934 0x105044aa8 0x1057145a8 0x10571605c 0x105726810 0x105726354 0x1abab26f8 0x1aba94058 0x1aba98ed4 0x1e44f1368 0x1adf773d0 0x1adf77034 0x104c67e14 0x1ca0f0960)
libc++abi: terminating with uncaught exception of type NSException

Ionic info
Ionic:

Ionic CLI : 7.0.1
Ionic Framework : @ionic/angular 6.7.5
@angular-devkit/build-angular : 13.1.2
@angular-devkit/schematics : 12.1.4
@angular/cli : 13.1.2
@ionic/angular-toolkit : 4.0.0

Capacitor:

Capacitor CLI : 4.8.1
@capacitor/android : not installed
@capacitor/core : 4.8.1
@capacitor/ios : 4.8.1

Usage Example Needed

Hi, thanks for making this plugin and supporting it!

Could you provide an example of how to use this plugin, or describe the steps of importing/injecting it into an Ionic project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.