Google Instant Apps Native Extension

This forum topic is outdated, please, take a look this post about Google Play Instant:

Old post is available here (outdated)

https://github.com/AGulev/instantapp

Google Instant Apps

This is Native Extension for the Defold Game Engine implement Google Play Instant API methods.

Here you can find instruction how to build instant app using Defold.

Setup

You can use the InstantApp extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/AGulev/instantapp/archive/master.zip

Or point to the ZIP file of a specific release.

API

If you are working on cross-platform application the best practice to check the existence of instantapp module, this module exists only in android bundle:

if instantapp then
  -- call instantapp methods
end

instantapp.is_instant_app() Original DOC

Returns true if this application is an instant app.

if instantapp.is_instant_app() then
  --do something specific for instant app
end

instantapp.show_install_prompt() Original DOC

Shows a dialog that allows the user to install the current instant app.

if instantapp.is_instant_app() then
  instantapp.show_install_prompt() -- if this is instant app then show install prompt
else
  -- regular app logic
end

Popup example:

2019-04-07 20 54 02

instantapp.get_cookie_max_size() Original DOC

Gets the maximum size in bytes of the cookie data an instant app can store on the device.

local cookie_size = instantapp.get_cookie_max_size() --number, for example 16384

instantapp.get_cookie() Original DOC

Gets the instant application cookie for this app. Non instant apps and apps that were instant but were upgraded to normal apps can still access this API.

local cookie_byte_array = instantapp.get_cookie()

instantapp.set_cookie() Original DOC

Sets the instant application cookie for the calling app. Non instant apps and apps that were instant but were upgraded to normal apps can still access this API.

instantapp.set_cookie(bytes)

Issues and suggestions

If you have any issues, questions or suggestions please create an issue or contact me: me@agulev.com

11 Likes

I implemented the most important two methods for a first version of the NE, if you need something else just give me know.

5 Likes

whoah! This feature was ofter requested all around.

Can you please link to a game or a demo on the Play Store that utilises this NE already?

4 Likes

Unfortunately, for now, I have only a dirty demo in test mode, but I’ll try to do an example later on this week. Also, I wanna add new functions for this NE.

3 Likes

Epic!!

2 Likes

Interesting fact: players who launched the Google Instant App on a page on Google Play account for approximately 10-20% of the number of players who installed the game.
In my opinion, this is a pretty good result, considering that we are talking only about organic traffic (from advertising you can launch the Instant app via a direct link).

I didn’t bother much and just using the Instant App extension I check if the game is an instant application, if yes, instead of restarting at the end of the level, I suggest installing the full game (almost the same apk, but on a permanent basis). Even with this approach, the game fits into a 4Mb limit for applications (for games, a 10Mb limit).

8 Likes

I’ve released version 1.0.0.
Added new methods:
instantapp.get_cookie_max_size()
instantapp.get_cookie()
instantapp.set_cookie()

Those methods provide a possibility to communicate between instant application and the main application.

4 Likes

Hi @AGulev is there any chance you could please provide updated instructions for building the instant app as an AAB in the latest version of Defold? It says here “All new instant experiences must publish with instant-enabled app bundles”.

Yes, of course. I’ll take a look.

1 Like

Great thanks!

Hi, here is instruction:


I think you need to add

<dist:module dist:instant="true" />

Thanks, trying it now. One thing I’m confused about is the version codes. How do I set a seperate version code for the instant app and the installable app? Do I need to have a seperate Defold project for the instant app?

No I don’t think so. You need to manually change the version code when you build. Or if you build from the command line you can script it.