Skip to content

Commit 1028421

Browse files
committed
Update iOS deployment target to 13.0, enhance email composition features, and improve mail app detection and settings access.
1 parent 3a14be3 commit 1028421

File tree

8 files changed

+206
-220
lines changed

8 files changed

+206
-220
lines changed

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>12.0</string>
24+
<string>13.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '12.0'
2+
# platform :ios, '13.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ EXTERNAL SOURCES:
2424
:path: ".symlinks/plugins/url_launcher_ios/ios"
2525

2626
SPEC CHECKSUMS:
27-
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
27+
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
2828
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
2929
open_mail: 490d7633e966119c4b6a4f9ddf6c0747b9a7e8c9
3030
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
3131

32-
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
32+
PODFILE CHECKSUM: 4f1c12611da7338d21589c0b2ecd6bd20b109694
3333

3434
COCOAPODS: 1.16.2

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@
455455
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
456456
GCC_WARN_UNUSED_FUNCTION = YES;
457457
GCC_WARN_UNUSED_VARIABLE = YES;
458-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
458+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
459459
MTL_ENABLE_DEBUG_INFO = NO;
460460
SDKROOT = iphoneos;
461461
SUPPORTED_PLATFORMS = iphoneos;
@@ -585,7 +585,7 @@
585585
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
586586
GCC_WARN_UNUSED_FUNCTION = YES;
587587
GCC_WARN_UNUSED_VARIABLE = YES;
588-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
588+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
589589
MTL_ENABLE_DEBUG_INFO = YES;
590590
ONLY_ACTIVE_ARCH = YES;
591591
SDKROOT = iphoneos;
@@ -636,7 +636,7 @@
636636
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
637637
GCC_WARN_UNUSED_FUNCTION = YES;
638638
GCC_WARN_UNUSED_VARIABLE = YES;
639-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
639+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
640640
MTL_ENABLE_DEBUG_INFO = NO;
641641
SDKROOT = iphoneos;
642642
SUPPORTED_PLATFORMS = iphoneos;

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<MacroExpansion>
3132
<BuildableReference
@@ -54,6 +55,7 @@
5455
buildConfiguration = "Debug"
5556
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5657
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
58+
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
5759
launchStyle = "0"
5860
useCustomWorkingDirectory = "NO"
5961
ignoresPersistentStateOnLaunch = "NO"

example/lib/main.dart

Lines changed: 40 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ignore_for_file: use_build_context_synchronously
22

3-
43
import 'package:flutter/material.dart';
54
import 'package:open_mail/open_mail.dart';
65

@@ -11,6 +10,18 @@ void main() {
1110
class MyApp extends StatelessWidget {
1211
const MyApp({super.key});
1312

13+
EmailContent get emailContent => EmailContent(
14+
15+
subject: 'Hello!',
16+
body: 'How are you doing? [Debug: ${DateTime.now()}]',
17+
18+
19+
attachments: [
20+
// Example file path (must be accessible and supported by the mail app)
21+
// 'file:///path/to/your/file.pdf',
22+
],
23+
);
24+
1425
@override
1526
Widget build(BuildContext context) {
1627
return Scaffold(
@@ -25,7 +36,7 @@ class MyApp extends StatelessWidget {
2536
ElevatedButton(
2637
child: const Text("Open Mail App"),
2738
onPressed: () async {
28-
// Try to open the mail app
39+
//TODO: open default mail inbox only
2940
var result = await OpenMail.openMailApp(
3041
nativePickerTitle: 'Select email app to open',
3142
);
@@ -50,45 +61,30 @@ class MyApp extends StatelessWidget {
5061

5162
// Button to test mail app detection
5263
ElevatedButton(
53-
child: const Text("Debug Mail App Detection"),
64+
child: const Text("Debug Mail App Detection (Custom Picker)"),
5465
onPressed: () async {
5566
try {
56-
// Get installed mail apps with detailed logging
57-
// Debug print removed
5867
var options = await OpenMail.getMailApps();
59-
// Debug print removed
60-
// Debug print removed
61-
// Show the list of detected mail apps
6268
showDialog(
6369
context: context,
64-
builder: (_) {
65-
return AlertDialog(
66-
title: Text('Detected ${options.length} Mail Apps'),
67-
content: SingleChildScrollView(
68-
child: Column(
69-
mainAxisSize: MainAxisSize.min,
70-
crossAxisAlignment: CrossAxisAlignment.start,
71-
children: options
72-
.map((app) => ListTile(
73-
title:
74-
Text('${app.name} (${app.nativeId})'),
75-
subtitle: Text(
76-
'ID: ${app.nativeId ?? "No ID"}, Scheme: ${app.iosLaunchScheme ?? "No Scheme"}'),
77-
))
78-
.toList(),
79-
),
80-
),
81-
actions: [
82-
TextButton(
83-
child: const Text('Close'),
84-
onPressed: () => Navigator.of(context).pop(),
85-
),
86-
],
87-
);
88-
},
70+
builder: (_) => MailAppPickerDialog(
71+
mailApps: options,
72+
itemBuilder: (context, app, fn) => ListTile(
73+
onTap: () async {
74+
// TODO: open specific mail app inbox only
75+
await OpenMail.openSpecificMailApp(
76+
app.name, emailContent);
77+
},
78+
leading:
79+
const Icon(Icons.email), // Placeholder for icon
80+
title: Text(app.name),
81+
subtitle: Text(app.iosLaunchScheme ?? "No ID"),
82+
),
83+
),
8984
);
9085
} catch (e) {
9186
// Debug print removed
87+
debugPrint('Error: $e');
9288
}
9389
},
9490
),
@@ -97,48 +93,25 @@ class MyApp extends StatelessWidget {
9793
ElevatedButton(
9894
child: const Text('Open mail app, with email already composed'),
9995
onPressed: () async {
100-
// Define the content of the email with debug info
101-
EmailContent email = EmailContent(
102-
to: ['[email protected]'], // Recipient(s)
103-
subject: 'Hello!', // Email subject
104-
body:
105-
'How are you doing? [Debug: ${DateTime.now()}]', // Email body with timestamp for debugging
106-
cc: ['[email protected]', '[email protected]'], // CC recipients
107-
bcc: ['[email protected]'], // BCC recipients
108-
);
109-
110-
// Debug log
111-
// Debug print removed
112-
11396
OpenMailAppResult result;
11497

11598
try {
116-
// Try to compose a new email in a mail app
11799
result = await OpenMail.composeNewEmailInMailApp(
118100
nativePickerTitle: 'Select email app to compose',
119-
emailContent: email);
101+
emailContent: emailContent);
120102

121-
// Debug log after attempt
122-
// Debug print removed
123-
124-
// If no mail apps are installed
125103
if (!result.didOpen && !result.canOpen) {
126104
showNoMailAppsDialog(context);
127-
}
128-
// If multiple mail apps are available on iOS, show a picker
129-
else if (!result.didOpen && result.canOpen) {
105+
} else if (!result.didOpen && result.canOpen) {
130106
showDialog(
131107
context: context,
132108
builder: (_) => MailAppPickerDialog(
133109
mailApps: result.options,
134-
emailContent: email,
110+
emailContent: emailContent,
135111
),
136112
);
137113
}
138114
} catch (e) {
139-
// Catch and print any exceptions
140-
// Debug print removed
141-
// Show error dialog to user
142115
showDialog(
143116
context: context,
144117
builder: (_) => AlertDialog(
@@ -212,6 +185,14 @@ class MyApp extends StatelessWidget {
212185
title: const Text("Open Mail App"),
213186
content: const Text("No mail apps installed"),
214187
actions: <Widget>[
188+
TextButton(
189+
child: const Text("Settings"),
190+
onPressed: () async {
191+
// Open device settings (works for both iOS and Android)
192+
await OpenMail.openDeviceSettings();
193+
Navigator.pop(context);
194+
},
195+
),
215196
TextButton(
216197
child: const Text("OK"),
217198
onPressed: () {

0 commit comments

Comments
 (0)