Issue
Any Solution to know if content page is active or called inside a AppDelegate.cs ? because iv installed a plugin NFC, and i want to active the plugin only when NFC.xaml page is active, not when starting the application. in this code am trying to begin session only When page NFC.xaml is active or called
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
// if(App.CurrentNFC.xaml) any way to know the content page ?
Session new NFCNdefReaderSession(this, null, true);
Session?.BeginSession();```
}
}
Solution
When a page is getting active OnAppearing method would be triggered .
So we could use MessagingCenter
here .
NFC.xaml.cs
protected override void OnAppearing()
{
base.OnAppearing();
MessagingCenter.Send<object>(this,"Hi");
}
AppDelegate.cs
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
MessagingCenter.Subscribe<object>(this, "Hi", (obj) >
{
Session new NFCNdefReaderSession(this, null, true);
Session?.BeginSession();
});
}
}
Answered By – ColeX – MSFT