taljacobson / flutter_mailer

A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
MIT License
47 stars 39 forks source link

Unhandled Exception: PlatformException(UNAVAILABLE, default mail app not available, null) #30

Closed 0xdhu closed 4 years ago

0xdhu commented 4 years ago

Hello. While using flutter mailer package in iphone version, I have this issue. `[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: PlatformException(UNAVAILABLE, default mail app not available, null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:570:7)

1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)

#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12) #3 FlutterMailer.send (package:flutter_mailer/flutter_mailer.dart:9:21) #4 MailService.sendMailToClient (package:fai_reciept/service/mailservice.dart:18:25) #5 PdfViewerPage.build. (package:fai_reciept/billhome.dart:632:37) #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:989:19) #7 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1095:38) #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) #9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:522:11) #10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5) #11 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7) #12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9) #13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12) #14 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9) #15 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8) #16 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18) #17 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7) #18 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19) #19 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22) #20 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7) #21 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7) #22 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7) #23 _rootRunUnary (dart:async/zone.dart:1206:13) #24 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #25 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7) #26 _invoke1 (dart:ui/hooks.dart:281:10) #27 _dispatchPointerDataPacket (dart:ui/hooks.dart:190:5)` I am using xcode version 11.0 (11A420a) Target: iOS11.0 Device: iphone, iPad flutter doctor -v `[✓] Flutter (Channel dev, 1.18.0-11.1.pre, on Mac OS X 10.15.5 19F101, locale en-CN) • Flutter version 1.18.0-11.1.pre at /Users/kk/Developer/flutter • Framework revision c2b7342ca4 (3 months ago), 2020-05-06 23:16:03 +0800 • Engine revision e8c13aa012 • Dart version 2.9.0 (build 2.9.0-14.0.dev 5c1376615e) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at /Users/kk/Library/Android/sdk • Platform android-29, build-tools 29.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 11.0) • Xcode at /Users/kk/Downloads/Xcode.app/Contents/Developer • Xcode 11.0, Build version 11A420a • CocoaPods version 1.9.1 [✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 46.0.2 • Dart plugin version 193.7361 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [✓] IntelliJ IDEA Ultimate Edition (version 2020.1) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 45.1.3 • Dart plugin version 201.7223.43 [✓] VS Code (version 1.46.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.12.1 [✓] Connected device (1 available) • iPhone • 00008020-000414A00178002E • ios • iOS 13.5.1 `
taljacobson commented 4 years ago

Are you testing on a physical device, or through the simulator?

On iOS it required the default mail app to work. And that error is returned when it is not found.

0xdhu commented 4 years ago

Thank you for your quick response. I am testing in real physical device.

can you please tell me how to set the default mail app to work?

taljacobson commented 4 years ago

its the pre installed mail app by apple https://apps.apple.com/us/app/mail/id1108187098.

On Tue, Jul 21, 2020 at 1:54 PM CuiYongHu notifications@github.com wrote:

Thank you for your quick response. I am testing in real physical device.

can you please tell me how to set the default mail app to work?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/taljacobson/flutter_mailer/issues/30#issuecomment-661785454, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDQIUJ53ECNHWTHJ5VTOA3R4VXWXANCNFSM4PDNIPXA .

0xdhu commented 4 years ago

I have just installed mail app from appstore. And I build app to my iphone again. but it has same problem.....

taljacobson commented 4 years ago

If at least one email account is enabled on the device, the following call should return YES:

[MFMailComposeViewController canSendMail] Conversely, if all accounts are disabled/removed, it will return NO.

https://stackoverflow.com/a/3671759/8469022

the ios code that is returning the UNAVAILABLE error uses MFMailComposeViewController canSendMail which returns a boolean response for availability of the service. since i cant reproduce your error something in the stackoverflow link might be relevant

0xdhu commented 4 years ago

Yes. For now, any email account was not enabled to my device. Let me check after enable my email account to device. Thank you.

0xdhu commented 4 years ago

wow. Great I works perfect. Thank you so much to @taljacobson