Hello,
If your app is playing an audio/video, you can receive the AVAudioSession.InterruptionNotification, and do something in its callback method. And you cannot detect the system-event if your app is not playing an audio/video.
Please refer to the following code:
var player = new AVPlayer(new NSUrl("https://XXXXX"));
player.Play();
NSNotificationCenter.DefaultCenter.AddObserver(
AVAudioSession.InterruptionNotification, (notification) =>
{
var okAlertController = UIAlertController.Create("Title", "The message", UIAlertControllerStyle.Alert);
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
// Present Alert for testing UIApplication.SharedApplication.Delegate.GetWindow().RootViewController.PresentViewController(okAlertController, true, null);
});
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.