cjlotz / xamarin.plugins Goto Github PK
View Code? Open in Web Editor NEWCross platform Xamarin Plugins
License: MIT License
Cross platform Xamarin Plugins
License: MIT License
I need a post action for SendEmail method. Can I do this?
I was curious about the logic here. Seems like some overhead to create these in memory. Can't they just be parameters? This would make more sense to me.
Add the ability to include attachments as part of the email.
Running on Android 5.1.1, Google Nexus 6, Project compiled with SDK v23 (6.0).
Version 2.2.1 Produces this error:
E/JavaBinder( 6904): !!! FAILED BINDER TRANSACTION !!!
Simple example of what fails:
public static bool sendEmail(this IEmailTask emailTask, string to, string cc, string subject, string body, string attachment = null) {
if (emailTask.CanSendEmail)
{
var emailBuilder = new EmailMessageBuilder()
.To(to)
.Cc(cc)
.Subject(subject)
.Body(body);
if (attachment != null)
emailBuilder.WithAttachment(attachment);
var email = emailBuilder.Build();
emailTask.SendEmail(email);
return true;
}
return false;
}
If you do a phone call on a device without phone function, the "MakePhoneCall" methode will crash your app.
But the check is not implemented in the framework.
I first want to personally thank you for creating a Plugin for Xamarin for our holiday contest. To get your exclusive Xamarin Swag Bag out to you I just need a bit more information from you. If you can email: [email protected] with the following information we will get the bag out to you.
Name
Street Address
City, State, Zip Code
Country
Phone Number
The URL to this repo
Thank you again and I hope to see even more plugins from you in the future. Always feel free to reach out if you need anything.
Are you able to ship a blank one so it fits in the PCL profile? Also, can it use the same implementation of your WinPhoneRT?
If I download this repo and run the sample project on Android, no email can be sent because the CanSendEmail property is false. Is there something I am missing about how to setup the project?
I've been having this issue since I started using Xam.Plugins.Messaging:
What would be a simple solution in this case?
Either the Android assembly in v3.2.1 of the NuGet package is mixed up with the PCL assembly, or I must be misunderstanding something. See the screenshot from a debug session running on my Android device, showing the EmailMessenger implementation in my Android project throwing NotImplementedException. Looking through the code, it seems like this exception should be thrown in the PCL implementation, but not in the Android implementation.
Nexus 7/10 Tablet doesn,t support calling .
But still the check returns true
Hello,
Thank you for the great plugin.
However when I try to add addresses with the emailbuilder to the bcc box they are added to the cc box.
public void SendForm(string to, string subject, List<string> data, string cc, List<string> bcc, List<string> filePath) {
var emailTask = MessagingPlugin.EmailMessenger;
var email = new EmailMessageBuilder ();
email.To (to);
email.Subject (subject);
email.BodyAsHtml ("<table><tr><td>T1</td><td>T2</td></tr><tr><td>T3</td><td>T4</td></tr><tr><td>T5</td><td>T6/td></tr><tr><td>T7</td><td>T8</td></tr><tr><td colspan=\"2\">span 2</td></tr></table>");
emailTask.SendEmail (email.Build ());
}
I have tried something like this on my native side (I am building a cross-platform application). But I cannot see the table generated inside Gmail or Native email apps on my ASUS Zenfone 2 only the content of the table (just like "T1T2T3T4T5T6T7T8span 2".
Hey there! This is looking great.
For the name of the NuGet package I would go with:
"Messaging Plugin for Xamarin and Windows"
This makes it easy to read through all of the plugins :)
Love the concept behind the messagingcontext, however this limits the plugin in the fact that it can not be used from a portable class library.
You should be able to completely remove the MessagingContext though.
On android you could use: Android.App.Application.Context.StartActivity
on iOS you could use: UIApplication.SharedApplication.KeyWindow.RootViewController.View
If for some reason that is not enough, I would recommend that you have a static Init() method on your iOS and Android implementations that actually take in your UIViewController or Activity and then check against null. This is also a good way to do it if that application context and sharedapplication rootviewcontroller are not sufficient.
When I try to obtain the singleton it just returns null and sends me the exception that it's not implemented, what am I doing wrong ?
Thank you for your time!
If you want I created a few new templates for the icons that you can add to if you want.
If I use MessagingPlugin.SmsMessenger.SendSms the message is pass to the default app (hangout for instance) and never sent (using the intent, it is up to the default app to react to it)
Using SmsManager does send the message directly, but needs permission to do so (SEND_SMS).
Would it be possible to flag what method we would like to use on android platform?
Thanks.
I am trying to use some of your code to send email from my shared project instead of platform specific. Not sure which code I need to use to send from shared project PCL in Xamarin.Forms. Can you help me?
When running on an iPad with iOS 8 and above, CanMakePhoneCall returns true, even if the device cannot make a phone call. The actual attempt at placing a call then does nothing.
When the UI layout is a Xamarin Forms NavigationPage -> Modal NavigationPage I get the following warning when trying to send an email:
Warning: Attempt to present <MFMailComposeViewController: 0x15591e00> on <Xamarin_Forms_Platform_iOS_PlatformRenderer: 0x159978d0> whose view is not in the window hierarchy!
I suspect that it will also occur in other Xamarin Forms UI layouts too.
It appears that there has been work to fix a problem on iOS where a call to CrossMessaging.Current.EmailMessenger.SendEmail()
was failing and producing: Warning: Attempt to present <MFMailComposeViewController> whose view is not in the window hierarchy!
- as discussed in closed issue #24
However, I am using version 3.2.1 of the Xam.Plugins.Messaging NuGet package, and still encountering this issue - please see: http://stackoverflow.com/questions/40273884/how-to-reset-prism-for-xamarin-forms-view-navigation-stack
I have gotten around this problem by modifying the MessagingExtensions class in Plugin.Messaging.iOSUnified, as follows:
private static UIViewController _messagingViewController = null;
private static readonly object messagingControllerLocker = new object();
public static void SetMessagingViewController(UIViewController controller)
{
lock (messagingControllerLocker)
{
_messagingViewController = controller;
}
}
public static void PresentUsingRootViewController(this UIViewController controller)
{
if (controller == null)
throw new ArgumentNullException(nameof(controller));
UIViewController visibleViewController = null;
lock (messagingControllerLocker)
{
visibleViewController = _messagingViewController;
_messagingViewController = null;
}
visibleViewController = visibleViewController ?? GetVisibleViewController(null);
if (visibleViewController == null)
{
throw new InvalidOperationException("Could not find a visible UIViewController on the Window hierarchy");
}
visibleViewController.PresentViewController(controller, true, () => { });
}
So now I call SetMessagingViewController()
with a UIViewController that I have created just before I call SendMail()
, but that feels like kludge; and I would like to migrate away from my custom version of the Plugin.Messaging.iOSUnified library...
Can you add a supported way of doing this?
Hi,
I'm unable to perform a call on iOS. I always get an exception sayin the NSString couldnt be parsed.
I also tried removed whitespaces and signs like "+" from the number but nothing worked.
Any ideas?
Is it possible to add more than 1 recipient in an SMS message?
Hello,
Can you use the AutoDial property in IOS and UWP projects?
In the messaging plugin there's only a reference to Android.
Thank you
Using this simple convenience method:
Device.OpenUri(new Uri("mailto:[email protected]"));
The default email app is launched as expected.
Using the plugin:
var emailMessenger = CrossMessaging.Current.EmailMessenger;
if (emailMessenger.CanSendEmail)
{
emailMessenger.SendEmail("mailto:[email protected]", "", "');
}
Seems to launch a more general text share intent (it's using the simple API there, but even when using the builder and filling all cc, bcc, etc fields, it still doesn't launch the default app).
Is there something I'm missing?
With the latest Xamarin Forms release 2.3.4.214, on SMS, only keyboard shows. Nothing happens on Email. Phone works fine. This is for the iOS version in both device and simulator.
On Android, the dial action only puts the number into the dialer, it doesn't automatically dial.
...as I understand it, if ACTION_CALL is used instead, it will do this.
Thanks!
If the user hasn't set up his mail account with apple mail. CanSendMail is set to false. It would be great however to also try to send mail using Outlook or Google Mail. They have their own URL schemes:
gmail:
https://www.macstories.net/links/gmail-for-ios-url-scheme/
outlook:
http://stackoverflow.com/questions/32369198/i-just-want-to-open-ms-outlook-app-and-see-mailto-screen-using-url-scheme-at-ios
Hi,
first of all, thanks for your efforts on this project.
Since WP8.1 does support email with attachments (via EmailMessage and EmailManager), I wonder if you can update the library and add support for attachments on WinPhone.
Regards,
Michele Noberasco
I would recommend following my "Lazy" loads for each. Else you are creating a new Task each and every time.
Ideally I would say that this could be 3 plugins... 1 for each Interface to be honest such as:
Phone Call Plugin for Xamarin
SMS Plugin for Xamarin
E-mail Plugin for Xamarin
However if keep them all in 1 Messaging plugin for Xamarin (which I think is alright) I would just have 1 interface. There is no real need from what I see to have 3.
You could just have IMessaging and that is it with all of them. Seems to add complexity for using the plugin.
Move build system over to use Cake
When I use the EmailMessageBuilder().WithAttachment() method in a PCL library, the signature is string filePath, string contentType, but when I run it, I get a PlatformNotSupportedException that says, "User EmailMessageBuilder.WithAttachment(Windows.Storage.IStorageFile file). overload instead.
The file path I provided points to local storage. I don't know if that's part of the problem. Also, none of the docs mention contentType, so I set it to mime type text/csv.
My ultimate goal is to get this running on an iPad, so perhaps this is just an issue with UWP? Thank you in advance!
Can you remove the requirement for an emailaddress not to be null and sms recipient not to be null?
I use outlook for my mail account. Seems the check is not for accounts, or does not open the default client? The same check then works if the mail app is restored.
please review my code as I am not able to attach any file in EmailMessageBuilder, Also I need to understand about the ContentType, what should I pass in ContentType?
FileData filedata = await CrossFilePicker.Current.PickFile();
String Path = CrossGetLocalFilePath.Current.GetLocalPath(filedata.FileName);
var emailMessenger = CrossMessaging.Current.EmailMessenger;
if (emailMessenger.CanSendEmail)
{
var email = new EmailMessageBuilder()
.To("[email protected]")
.Subject("Xamarin Messaging Plugin")
.Body("Well hello there from Xam.Messaging.Plugin")
.WithAttachment(Path, "image/jpeg")
.Build();
emailMessenger.SendEmail(email);
}
I was wondering if it would make sense to make the "WithAttahchment" extension method PCL compatible? (Also possibly adding a "SupportsAttachments" property to the EmailMessenger)
This would make it much easier to add attachments to emails in a truly platform independent way.
I am getting this exception on IOS : No overload for method WithAttachment' takes
1' arguments (CS1501)
When I execute the following code:
var smsTask = MessagingPlugin.SmsMessenger;
if (smsTask.CanSendSms)
{
smsTask.SendSms(phoneNumber, textToSend);
}
else
{
Debug.WriteLine($"Unable to text {phoneNumber} - Cannot send SMS text at this time");
}
The text dialog is showing, the correct number is in the "To" area, and the text is placed in the text area, however VERY quickly the text area and the keyboard (including the send button) go away. We used slo-mo video to capture that the text WAS indeed passed to the text app and that it all went away, leaving the dialog just sitting there with the number and a cancel button.
Any ideas what could be causing this?
Running XForms 2.3.1.114
Xam.Plugins.Messaging 3.2.1
hardware is iPad Air 2 (but can duplicate on iPad mini) both running iOS 9.3.5
And it works fine on iPhones
Thanks for any help!
ITNOA
I think is very good if we can send SMS background and silently when user permit our. this API useful for any app that need send SMS automatically.
Add the ability to send through HTML body content
Hi,
I want to send emails in the background without user interaction, even to track if someone wants to authenticate which is not authorized. I already send such information to my Application Insights config in Azure. So I get the info anyway. But for convenience it would be great if I can specifiy a To: (sender) like [email protected] . Currently when the app attempts to send an email the standard android email program choose dialog pops up where a user would have to choose its own email account, which is not the desired behaviour.
thanks,
Eric
This may not be an issue in the sense that it simply may not be supported. Is it possible to get this to work with Pause and Wait symbols eg +643210;034471234 where ; is the same as WAIT for user input. At the moment if you passed that string you'd end up with +643210 appearing on the dial string on android.
If you entered that number in for a contact then you'd see the whole thing on the screen, and then it would work as expected.
Hello, before of all, congrats for sharing this amazing plugin. But, I'm having difficult to find the documentation, like how to install, how to setup, anything that help me to get started. Thanks so much!
The validation on Ipad Mini 2,
Are returning false even with sim card.
Hi @cjlotz,
I was moving to the Android Nougat style FileProvider to handle my app's attachments and found that on line 74 of Messaging/Plugin.Messaging.Android/EmailTask.cs, the attachment logic always adds in "file://".
var uri = Android.Net.Uri.Parse("file://" + attachment.FilePath);
This causes parsing to fail for the FileProvider "content://" style urls.
Would you accept a pull request to fix this? I was planning to replace this with the following:
var uri = Android.Net.Uri.Parse(attachment.FilePath.Contains("content://") ? attachment.FilePath : "file://" + attachment.FilePath);
Thanks!
Dylan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.