Game Maker Studio Android Native extension – Deep Link

Hello there!

Deep Linking is quite an important feature we may want to have in our applications.
It allows users to open our application, or sub-menu of our application just by an external link or button from another Application.
This may come handy when working with App Promotion or Incentivized installation services which will require a deep link for opening our application from ads within other applications and maybe also cross reward users between application.

Want to know more about Deep Linking?
Check WikipediaΒ or Android docs.

So, since I needed it for some projects and since Game Maker Studio does not supports it by default, I’ve created a quite simple extension for handling this feature!

It is called DeepLinkEx, it is totally FREE and you can find it HERE ON GAME MAKER MARKETPLACE

Be sure to setup it properly before use!

============================
SETUP
============================

change deeplink URI: go to Extensions>DeepLinkEx>Android and into the Inject into Android Manifest part, change
android:scheme=”myapp” and android:host=”com.myapp.something” with your scheme and host.

 
============================
OPEN APP THROUGH DEEPLINK
============================

now, if your app is installed, if the user goes to the link you set during SETUP which will be something like this
myapp://com.myapp.something
your app will open and you will receive a social async event.
Note: the callback is called after 5 seconds to be sure that the game is opened and there’s an object ready to receive the callback.

 

============================
BASIC USAGE
============================

Basic usage is all about receiving a deep link callback in a SOCIAL ASYNC EVENT.
You will receive “DEEPLINK” marked as “type” and the URI as string within “uri” (in this case “myapp://com.myapp.something”)

Within Game Maker, into a social async event put this code:

var type = string(async_load[? “type”])
var uri = string(async_load[? “uri”])
//check for async event type
if type == “DEEPLINK”
{
//do something
}

NOTE:
The deeplink and the callback will work both if the game is running in background or it is not running at all.

============================
ADVANCED USAGE AND FEATURES
============================

1) Whenever you want, you can use
deepLinkReady()
to “force” the social async call.
You may want to do this if the 5 seconds delay is too much for your app’s design.
You can for example call deepLinkReady() each step, without problems, because if the social async event
has already been called, by default or by deepLinkReady() itself, it won’t be called again.
Even if forced, the social async event won’t be called again.
Thanks goes to Tom Bogin for this feature.

