Last active
February 14, 2022 18:46
-
-
Save DVDPT/3f81d9216f0cbfab3b4746fb5d529467 to your computer and use it in GitHub Desktop.
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
// | |
// Made by furic | |
// https://github.com/furic | |
// | |
// A deep linking launcher to be used with the Unity plugin Universal Deep Linking (https://assetstore.unity.com/packages/slug/125172?aid=1100l8RBa) | |
// It checks if the game is already running, if it is it shares the deep link activation using a shared file, if not it launches the game | |
// Documentation on integration with a launcher application: https://universaldeeplinking.imaginationoverflow.com/docs/Internals/#standalone-activation-after-launch | |
// | |
// | |
using System.Diagnostics; | |
using System.IO; | |
class MainClass | |
{ | |
public static void Main(string[] args) | |
{ | |
if (args.Length == 0) { | |
System.Console.WriteLine("No argment set."); | |
return; | |
} | |
// Get the activation uri | |
var uri = args[0]; | |
System.Console.WriteLine("uri=" + uri); | |
string executablePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "<YOUR_GAME_NAME>.exe"); | |
string linkFilePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ShareLink.txt"); | |
System.Console.WriteLine("executablePath=" + executablePath); | |
System.Console.WriteLine("linkFilePath=" + linkFilePath); | |
// Check if your app/game is running | |
if (Process.GetProcessesByName("<YOUR_GAME_NAME>").Length == 0) { | |
//if not simply launch it with the activationUri as argument | |
Process p = new Process { | |
StartInfo = new ProcessStartInfo(executablePath, uri) | |
}; | |
p.Start(); | |
} else { | |
// Write in the share file the uri so that the app/game can extract it | |
File.WriteAllText(linkFilePath, uri); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment