--jpCloudEnvironment API jpCloudEnvironment.activate ( sUserToken, sActivationKey ) jpCloudEnvironment.clear ( ) bYes = jpCloudEnvironment.variableExists ( sName ) vValue = jpCloudEnvironment.getVariable ( sName ) nCount = jpCloudEnvironment.getVariableCount ( ) sName = jpCloudEnvironment.getVariableNameAt ( nIndex ) jpCloudEnvironment.setVariable ( sName, vValue ) jpCloudEnvironment.synchronize ( ) jpCloudEnvironment.unsetVariable ( sName ) --User notification events: "onCloudEnvironmentChanged" ( )
jpCloudEnvironment works just like the ShiVa integrated environment system, except that the environment is stored on iCloud.
Its API has been designed to be as smooth as possible. The functions name are the same ones as the default ShiVa environment ones.
Once variables have been saved locally they will not be synchronized with iCloud storage until a call is made to the synchronize. It is important to note that a call to the synchronize method does not result in an immediate synchronization of the locally saved data with the iCloud store. iOS will, instead, perform the synchronization at what the Apple documentation refers to as “an appropriate later time”.
The amount of data that can be stored per variable is 64Kb. The per-application limit is 256 individual variables which, combined, must also not exceed 64Kb in total.
In the event that two application instances make changes to the same variable, the most recent change is given precedence.
As with iCloud document storage, environment storage requires the implementation of appropriate iCloud entitlements. In this case the application must have the com.apple.developer.ubiquity-kvstore-identifier entitlement key configured in the project’s entitlements file. The value assigned to this key is used to identify which applications are able to share access to the same iCloud stored key-value data. If, for example, the ubiquity-kvstore-identifier entitlement key for an application named MyApp is assigned a value of ABCDE12345.com.mycompany.MyApp (where ABCDEF12345 is developer’s unique team or individual ID) then any other applications using the same entitlement value will also be able to access the same stored environment. This, by definition, will be any instance of the MyApp running on multiple devices, but applies equally to entirely different applications (for example MyOtherApp) if they also use the same entitlement value.