Skip to content

Upgrade from Old Balancy SDK

We have aimed to keep the new SDK as similar to the old one as possible. However, there are some important differences you should be aware of.

Initialization

The Init method and AppConfig in the new SDK are largely the same as in the old SDK. The biggest difference lies in the callbacks. The old SDK required several callbacks in AppConfig such as OnInitProgress, OnReadyCallback, and an additional callback in ISmartObjectsEvents.OnSmartObjectsInitialized. Developers had to manage these methods to ensure a proper initialization flow.

The new SDK simplifies this process with a single callback that suffices for most use cases. The OnDataUpdated callback is invoked when the SDK is fully initialized and ready for use. The Configs Data and Profiles are now properly synchronized, so they can only be updated together.

Data Access

The new SDK provides more straightforward data access. You can now directly access data from the Balancy.CMS object. Accessing data properties remains the same for both SDKs. An additional feature of the new SDK is the ability to easily access all child templates of a specified type by setting the includeChildren parameter to true.

Old SDK

var items = Balancy.DataManager.SmartObjects.Items;
var storeItems = Balancy.DataManager.SmartObjects.StoreItems;
var myItems = Balancy.DataEditor.MyItems;

New SDK

var items = Balancy.CMS.GetModels<Balancy.Models.SmartObjects.Item>(false);
var storeItems = Balancy.CMS.GetModels<Balancy.Models.SmartObjects.StoreItems>(false);
var myItems = Balancy.CMS.GetModels<Balancy.Models.MyItems>(false);

Profile Access

The new SDK also provides a more convenient way to access profiles. You can now access profiles directly from the Balancy.Profiles object. The method for accessing profile properties remains the same for both SDKs.

Old SDK

Balancy.Data.SmartStorage.LoadSmartObject<Profile>(responseData =>
{
    var profile = responseData.Data;
});

New SDK

var profile = Balancy.Profiles.Get<Profile>();

Summary of Changes

  • Initialization: The new SDK uses a single OnDataUpdated callback for simplicity, reducing the need to juggle multiple callbacks during initialization.
  • Data Access: Direct access to data through Balancy.CMS with optional inclusion of child templates.
  • Profile Access: Simplified profile access through Balancy.Profiles.

These changes aim to improve usability and streamline the development workflow. If you need more detailed guidance on transitioning to the new SDK, feel free to reach out.