-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make game unfocused on incoming call
- Loading branch information
1 parent
3642268
commit 555f00b
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Linq; | ||
using CallKit; | ||
using Foundation; | ||
|
||
namespace osu.Framework.iOS | ||
{ | ||
internal class IOSCallObserver : NSObject, ICXCallObserverDelegate | ||
{ | ||
private readonly Action onCall; | ||
private readonly Action onCallEnded; | ||
|
||
private readonly CXCallController callController; | ||
|
||
public IOSCallObserver(Action onCall, Action onCallEnded) | ||
{ | ||
this.onCall = onCall; | ||
this.onCallEnded = onCallEnded; | ||
|
||
callController = new CXCallController(); | ||
callController.CallObserver.SetDelegate(this, null); | ||
|
||
if (callController.CallObserver.Calls.Any(c => !c.HasEnded)) | ||
onCall(); | ||
} | ||
|
||
public void CallChanged(CXCallObserver callObserver, CXCall call) | ||
{ | ||
if (!call.HasEnded) | ||
onCall(); | ||
else | ||
onCallEnded(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
callController.Dispose(); | ||
base.Dispose(disposing); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters