Customizing Notifier.Plugin Navigation with Xamarin Forms(Android) - xamarin

we were using the Notifier Plugin in our application to show the Notification for our Xamarin Forms application.
Notifier Plugin URL: https://github.com/edsnider/Xamarin.Plugins/tree/master/Notifier
For customizing the Notification Navigation with Android Platform,
Changes made in Plugin.LocalNotifications.Android Source as :
In LocalNotificationsImplementation as "var resultIntent = new Intent(Application.Context,typeof(RedirectActivity));"
In RedirectActivity Activity, we have included "MessagingCenter.Send("SampleAppNotificationNavigation", "RedirectToNavigationPage");"
Changes made in MyApplication.Android Source as :
In our Android application we subscribed messaging center as " MessagingCenter.Subscribe(this, "RedirectToNavigationPage", message =>
{
LoadApplication(new NextPage());
});"
Note: Based on the suggestion from Native to Forms Page Navigation we have implmented the same.
https://github.com/xamarin/xamarin-forms-samples/tree/master/Native2Forms
In our core project App page we have included as "
public class NextPage : Application
{
public NextPage()
{
MainPage = new NavigationPage(new ConfigureServer());
}
}"
Everything is working as expected (till ConfigureServer page constructor and intializecomponent() riased ) but failed to launch the ConfigureServer Page.
Kindly guide us to proceed further.
Thanks in advance.

Related

Shell BackButtonBehavior command binding not working in UWP

I am kind of new to Xamarin development. I tried to change the back button behavior with a binding command, but that didn't seem to work. This is the code for the view:
<Shell.BackButtonBehavior>
<BackButtonBehavior Command="{Binding GoBack}"/>
</Shell.BackButtonBehavior>
And this is the code for the view model:
public CreatePasswordVM()
{
_goBack = new Command(GoBackButton);
}
private ICommand _goBack;
public ICommand GoBack
{
get { return _goBack; }
}
public async void GoBackButton()
{
await Shell.Current.GoToAsync("../..");
}
When I pressed the back button, the method "GoBackButton" didn't call. I want to mention that on Android works.
Shell BackButtonBehavior command binding not working in UWP
Derive from Xamarin Form source code. BackButtonBehavior has not implemented for UWP platform, we could find Android and IOS implementation here and here. But for uwp there is not such tracker and there is not such value in the UWP ShellRenderer. For this scenario, we suggest your post new feature request in the Xamarin Forms github.

Android Issue with Xamarin forms, mvvmcross, tabs and tasks

So i am using mvvmcross 6.2 and Xamarin Forms. I have setup the tabs using this informaiton Is there tabbed layout platform provided by mvvmcross?. I have an iOS app that works fine, When running the android app i get the following exception whenever initating one of the tasks.
Java.Lang.IllegalStateException: 'FragmentManager is already executing transactions'
The app is not busy while doing this so the busy indicator is not showing , however the app takes a very long time to change from login page to the tabs home. the exception does not seem to stop the process but it does really slow down the loading.
in my homeviemodel
public async Task ShowInitialViewModels()
{
tasks.Add(NavigationService.Navigate<tab1ViewModel>());
tasks.Add(NavigationService.Navigate<tab2ViewModel>());
tasks.Add(NavigationService.Navigate<tab3ViewModel>());
tasks.Add(NavigationService.Navigate<tabViewModel>());
await CheckFortab5ViewModel();
await Task.WhenAll(tasks);
}
in my home xaml
[XamlCompilation(XamlCompilationOptions.Compile)]
[MvxTabbedPagePresentation(TabbedPosition.Root, WrapInNavigationPage = true, Animated = false)]
public partial class HomePage : MvxTabbedPage<HomeViewModel>
{
in my tabs
[XamlCompilation(XamlCompilationOptions.Compile)]
[MvxTabbedPagePresentation(TabbedPosition.Tab, WrapInNavigationPage = false, NoHistory = true)]
public partial class tab1page: MvxContentPage<tab1ViewModel>
{
any ideas? should i even be worried about this?

How to navigate to a particular page when user taps on a Local Notification in Xamarin Forms app?

Hi am developing a Xamarin Forms app. i have implemented local notifications in the app. When the notification has fired, upon clicking the notification it has to navigate to a particular page.
In iOS project in Appdelegate.cs i wrote this method
public async override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
which will fire when the user taps on the notification. here i need to navigate to a page. Here i wrote the below line of code
App.Current.MainPage = new NavigationPage(new FavoritesPage());
It is navigating to the Favorites page but it is just displaying a blank page. OnNavigatedTo method is not calling for the FavoritesViewModel and in the Onnavigated to am calling a method which takes id(this id comes from the notification) as parameter to get a particular favorite
Here two questions
1) How to navigate to a Specific page
2) How to pass a parameter along with the page navigation.
Can someone please help me to solve this issue.
For 1:
You want to push to a new Page, but what you did is replacing the app's MainPage. please try PushAsync. You can subscribe a MessagingCenter in App:
public App ()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage());
MessagingCenter.Subscribe<object, string>(this, "Push", async (sender, favoriteID) =>
{
var favorite = new FavoritesPage();
favorite.FavoriteID = favoriteID;
await (MainPage as NavigationPage).PushAsync(favorite, true);
});
}
This Lambda will fire when you call MessagingCenter.Send<object, string>(this, "Push", "01");
The string 01 here is the ID what I want to push.
For 2:
Before I push to a new page, I define a property called FavoriteID in this page, then I pass the string using method above.
Use MessagingCenter, set ContentPage type or url for MessagingCenter.Send, then MessagingCenter.Subscribe & load

How to present an iOS Modal View in MvvmCross

How can I present a modal view on iOS using MvvmCross?
Using Xamarin Studio on iOS and the MvvmCross NuGet version 4.2.2, none of the MvxModalSupportTouchViewPresenter, MvxModalNavSupportTouchViewPresenter or IMvxModalTouchView are even available.
Does the ViewModel even need to know about the fact that a particular view is presented as a modal view on iOS?
MvvmCross is a strong Page navigation framework. Default navigation using ShowViewModel<AViewModel> will use the stack metaphor: one on top of another on Android, slide atop each other on iOS, and use < on either platform to go back.
You can tell the ViewPresenter that a given view is modal by giving it a hint, in the form of an interface marker, by adopting IMvxModalIosView.
At the View Level
Adopt the IMvxModalIosView protocol:
public partial class AView : MvxViewController, IMvxModalIosView
At the AppDelegate Level
Replace var setup = new Setup(this, Window) by:
var presenter = new MvxModalSupportIosViewPresenter(this, Window);
var setup = new Setup(this, presenter);
setup.Initialize();
At the ViewModel Level
No change required. The ViewModel is actually not made aware of the modal presentation. Invoke:
ShowViewModel<AViewModel> // May be modal on certain platforms
To close a Page and go back to the previous one, regardless of your presentation style, use Close(this) on that very ViewModel. This will close a modal dialog, or pop a pushed view. A complete, bindable ICommand may look like this:
public ICommand BackCommand {
get { return new MvxCommand(() => Close(this)); }
}
Notes: In MvvmCross 4.2.2, Touch has been renamed iOS, so IMvxModalTouchView is now IMvxModalIosView. The new using are:
using MvvmCross.iOS.Platform;
using MvvmCross.iOS.Views.Presenters;
Using MvvmCross 5.5.2 all I had to get a modal was to add the following MvxModalPresentation attribute to my iOS view:
[Register("ExampleModalView")]
[MvxModalPresentation(
ModalPresentationStyle = UIModalPresentationStyle.PageSheet,
ModalTransitionStyle = UIModalTransitionStyle.CoverVertical
)]
public class ExampleModalView : MvxViewController
{
public ExampleModalView() {
}
...
}
Launching the modal is simple with the IMvxNavigationService service
await _navigationService.Navigate<ExampleModalViewModel>();
ExampleModalViewModel just needs to be a plain MvvmCross view model inheriting from MvxViewModel.
A useful reference for this is ModalView.cs in the iOS playground project: https://github.com/MvvmCross/MvvmCross/blob/develop/TestProjects/Playground/Playground.iOS/Views/ModalView.cs#L12

add web page in xamarin form

I'm very very new to using Xamarin forms. So new in fact I have just watched the "microsoft xamarin forms for absolute beginners".
I'm trying to include a webpage into the Xamarin form but the only info I can find is
var browser = new WebView {
Source = "http://xamarin.com"
};
This might sound silly but has anyone got a full tutorial on how to include one?
thanks
just create a WebView and assign it to a ContentPage. Then you can either make this page the main page of your app (in the App class) or you can navigate to it from another page.
ContentPage page = new ContentPage {
Content = new WebView { Source = "http://xamarin.com" }
};
To display a website from the internet, set the WebView's Source property to a string URL:
var browser = new WebView
{
Source = "http://xamarin.com"
};
see this:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/webview?tabs=windows#performance

Resources