taljacobson / flutter_mailer

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

[PPT] Error creating the CFMessagePort needed to communicate with PPT. #45

Open martin-robert-fink opened 3 years ago

martin-robert-fink commented 3 years ago

On iOS get the error: [PPT] Error creating the CFMessagePort needed to communicate with PPT. when using FlutterEmailSender.send(email).

The email window comes up as expected. If I send or cancel the email, then I get the following error stream:

[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:609 (
    0   AXRuntime                           0x00000001a5fb2c24 638F11FF-7696-30F3-A29E-8ECB6147567D + 322596
    1   AXRuntime                           0x00000001a5f685dc _AXGetPortFromCache + 708
    2   AXRuntime                           0x00000001a5f69cec AXUIElementPerformFencedActionWithValue + 488
    3   UIKit                               0x00000001f08bdc70 89D9DA59-C6CA-39FF-AF87-AB9019F15DC6 + 932976
    4   libdispatch.dylib                   0x0000000180ef1c04 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 7172
    5   libdispatch.dylib                   0x0000000180ef3950 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 14672
    6   libdispatch.dylib                   0x0000000180efb0ac 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 45228
    7   libdispatch.dylib                   0x0000000180efbc10 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 48144
    8   libdispatch.dylib                   0x0000000180f06318 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 90904
    9   libsystem_pthread.dylib             0x00000001f05b11b0 _pthread_wqthread + 288
    10  libsystem_pthread.dylib             0x00000001f05b0f50 start_wqthread + 8
)
[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:609 (
    0   AXRuntime                           0x00000001a5fb2c24 638F11FF-7696-30F3-A29E-8ECB6147567D + 322596
    1   AXRuntime                           0x00000001a5f685dc _AXGetPortFromCache + 708
    2   AXRuntime                           0x00000001a5f69cec AXUIElementPerformFencedActionWithValue + 488
    3   UIKit                               0x00000001f08bdc70 89D9DA59-C6CA-39FF-AF87-AB9019F15DC6 + 932976
    4   libdispatch.dylib                   0x0000000180ef1c04 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 7172
    5   libdispatch.dylib                   0x0000000180ef3950 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 14672
    6   libdispatch.dylib                   0x0000000180efb0ac 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 45228
    7   libdispatch.dylib                   0x0000000180efbc10 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 48144
    8   libdispatch.dylib                   0x0000000180f06318 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 90904
    9   libsystem_pthread.dylib             0x00000001f05b11b0 _pthread_wqthread + 288
    10  libsystem_pthread.dylib             0x00000001f05b0f50 start_wqthread + 8
)
[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:609 (
    0   AXRuntime                           0x00000001a5fb2c24 638F11FF-7696-30F3-A29E-8ECB6147567D + 322596
    1   AXRuntime                           0x00000001a5f685dc _AXGetPortFromCache + 708
    2   AXRuntime                           0x00000001a5f69cec AXUIElementPerformFencedActionWithValue + 488
    3   UIKit                               0x00000001f08bdc70 89D9DA59-C6CA-39FF-AF87-AB9019F15DC6 + 932976
    4   libdispatch.dylib                   0x0000000180ef1c04 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 7172
    5   libdispatch.dylib                   0x0000000180ef3950 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 14672
    6   libdispatch.dylib                   0x0000000180efb0ac 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 45228
    7   libdispatch.dylib                   0x0000000180efbc10 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 48144
    8   libdispatch.dylib                   0x0000000180f06318 959CD6E4-0CE7-3022-B73C-8B36F79F4745 + 90904
    9   libsystem_pthread.dylib             0x00000001f05b11b0 _pthread_wqthread + 288
    10  libsystem_pthread.dylib             0x00000001f05b0f50 start_wqthread + 8
)

Here's the flutter doctor -v:

mfink@MacBook-Pro bin % flutter doctor -v
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-arm, locale en-US)
    • Flutter version 2.5.1 at /Users/mfink/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffb2ecea52 (4 days ago), 2021-09-17 15:26:33 -0400
    • Engine revision b3af521a05
    • Dart version 2.14.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mfink/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.10.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.60.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.26.0

[✓] Connected device (3 available)
    • Martin iPad Pro (mobile) • 00008027-001259C10CF8402E • ios            • iOS 15.0 19A346
    • macOS (desktop)          • macos                     • darwin-arm64   • macOS 11.6 20G165
      darwin-arm
    • Chrome (web)             • chrome                    • web-javascript • Google Chrome
      93.0.4577.82

• No issues found!

is there something I'm doing wrong? Thanks!

taljacobson commented 3 years ago

don't believe your doing something wrong. can you provide more context of when this accurse. what device your using, are you sending attachments, where are the attachments located (application cache/external storage). are you awaiting the response?

martin-robert-fink commented 3 years ago

Hi - Thanks for the response. I'm using FlutterMailer to allow users to send feedback and/or request support. I am collecting device/app info, and attaching a few critical files. The app is only running on an iPad. I am awaiting sendFeeback(). Below is the entire code file:

import 'dart:io';
import 'dart:convert';

import 'package:archive/archive_io.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart';
import 'package:get/get.dart';
import 'package:flutter_mailer/flutter_mailer.dart';

import '../global_constants/constants.dart';
import '../controllers/project_controller.dart';
import './package_info.dart';
import './device_info.dart';

Future<String> get emailBody async {
  final appInfo = await packageInfo();
  final deviceInfo = await iosDeviceInfo();
  String body = 'Thank you for taking the time to provide feedback.\n\n';
  body = body + 'Type your feedback or support request here: \n\n\n';
  body = body + 'Information for troubleshooting: \n';
  body = body + 'App Version: ${appInfo[PackageInfoType.version]}\n';
  body = body + 'Build: ${appInfo[PackageInfoType.buildNumber]}\n';
  body = body + 'OS Version: ${deviceInfo[DeviceInfoType.osVersion]}\n';
  body = body + 'Device Type: ${deviceInfo[DeviceInfoType.hardwareType]}\n';
  return body;
}

Future<String?> get vcdFile async {
  Directory docDirectory = await getApplicationDocumentsDirectory();
  var vcdFile = join(docDirectory.path, Constants.vcdZipFileName);
  return (File(vcdFile).existsSync()) ? vcdFile : null;
}

Future<String?> get projectFile async {
  final _pc = Get.find<ProjectController>();
  Directory docDirectory = await getApplicationDocumentsDirectory();
  try {
    _pc.setupProjectForSaving();
    String encoded =
        const JsonEncoder.withIndent('  ').convert(_pc.project.toJson());
    String compressed =
        base64.encode(GZipEncoder().encode(utf8.encode(encoded))!);
    var projectFile = join(docDirectory.path, Constants.projectZipFileName);
    File(projectFile).writeAsStringSync(compressed, flush: true);
    return projectFile;
  } catch (_) {
    return null;
  }
}

Future<List<String>> get _attachments async {
  List<String> attachments = [];
  final _pc = Get.find<ProjectController>();
  if (_pc.isProjectOpen) {
    String? project = await projectFile;
    if (project != null) attachments = [project];
    String? vcd = await vcdFile;
    if (attachments.isNotEmpty && vcd != null) attachments.add(vcd);
    if (attachments.isEmpty && vcd != null) attachments = [vcd];
    return attachments;
  }
  return <String>[];
}

Future<void> sendFeedback() async {
  List<String>? attachments = await _attachments;
  final MailOptions mailOptions = MailOptions(
      subject: 'Support/Feedback',
      body: await emailBody,
      recipients: [Constants.feedbackEmailAddress],
      attachments: attachments,
      isHTML: false);
  try {
    await FlutterMailer.send(mailOptions);
  } catch (_) {}
}
taljacobson commented 3 years ago

apologies, i cant repreduce the issue. might be an issue with ipads, which i have none.

only reference i can see with a fix is this, https://developer.apple.com/forums/thread/120696

if any one can help a PR would be much appreciated.