1.0.1
General
RuStore In-app updates SDK enable users to be kept up to date with the latest app version on their device. This allows them to stay informed about any performance enhancements or bug fixes that have been implemented.
User scenario example
Additionally, the SDK offers the ability to notify users of a new version and provide an option to install it. The installation process can occur in the background, while the user can track the progress of the update.
See the example app to learn how to integrate Updates SDK correctly.
Prerequisites
For RuStore In-app updates SDK to operate correctly, the following conditions need to be met:
- Android 7.0 or later..
- RuStore app version on the device is up-to-date..
- The user is authorized in RuStore.
- RuStore app is allowed to install applications.
Connecting to project
To get started, follow these steps:
- Copy the plugin projects from the official RuStore repository to GitFlic.
- In your IDE, open the Android project from the
godot_plugin_libraries
folder. - In the
godot_plugin_plugin_libraries / libs
folder, save thegodot-lib.xxx.yyy.template_release.aar
package, wherexxx.yyyy
is the version of your Godot Engine edition.
The godot-lib.xxx.yyy.template_release.aar
package for your version of Godot Engine can be found on the developer page at Sourceforge.net.
- Build your project with the command
gradle assemble
.
If the build is successful, the following files will be created in godot_example/android/plugins
.
RuStoreGodotAppUpdate.gdap
.RuStoreGodotAppUpdate.aar
.RuStoreGodotCore.gdap
.RuStoreGodotCore.aar
.
Note that the plugin libraries must be built for your version of the Godot engine.
-
Save the contents of the
godot_example / android / plugins
folder to theyour_project / android / plugins
folder. -
Tick the "RuStore Godot App Update" and "RuStore Godot Core" lines in the "Plugins" list in the Android build preset..
Создание менеджера обновлений
Create update manager before calling library methods.
var _appUpdate_client: RuStoreGodotAppUpdateManager = null
func _ready():
_appUpdate_client = RuStoreGodotAppUpdateManager.get_instance();
Проверк а наличия обновлений
Before requesting an update, check if it is available for your application To check for updates, call the get_app_update_info
method. When this method is called, the following conditions will be verified:
- The current version of RuStore is installed on the user's device.
- The user and the app should not be blocked in RuStore.
- RuStore app is allowed to install applications.
- The user is authorized in RuStore.
You will need to subscribe to the events once before you can use this method:
on_get_app_update_info_success
;on_get_app_update_info_failure
.
func _ready():
# Инициализация _appUpdate_client
_appUpdate_client.on_get_app_update_info_success.connect(_on_get_app_update_info_success)
_appUpdate_client.on_get_app_update_info_failure.connect(_on_get_app_update_info_failure)
func _on_get_app_update_info_success(response: RuStoreAppUpdateInfo):
pass
func _on_get_app_update_info_failure(error: RuStoreError):
pass
_appUpdate_client.get_app_update_info()
The on_get_app_update_info_success
callback returns объект with the update details. Request information in advance to run the update without delay at a convenient time for the user.
class_name RuStoreAppUpdateInfo extends Object
var updateAvailability: ERuStoreUpdateAvailability.Item
var installStatus: ERuStoreInstallStatus.Item
var availableVersionCode: int
func _init(json: String = ""):
if json == "":
updateAvailability = ERuStoreUpdateAvailability.Item.UNKNOWN
installStatus = ERuStoreInstallStatus.Item.UNKNOWN
availableVersionCode = 0
else:
var obj = JSON.parse_string(json)
updateAvailability = int(obj["updateAvailability"])
installStatus = int(obj["installStatus"])
availableVersionCode = int(obj["availableVersionCode"])
-
:updateAvailability
— update availability:UNKNOWN (int == 0)
— by default..UPDATE_NOT_AVAILABLE (int == 1)
— no update required..UPDATE_AVAILABLE (int == 2)
— update needs to be downloaded or it has already been downloaded to the user's device..DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS (int == 3)
— update is already being downloaded or installation is already running..
-
:installStatus
— update installation status, if the user has already started the update installation at the time:UNKNOWN (int == 0)
— by default..DOWNLOADED (int == 1)
— successfully downloaded..DOWNLOADING (int == 2)
— currently being downloaded..FAILED (int == 3)
— error..PENDING (int == 5)
— awaiting update..
-
availableVersionCode
— update version code.
The update download is only available if the updateAvailability
field has the UPDATE_AVAILABLE
value.
on_get_app_update_info_failure
callback returns объект with the error information. Error structure is described in Error Handling.
Скачивание и установка обновлений
Использование слушателя
After confirming the update availability (RuStoreAppUpdateInfo
), you can receive the update download status. This involves subscribing to the on_state_updated
event and calling the register_listener
method to start the download status listener.