SaveSharedVariable

Description

Saves a variable so it can be accessed from other apps. This only works on iOS, Android 9 and below, and HTML5 platforms. Apps can only share a variable if they meet certain requirements based on the platform.

On iOS the apps must be created by the same Apple developer account, and have the same App Group added to their App IDs on the Apple developer portal. You will need to regenerate the provisioning profile after doing this. On iOS you must tell AGK what the App Group is by using SetSharedVariableAppGroup.

On Android 9 and below the apps must have the WRITE_EXTERNAL_STORAGE permission and have the same package name up to the last dot. For example com.mycompany.mygroup.myapp1 and com.mycompany.mygroup.myapp2 would be able to share variables. On Android shared variables are written to a user accessible location, so be aware that users may be able to read and/or edit the variables that you save.

On Android 10 or higher this command will not work as apps are restricted from writing to shared locations.

On HTML the apps must be hosted on the same domain, the values are stored as cookies.

Variables are identified by name, so using SaveSharedVariable("username", "Alice") will set the variable called "username" to the value "Alice". This can then be read by other apps by using LoadSharedVariable( "username", "" ) If two apps save different values to the same variable name then the value will be overwritten and only the most recent value will be accessible. Variable values will persist even if the app is deleted and re-installed. You should not use this command to store any sensitive information such as passwords in plain text. On iOS the length of the variable name plus the length of your App ID up to the last dot (e.g. com.mycompany.mygroup) must be less than 58.

Definition

SaveSharedVariable( varName, varValue )

Parameters