In your Unity project click on Tools > TriumphSDK > Generate Unity Native Methods
This will generate file TriumphUnityNativeMethods:
usingUnityEngine;usingUnityEngine.SceneManagement;namespaceTriumphSDK{publicclassTriumphUnityNativeMethods:MonoBehaviour,ITriumphUnityNativeMethods { // place your game ID herepublicstaticreadonlystring gameId =""; // place your merchant ID herepublicstaticreadonlystring merchantId ="";publicvoidTriumphStartedGame() {/* TODO: implement method */ }publicvoidTriumphDidDismiss() {/* TODO: implement method */ }publicvoidTriumphDidPresent() {/* TODO: implement method */ }publicvoidTriumphWillDismiss() {/* TODO: implement method */ }publicvoidTriumphWillPresent() {/* TODO: implement method */ } }}
Then, you need to click Tools > TriumphSDK > Generate API Prefab
Which will generate Prefab file called TriumphAPI. This prefab is an empty GameObject with two important MonoBehaviour components: TriumphAPI and TriumphUnityNativeMethods. Ensure that this prefab is in the first loaded scene of your game (i.e. the main menu).
Now, navigate to the TriumphUnityNativeMethods component of the TriumphAPI prefab. Grab the gameId for your game from the Triumph Dashboard (under your game's go live tab) and set it to the gameId variable in this file.
usingUnityEngine;usingTriumphSDK;publicclassTriumphUnityNativeMethods:MonoBehaviour,ITriumphUnityNativeMethods { // REQUIRED CONFIG IMPLEMENTATION /* * Put your gameId here! Use gameId = "" if you want to test * out our Sandbox mode before creating a dev account */publicstaticreadonlystring gameId ="YOUR_GAME_ID";/* * If you have playable or video tutorial within your game, * please specify this by setting it to true */publicstaticreadonlybool hasTutorial =false;}
Be sure to import TriumphSDK at the top level of any file that uses Triumph.
To configure Triumph Leaderboards, navigate to the AppDelegate.swift willFinishLaunchingWithOptions method, and add the configuration method Triumph.configure. Grab the gameId for your game from the Triumph Dashboard and pass it in as a parameter.
Please note that it's required to configure Triumph in willFinishLaunchingWithOptions
importTriumphSDKfuncapplication(_application: UIApplication, willFinishLaunchingWithOptionslaunchOptions: [UIApplication.LaunchOptionsKey :Any]?=nil) ->Bool {/* * @Params: * gameId -- Your game ID */ Triumph.configure(id:"YOUR_GAME_ID")returntrue}
If you have playable or video tutorial within your game, please specify this setting within the configuration:
importTriumphSDKfuncapplication(_application: UIApplication, willFinishLaunchingWithOptionslaunchOptions: [UIApplication.LaunchOptionsKey :Any]?=nil) ->Bool {/* * @Params: * gameId -- Your game ID * options -- Configuration options */ Triumph.configure( id:"YOUR_GAME_ID", options: .init( hasTutorial:true// set to true if you have tutorial))returntrue} asd
Next, to receive push notifications you should pass the data in these AppDelegate methods: