Using a physical android device.
When ComposeEmail is called, the email client opens.
Once the email client opens, the app goes to white screen.
If I go back to the app it will stay on white screen.
If I hit the back button I will be brought to the login screen.
Does there need to be some session management here if an external app opens?
public async void SendEmail(EmailMessage message) {
await Xamarin.Essentials.Email.ComposeAsync(message);
}
According to your description, you want to solve the problem of the white screen of the application. You can implement the operation you want in the OnResume method in the App.xaml.cs class, OnResume will be called when the app goes from the background to the app interface.
In Xamarin, the official support for using Email is provided. You can use Xamarin.Essentials: Email, and it will not show a white screen interface.Information about using Xamarin.Essentials: Email can be found at :Xamarin.Essentials: Email.
Related
I have the MS team's custom tab application for the team's. It is an angular application, it has some internal navigations like navigating from one view to another. When I am sending a notification using the sendActivityNotification API call, it reaches to the mobile app. With the click of the notification, the application loads and it works fine.
But after navigation, if I tap on the back button of the device or (<-) button from the MS team's app header then it behaves like loading the history instead of navigating back to the activity(Feed).
Thanks,
Pratap
I'm working on a Xamarin.Forms app using the Prism library. The app has a phone component to it with integration to CallKit and a SIP library. When the device is locked, a call can be received, which results in the native phone UI for iOS. User can answer the call and hangup. Within the app, there is a Xamarin.Forms page to handle calls. There are events from the iOS service that deals with the calls to interact with the "shared project". The issue that I am running in to is that when the user unlocks the device and returns to the app, the UI is non-responsive.
Scenario:
User starts app and logs in.
User locks device
Incoming call received
User answers call
Behind the scenes (i.e. native phone UI), the call service communicates with the "shared project" to display a Call Screen in the app. Since the phone is locked, the user will not see this now.
User hangs up.
When user hangs up, the call service communicates with the "shared project" that the call has been terminated and to return to the previous screen.
User then unlocks the screen
App is on same screen as when user locked device, but UI is not responsive.
To navigate to the call page, I am doing:
await NavigationService.NavigateAsync(targetPage, null, useModalNavigation: null, animated: animated);
and to return to previous page:
await NavigationService.GoBackAsync(animated: false, parameters: parameters);
NavigationService is of type INavigationService from Prism.
The essential question is: what would make the navigation appear to work, but result in a non-responsive UI? I've found in the past that I need to do the navigation on the main thread. Is there anything else I need to look for?
What I understood that you are looking for a method just like the OnAppearing method of forms page.
You need to implement interface INavigatedAware to your ViewModel. By doing this, 2 methods will be added to your ViewModel "NavigatedTo" and "NavigatedFrom". You need to put your logic into the "NavigatedTo" method. This method will be triggered whenever that particular page will appear on the screen.
I'm building a Windows 8.1 App using Ionic 3. In the app, the user would have to type in a lot of stuff. I want to avoid accidental closure of the app by clicking on 'X' button at the top right corner or by Alt+F4. When the user tries to close the app, is there a way to prevent the default behaviour of closing the app and instead ask a confirmation?
You must override the onbackbutton event to do this.
document.addEventListener('backbutton', function (evt) {
/* BackButton pressed: do nothing */
return;
}, false);
Do NOT use the method shown on that page to exit the app:
throw new Error('Exit'); // This will suspend the app BUT the store will reject it
If you do this to exit your app, it will be rejected by the Microsoft store. To exit the app, remove the event listener and let the backbutton event suspend the app normally.
There's no special event to indicate that the user has closed an app.
App Lifecycle docs for Windows Store Apps.
https://learn.microsoft.com/en-us/previous-versions/windows/apps/hh464925(v=win.10)?redirectedfrom=MSDN#app-close
When the user closes the app or moves the app to background, it enters into a Suspended State. Windows recommends saving user state when the app enters such a state. You can save data in that state thereby achieving the overall goal.
My cross-platform Xamarin Forms app (iOS and Android) needs to send an email (upon request from the user). Right now, when the user presses the appropriate button I'm calling
Page.Navigation.PushAsync(new SendEmailPage)
And then in the SendEmailPage constructor I'm using the DependencyService to send an email:
IMail mail = DependencyService.Get<IMail> ();
mail.SendMessage ("Contents");
I've implemented IMail in both Android and iOS, but looking just at the Android version:
void IMail.SendMessage (string contents)
{
Intent emailIntent = new Intent(Intent.ActionSend);
emailIntent.SetType ("message/rfc822");
emailIntent.PutExtra (Intent.ExtraEmail, new string [] { "me#notreal.com" });
emailIntent.PutExtra (Intent.ExtraSubject, "Subject");
emailIntent.PutExtra (Intent.ExtraText, contents);
Forms.Context.StartActivity (Intent.CreateChooser (emailIntent, "Send email"));
}
When I run this code, and click the appropriate button, it pops up an email "Compose" window with all the appropriate information filled in, and I can click the "send" button to send the mail. Cool!
Side Question: Am I correct in assuming there's no way to send an email "quietly" (without requiring additional user intervention)? This would not be something done maliciously, our app would only do this when the user asked to, and would certainly request the appropriate privileges if this is possible.
Main Question #1: When the "Compose" window comes up, if I click the back button in the title bar, it takes me back to my email Inbox, not back to my application. How do I invoke the email intent/activity in such a way that its back button brings the user back to my app?
Main Question #2: Instead, when the "Compose" window comes up, if I click the back button in the bottom of the screen, it does come back to my app, but tells me "Message saved as draft" which isn't what I want. I would rather have the message deleted, and then re-create it if the user hits the appropriate button again.
For Main Question #1, I believe that starting the activity with
Forms.Context.StartActivityForResult (Intent.CreateChooser (emailIntent, "Send email"));
instead of:
Forms.Context.StartActivity (Intent.CreateChooser (emailIntent, "Send email"));
should work to get you back to your Forms activity. At least in a non-forms app that should work, and I suspect it should in a Form app as well, but not 100% certain.
I can not answer your side question, though I suspect that this is intentional. I am sure you are not intending to do anything malicious and that the user requests the email, but if the OS allowed sending the email without user interaction, developers who are not as ethical as you might abuse the feature. But don't quote me, there may very well be a way to do it, I just don't know how if so.
As for Main Question #2, without changing the behavior of the email client app, I don't see how you could do as you wish as it is the mail client itself that is saving the email as a draft.
Is there anyway to get the context that an app has been opened? ie. Has the user pressed on a received toast notification or have they clicked on the application tile? My reasoning is that I will send the user a toast notification (eg. 1 new message for you!). If they tap on the toast notification I would like the app to open at an inbox like screen as opposed to my home screen.
Add some parameter to Toast or Tile Url. For example, /Views/MainPage.xaml?from=toast that tells you that user tap a toast instead of just launch your app from a menu. It's called Deep Links