Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetURLSchemeText how to use?

Author
Message
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 21st Oct 2018 14:31
The description for this on the help pages seems like the thing I've been wanting for ages. Open the app from a URL. Yay!

But how do you get the URL to open the app? I see that this command reads the URL that opened it but there's no instructions on how to open the app with the URL.

Is this a tier 2 only thing?
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 22nd Oct 2018 03:11
I haven't tried the latest version of AppGameKit yet, but it states:

* Added the option to add a URL scheme during Android and iOS export, so that the exported app can be opened by a browser link
* Added GetURLSchemeText to return the URL used to open the app on Android and iOS, if any

So you are able to define the URL scheme on export if you are using the latest AGK. This will allow your app to be opened from a URL once the apps have been published (Android and iOS).
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 22nd Oct 2018 03:55
I haven't played around with it yet, but I suspect there'll be a new entry in the exported manifest of "android:host" with a URL of whatever you set in the "URL Scheme" field when exporting your APK. Once the APK is installed, use a web browser on that device to click on a link with the URL that you set. This should prompt you to select how you'd like to open the link - with a browser, or with your app! I'm guessing anything after the host name in the link will get returned when calling GetURLSchemeText allowing you to detect if the app was opened via a link, and perform different tasks depending on what's in the link. I'm really excited to start playing with this, but haven't got time just yet. Let us know how you get on!
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 22nd Oct 2018 07:23
Thank you both. I did see the export thing mentioned in the list of changes but I guess I misunderstood it. I somehow read that as being able to install the apk from a url when exporting from AGK. I tend to copy it over to dropbox for Android, so thought they were offering an easy way to install it for testing.

I haven't installed the latest version yet, but will have a look as this will be a really nice feature.
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 23rd Oct 2018 00:42 Edited at: 23rd Oct 2018 00:48
This wasn't that easy to set up but finally figured it out with some googling so thought I'd share my findings.

I’m basing this example on a fictitious game called Five Knights

In the export window set the URL scheme to match your app name (don't include :// or any other text after the name). You probably could use any name here but it kind of makes sense to use your app name. I’d use the name that’s at the end of your package name i.e. com.coolgames.fiveknights.

The next bit is where I really struggled because fiveknights://mytext in the browser address bar does not work, and pasting it anywhere doesn't create a clickable link.

What you need to do is create a web page that has a clickable link or a page that redirects. This page has an example of the clickable a href tag to use: https://developer.chrome.com/multidevice/android/intents

This is an example taken from that page and updated for the Five Knights game.


With a bit of javascript you could get the page to redirect to that intent URL above without having to click a link. I would definitely recommend a redirect over a clickable a href tag.

The page that has the above code would live on your server and be accessible via a URL that might look like this: https://www.fiveknights.com/loadlevel.php?id=12345

Obviously if you’re passing different values on the URL then the href tag in the loadlevel.php page would need to pull in the values from the URL with PHP $_GET or some other way.

Clicking the link will open the app and GetURLSchemeText() will return this: fiveknights://loadlevel?id=12345

With that you can program your AppGameKit app to chop up the string to get the parameters you need and do something with it.

I don't know if this is the only way, and with no instructions from TGC I'm guessing there's probably a much simpler way and they felt instructions weren't needed. But this is one way that works

I hope this helps.
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 23rd Oct 2018 19:41
Here's a PHP line of code which will automatically open the app (based on my last post above):



The following link would open the loadlevel.php script that has that php code in and pull in the id from the URL: https://www.fiveknights.com/loadlevel.php?id=12345

The good thing with this is if the app isn't installed it redirects to the app in the store based on the package name.

Login to post a reply

Server time is: 2024-04-25 12:05:11
Your offset time is: 2024-04-25 12:05:11