-
Notifications
You must be signed in to change notification settings - Fork 337
Getting started
One version of the plugin must be installed to each native project and PCL/Net.Standard before to be used.
The plugin requires to be initialized. To use a PopupPage inside an application, each platform application must initialize the Rg.Plugins.Popup. This initialization step varies from platform to platform and is discussed in the following sections.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Rg.Plugins.Popup.Popup.Init();
global::Xamarin.Forms.Forms.Init ();
LoadApplication (new App ());
return base.FinishedLaunching (app, options);
}
}
namespace HelloXamarinFormsWorld.Android
{
[Activity(Label = "HelloXamarinFormsWorld", MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Rg.Plugins.Popup.Popup.Init(this, bundle);
Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication (new App ());
}
}
}
In Universal Windows Platform (UWP) applications, the Init method that initializes the Rg.Plugins.Popup is invoked from the App class:
Rg.Plugins.Popup.Popup.Init();
Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Popup.GetExtraAssemblies());
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
...
}
You can read more information about "why do I need to use GetExtraAssemblies
" in the troubleshooting documentation page.
For Android back button to work with the plugin, you should invoke Rg.Plugins.Popup.Popup.SendBackPressed
in your MainActivity
in override method OnBackPressed
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
...
public override void OnBackPressed()
{
if (Rg.Plugins.Popup.Popup.SendBackPressed(base.OnBackPressed))
{
// Do something if there are some pages in the `PopupStack`
}
else
{
// Do something if there are not any pages in the `PopupStack`
}
}
...
}