Implement the Skillz Delegate
Overview​
Control of your application is given to Skillz when you launch the Skillz UI. Because of this, you'll need to implement the Skillz Delegate interface, which contains callbacks that will be invoked for key events. There are two events that are essential for interacting with Skillz:
- When a match is starting.
- When the user is exiting the Skillz UI (via the sidebar menu).
The following sections describe how to implement these two methods of the Skillz Delegate for each platform.
Important Note for Unity Integrations​
To better understand how the Skillz SDK works with Unity please refer to our guidance on Unity Script Execution
- Unity/C#
- iOS/Objective-C
- iOS/Swift
- Android/Java
For Unity, you need to implement the SkillzMatchDelegate
interface as a regular C# class. This will be instantiated when launching Skillz later.
using SkillzSDK;
using UnityEngine.SceneManagement;
public sealed class SkillzGameController : SkillzMatchDelegate
{
private const string GameSceneName = "Level1"; // Your game scene name
private const string StartMenuSceneName = "StartMenu"; // Your menu scene (optional)
public void OnMatchWillBegin(Match matchInfo)
{
}
public void OnSkillzWillExit()
{
}
}
Implementation of these methods will be covered later.
For iOS, the Skillz Delegate is available as a protocol named SkillzDelegate
. It is common to conform to this protocol in the interface that conforms to UIApplicationDelegate
.
#import <UIKit/UIKit.h>
#import <Skillz/Skillz.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, SkillzDelegate>
@end
@implementation AppDelegate
- (void)tournamentWillBegin:(NSDictionary * _Nonnull)gameParameters
withMatchInfo:(SKZMatchInfo * _Nonnull)matchInfo {
}
- (void)skillzWillExit {
}
@end
Don't worry about implementing these methods for now. We'll discuss how later.
For iOS, the Skillz Delegate is available as an interface named SkillzDelegate
. It is common to adhere to this in the class that adheres to UIApplicationDelegate
.
import UIKit
import Skillz
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, SkillzDelegate {
func tournamentWillBegin(_ gameParameters: [AnyHashable : Any]!, with matchInfo: SKZMatchInfo!) {
}
func skillzWillExit() {
}
}
Don't worry about implementing these methods for now. We'll discuss how later.
For Android, the Skillz Delegate takes the form of special <meta-data>
tags that are added inside the <application>
element of your app's AndroidManifest.xml
.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="<your_package_name>" xmlns:tools="http://schemas.android.com/tools">
<application>
<meta-data android:name="skillz_game_activity" android:value="<your_game_activity>" />
<meta-data android:name="skillz_exit_activity" android:value="<your_activity_on_skillz_exit>" />
</application>
</manifest>
The skillz_game_activity
tag tells the Skillz SDK which activity to launch when a match starts. The skillz_exit_activity
tag tells the Skillz SDK which activity to launch if the user exits the Skillz UI.