Game Maker Firebase Dynamic Links

Welcome to the part three of my Firebase Tools series, Firebase Dynamic Links. Game Maker Firebase Dynamic Links extension. Firstly, I’ll detail you what this extension can do.

Setup Firebase Tools for Game Maker Studio

To be able to use the extension, you must prepare Game Maker Studio 2 to be able to compile for it. Click the link above to complete it.
For now, the extension only works at Android Exports.

What is a Dynamic Link


With Dynamic Links, your users get the best available experience for the platform they open your link on. If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your native app. If a user opens the same Dynamic Link in a desktop browser, they can be taken to the equivalent content on your website.

Retrieved from https://firebase.google.com/docs/dynamic-links/

Game Maker Dynamic Links extension allows you to share an entry point from your app to the internet. This is very much like going to a website, but in this case, you can go to a particular content within your app.

How Dynamic Links Work

Let’s say we created a shortlink like : game.page.link/playWithMarty

If the player has the game installed on their phone, and they opened the link above, they’d be directed to your game directly. You can then know that “your game is opened from this link” and take further actions(Like rewarding players etc.).

Also the links are super dynamic. This means that they work differently for different players. An example would be;

  • Opened from Android : Game is opened if installed, or directed to Google Play to be installed. After installation, you will still get the deep link.
  • Opened from iOS, same above with iTunes.
  • Opened from PC, you can direct them to your Html5 game page, or do whatever you want

DOCUMENTATION

firebase_dynamic_links_debug_mode(True/False);
Description
: Enables or disables debug logging. You’ll see the debug output on Game Maker Studio IDE(Output).
Notice : You can use this function before/after firebase_dynamic_links_init function.

firebase_dynamic_links_init();
Description : Initializes Dynamic Links. After using the function, it will return a Social Async Event includes the deeplink, or N/A if the game is not started from a Deep Link.

Returns : An async ds_map in Social Async Event.
async_load[“category”] = “dynamic_links_deeplink” (String)
async_load[“status”] = 1, 0 or -1
0 : Game is not started with a Deep Link.
1 : The Game is started with a Deep Link.
-1 : Failed to read the Deep Link data.
async_load[“data”] = “FAILED”, “N/A” or a Deep Link (String)
“FAILED” : Is returned when failed.
“N/A” : Is returned when there’s no Deep Link.
Deep Link Data : Is returned when there is a Deep Link. This may be something like game.page.link/martysgame

//Social Async Event
var category = async_load[? "category"];

if (category == "dynamic_links_deeplink")
{
	var status = async_load[? "status"];
	var data = async_load[? "data"];
	if (status==1)  //Yes this app is opened from a deep link.
	{
		show_message_async("This game is opened from the URL : "+string(data));
	}
}

firebase_dynamic_links_shorturl_fast(String domain, String targetURL, string androidPackageName);
Description : Fastest way to create a short link.

Parameters
@0 domain : The domain you created on your Firebase Panel. Your link will be created with that domain and you can add your deep link at the end of the url. (Like your.domain.firebase.etc.com/myDeepLink)

@1 targetURL : The URL that the player will be taken to. If the player does not have your game installed, you can set this link to your game’s Google Play page.

@2 androidPackageName : The package identifier of your Android game. For example : “com.gmdevblog.gameexample”

Returns : An async ds_map is Social Async Event.
async_load[“category”] = dynamic_link_shorturl (String)
async_load[“status”] = 0 or 1
0 : Failed to create a shortlink (Probably there’s no internet connection)
1 : Successfully created the shortlink.
async_load[“data”] = “ERROR” or shortlink (String)
“ERROR” : Failed!
shortlink : The URL of the shortlink.

firebase_dynamic_links_shorturl_fast("https://gmdevblog.page.link/martysDeepLink","https://forums.yoyogames.com","com.gmdevblog.firebasetest");

And after creating the link, our link is created and returned in Social Async Event.

//Social Async Event
var category = async_load[? "category"];
if (category == "dynamic_link_shorturl")
{
	var status = async_load[? "status"];
	var data = async_load[? "data"];
	
	if (status==1)
	{
		show_message_async("Short link created as : "+string(data));
	}
}

Advanced Dynamic Link Creation

This sections covers the functions that are used for creating more advanced – customized dynamic links. We will name this procedure as building a short link. By building a custom short link, you’ll have many options to set. One example is presented below.

ON Android

  • Set Android Package Name : That this dynamic link will open your game if it is installed in the Android device.
  • Android Alternative URL : If the game is not installed in the device, you can redirect the player to this URL. Preferably to the Google Play page.
  • Minimum Android Version : Okay, player have the version 2.0.1, but you want this link to work only in 2.1.0; no problem! Users will be redirected to the Alternative URL(can be Play Store to update their app)

firebase_dynamic_links_builder_begin(String domain, String targetURL);
Description : Starts building a dynamic link. The parameters are the very basic fields of the extension. The targetURL will be used when the link is clicked from PC. You can set different URLs with other functions.

Parameters
@0 domain : The domain you created on your Firebase Panel. Your link will be created with that domain and you can add your deep link at the end of the url. (Like your.domain.firebase.etc.com/myDeepLink)

@1 targetURL : The URL that the player will be taken to. This is the main link that’ll be taken into account. If you don’t set an Android parameter(check the function below), this link will be opened.

Notice : Remember that this function does not return anything. It just starts building the link. We will get the link later.

firebase_dynamic_links_builder_begin("https://gmdevblog.page.link/heyMarty","https://forums.yoyogames.com");

firebase_dynamic_links_builder_android_params(String androidPackageName,String androidAlternativeURL, String minimumVersion);
Description : Sets the Android Parameters of the link. If the shortlink is opened from an Android account, these parameters will be taken into account.

Parameters
@0 androidPackageName
: The application to be opened. For example : com.gmdevblog.FirebaseTest

@1 androidAlternativeURL : If the link is opened from Android and the user has not installed the app, this URL will be visited. You can set it to your Google Play Store page for example.

@2 minimumVersion : If the player has the app installed, but it’s version is not updated to the version you set here, they’ll be redirected to the androidAlternativeURL page.

firebase_dynamic_links_builder_social_meta_params(String SocialTitle, String SocialDescription, String imageURL);
Description : So, when you put your link in a social media page, Facebook for example, how should this look like. Well, you can set that as well.

Parameters
@0 SocialTitle : The title of the link.

@1 SocialDescription : The text that’ll be put into the description field.

@2 imageURL : The image that will be displayed along with text and description.

firebase_dynamic_links_builder_social_meta_params("Hello Social Media","This game is fun and you are invited by Marty","https://myimage.com/image.png");

firebase_dynamic_links_builder_analytics_params(String analyticsSource, String analyticsMedium, string AnalyticsCampaign);
Description : Sets the analytics parameters for the link. This is more related with tracking the usage of the shortlink. You may use it to track an advertising campaign etc.

Parameters
@0 analyticsSource : The source of the link to be tracked. You probably would want to set it to your game’s name.

@1 analyticsMedium : You should search what it means in Google.

@2 analyticsCampaign : Same as above.

firebase_dynamic_links_builder_finish();
Description : Finishes up the shortlink.
Returns : An async ds_map in Social Async Event.
async_load[“category”] = “dynamic_link_shorturl_ext” (String)
async_load[“status”] = 0 or 1
0 : Failed to create the shortlink. (Probably there’s no internet connection)
1 : Successfully created the shortlink.
async_load[“data”] = The shortlink.

var category = async_load[? "category"];

switch(category)
{
	case "dynamic_link_shorturl_ext": //The one we create with ShortURL Builder(Advanced one)
	var status = async_load[? "status"];
	var data = async_load[? "data"];
	
	if (status==1)
	{
		show_message_async("Advanced Short link created as : "+string(data));
	}
	break;
}

Get it on Marketplace (FREE)

Share

Marty

Truely speaking, I don't know what am I doing most of the time.

2 Responses

  1. SuproGames says:

    Is this for GMS1.4 as well? If not, what changes must be done before it can?

    • Marty McFly says:

      Hi. Although I have never tested it in there, the extension should be working. Follow the installation guide here

      One difference here is that your runner files are stored where you installed the game maker, which can be accessed by : Help > Open Gamemaker in Explorer in Game Maker Studio 1.4 IDE.

Leave a Reply