2) At any time, you can call
deepLinkGetUri()
to get the uri data as string (in this case “myapp://com.myapp.something”).
If the uri is not defined you will get the string “no uri”
You can use this to double check the deep link uri if needed.
This function is useful to check the status of the callback, too.
If deepLinkGetUri() is defined and good, it means that the app has been opened through the deeplink.
For example in a step even you can put this code:
if deepLinkGetUri() == myapp://com.myapp.something”
{
//deep link has been received
//do something
}
So, with a little bit of additional logic, you can also use this extension, without adding any social async event
or deepLinkReady(), by just checking the status of deepLinkGetUri()

I would still suggest using the async social event callback, with deepLinkReady() if needed, keeping deepLinkGetUri()
just to get the Uri, but it really depends on your specific needs.

 

============================
SPECIAL THANKS
============================
Tom Bogin for the deepLinkReady() feature

Remember that I’m doing this totally for FREE! So to support me don’t forget to rate and review the extension on Game Maker Marketplace, or download my games from Google Play!

If you need help, support or anything else, don’t hesitate to contact me or reply to this blog entry.

That’s all, happy coding!

Comments

  • October 7, 2015

    […] The AppsFlyer OneLink solution for Gaming is based on deep linking. If you don’t know what deep link is, or how to implement it on Game Maker, I’ve made a blogpost and an extension exactly for that! Click here to know more about deep linking in Game Maker […]

  • Hi Mattia – thanks for creating the deeplink extension.

    I have it only halfway working right now. I started with the Facebook tutorial, and got the login working, and sending invites. I then added the deeplink extension and set it up. At the same time on the facebook developer page, i turned on Deep Linking and Single Sign On.

    So if the receiver of the invite clicks the invite, it does open my GM app. However, I’m not getting the async social event to fire at all. I placed a show_message in the event script to see what async_load contains, but it doesn’t get that far.

    The other issue that I have to solve is – how does the invite sender get notified that the invite was accepted? Maybe this is a matter of solving the first problem, then the other will work?

    Any suggestions?

    Thanks,

    Gregg RenoApril 8, 2016
    • Hi Gregg,
      I’m glad that you found my extension useful πŸ™‚

      I’ve double checked the code and it should work fine.
      After 5 seconds after the game is opened your game should receive the social async call where “DEEPLINK” is passed through the value “type”.

      My suggestions are:
      1. Be sure that 5 seconds after the game is opened there is actually an instance of the object handling the social async call.
      2. Be sure that it’s listening for a SOCIAL ASYNC EVENT and not other async events.
      3. Use this code
      var type = string(async_load[? “type”])
      //check for deeplink type
      if type == “DEEPLINK”
      {
      //do something
      }
      To be sure that you receive the “type” value as String.
      4. Remember that this extension ONLY works on Android, and you have to compile the apk to actually test it! So test in on a real device not on Game Maker.
      5.Try log to Game Maker console, or use my other FREE extension to log directly into the Android console https://www.mattiafortunati.com/game-maker-studio-android-native-extension-log-to-console/
      6. check Android logcat to see if anything crashes.
      7. log log log everywhere to deeply investigate the issue and find out what and where is wrong!

      About the notification you have to push to the sender, I have no idea.
      For sure you should do it in the code after DEEPLINK social async is received but I don’t know how to send a notification back to the user that sent the invite.
      My extension simply opens the app and notifies it that it has been opened through a deeplink.
      It does not handle any other information, sorry.
      Maybe the sender user himself has to check (through Facebook APIs) if the invitation has been accepted, or maybe it’s Facebook itself which notifies the sender, I don’t know all the Facebook APIs features.
      Maybe some Facebook guide or tutorial can give you a good hint.

      Well, I hope that this can help you!
      Have a nice day!

      Mattia FortunatiApril 9, 2016
  • Hey bud, any ideas why I can’t get it working?
    my scheme is “https”
    host is “fb.me/171948886566464”

    The game is installed but it always goes directly to the store.
    Thanks for the great app!

    KyleAugust 28, 2016
    • Hi Kyle,
      yes, with your setup it is always pointing to Google Play.
      If you want, instead, that when a user clicks on a link from his device your app is opened, you have to change your setup.

      Let me give you a more specific example, using my Alpaca Jump’s setup:
      We have a user who already has Alpaca Jump installed on his smartphone and we want his smartphone to open Alpaca Jump every time he clicks on a link, even on the web, starting with “alpacajump://com.mattiafortunati.alpacajump”.
      The correct setup, in this case, is:
      android:scheme=”alpacajump” android:host=”com.mattiafortunati.alpacajump”

      Try to change your scheme and host and let me know πŸ™‚
      I hope that this can help you solving your problems, have a nice day!

      Mattia FortunatiAugust 28, 2016
  • How i can get host from application? (i.e. this string ”com.mattiafortunati.alpacajump”)

    GentJanuary 7, 2017
  • Hey Mattia, I’ve used your extension.
    It works great, but in the async_load I have only type,
    and I need the url too.
    Is it possible for you to add it for me please?
    From what I’ve seen in google this is the java code for it:

    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();

    https://developer.android.com/training/app-indexing/deep-linking.html

    Thanks a lot!
    Tom

    TomFebruary 9, 2017
    • Hi Tom!
      I’m glad that my extension is working well and helping you with you project.
      Good news!
      I’ve just updated the extension to the version 1.2.0.
      Now, along with “type” containing the string “DEEPLINK”, you will also receive “uri” containing the Uri data!
      I’ve also updated the example code.
      Enjoy!
      Oh, and let me know if it works!

      Mattia FortunatiFebruary 10, 2017
  • Wow awesome!! You’re really the best Mattia.

    It works great the uri thing πŸ™‚ I’ve rated you 5/5 in the market.
    How can I support you more?

    It’d be also great if you add a feature that instead of waiting 5 seconds,
    I’ll be able to call a function from gml, that’ll tell it that’s already ready to get it and call the async event now if it hasnt been called already.
    Maybe this function will be called each step frame. because waiting 5 seconds can be annoying for the user.
    You think it’s possible?

    Thanks again,
    Tom

    TomFebruary 11, 2017
  • Oh I’ve made the change myself. I found out that I have the java file comes with the extension.

    Now there’s no longer need to wait for 5 seconds. I can send you the fixed code if you want.

    TomFebruary 11, 2017
    • Hi Tom,
      yes the Java code comes together with the extension, but change it with care, since, according to Game Maker Studio Marketplace guidelines and rules, you are not allowed to make modifications to the extensions.
      Well, in this case don’t worry, feel free to make the changes you need πŸ™‚

      Also, I added the 5 seconds delay because the deeplink will open the game even if it is not running in the background, and, if that’s the case, since some games may take some time to open, the async event call may not reach the receiver.
      So, the 5 seconds are to be sure that the game is running at the moment of the callback, in case the game is not running in background and needs to be opened.

      This is a simple implementation, though, you are right and it can be improved in many ways for sure.
      For example, yes, I can add a function to “force” the deeplink activity to call the async event, or a function to directly get the URI and the needed data from the deeplink activity (and also prevent the callback to happen) and so on.

      The hardest part I had to dig around to add is the feature to open the Game Maker app’s main activity (along with the extension basic setup ^^), but since that is working fine, more feature can be add easily.
      So, yeah, I choose to keep it simple but I’ll keep your feature suggestions in consideration for sure when I’ll decide to upgrade my deeplink extension in the future!

      Thanks for your feedback Tom, it’s highly appreciated!

      Mattia FortunatiFebruary 11, 2017
  • Hey Mattia,

    Thanks for the awesome extension. I am able to click a link from Chrome that opens my game, and it receives the social event and URI. Then there’s a link in the game out to a different web page, which takes the user to another different page, which then redirects via deeplink back to my game.

    That all works, except I never receive another social event when the user returns to the game via that second deeplink. Any idea what’s happening?

    Thanks,
    Tom

    Tom SennettJuly 14, 2017
    • Hello Tom,
      I’m glad that you find my extension useful but, first of all … OMG. Tom Sennet.
      The real one! I’m a huge fan!

      I have to tell you: you are one of those who inspired me the most when I choose to seriously start making games and working in the gaming industry!
      I used to play Runman Unlimited, Monster Fracass and Acwabatiacs the whole day with my friends, about ten years ago!
      Thank you very much! I love your games! πŸ˜€

      Now, to the point πŸ™‚

      You are right, my deepLinkExtension opens the app every time but it fires the social async event only once.
      While talking about extensions, Game Maker is a little bit messy, but I may have found a quick and good solution for this issue.

      The new version of the extension is already on the marketplace, let me know if it works well!
      Please, keep in mind that, even if I run a lot of test cases, since I’m just one (and really busy these days), I may have missed something.
      So let me know if there are any problems.

      Alright,
      have a nice day Tom, and keep me posted!

      Mattia FortunatiJuly 14, 2017
    • Thanks Mattia and awesome to hear I helped inspire you!

      I got your updated version integrated and now everything is working smoothly. Fantastic work and thanks so much for helping so quickly.

      Spoiler alert! If you’re curious what I’m using this for, it’s part of hacking together an arcade box using an Android tablet and Square’s credit card reader. Coming soon to a South Philly bar near you!!

      Thanks again and have a day

      Tom SennettJuly 23, 2017
      • I’m glad to hear that πŸ˜€
        And wow, it seems an interesting project for sure, good luck with that!
        Cheers!

        Mattia FortunatiJuly 24, 2017
  • …that should be “have a *100* day”, it ate my emoji

    Tom SennettJuly 23, 2017

Leave a Reply

%d bloggers like this: