📦 An SDK to embed Lune enrichment views into your iOS mobile apps
Add the .xcframework provided to you into your Xcode project by simply dragging it into the Project navigator. With that done, you should be able to import the SDK into any of your Swift files as shown below.
To initialize the SDK, you simply have to create an instance of LuneKitManager that would be used across your app. The constructor accepts optional arguments for global customization of the views in the SDK.
With the instance in hand, luneKitManager, in this example, you can embed any of the Lune views into your app by calling the method(s) responsible for such views.
We'd look at each view in detail now.
The BudgetForm allows the user to set up a new budget. To use this view, just call the BudgetForm method of your LuneKitManager instance as shown in the example below. The method takes two arguments:
- loading: this is an optional argument that indicates the preferred state of the view.
- callback: this should be an async method that accepts a Double parameter (amount entered by user), and returns a Bool to show if the request was successful or not. We expect that the method internally makes a request to your backend to set the user's budget.
The BudgetSummaryView shows the user's overall spend in contrast to his budget and his expected spend per time. To use this view, just call the BudgetSummaryView method of your LuneKitManager instance as shown in the example below. The method takes a BudgetSummary object.
Category Spend List View
The CategorySpendListView shows the user's spend per each category, the user can modify specified budged for each category. To use this view, just call the CategorySpendListView method of your LuneKitManager instance as shown in the example below. The method takes 4 arguments:
- spendPerCategory: a list of CategoryBudgetSpend objects
- budget: the user's budget as a Double
- errorCallback: this should be a method that accepts a String parameter (messsage). We expect that this method internally uses some sort of feedback mechanism (e.g toasts) to pass message to the user.
- saveCallback: this should be an async method that accepts a BudgetUpdate object as parameter, and returns a Bool to show if the request was successful or not. We expect that the method internally makes a request to your backend to update the user's budget, and refresh the budget values too.
Users can interact with the CategorySpendListView when it is in edit mode. In this mode, they get to modify the budget allotted to each spend category manually.
If, at any point, the user tries to allocate more than the overall budget, the errorCallback is triggered with a message about over-allocation.
To allow interaction with the view, call the setEditMode method of your LuneKitManager instance. The method takes an optional Bool argument which determines the interactivity of the view. If the argument is omitted, the method just toggles the interactivity of the view.
You can also keep track of the value of editMode, if you need it in your app.
Call the saveBudget method of your LuneKitManager instance to save the user's budget. This disables further interaction by setting editMode to false, and calls saveCallback.
Brand List View
The BrandListView shows a list of brands the user has patronized. To use this view, just call the BrandListView method of your LuneKitManager instance as shown in the example below. The method takes a list of BrandSpend objects.
Transaction List View
The TransactionListView shows a list of enriched transactions in a user-friendly way, which each transaction having an associated brand. To use this view, just call the TransactionListView method of your LuneKitManager instance as shown in the example below.
If your app is already localized, the SDK would be localized as well - no configurations needed. If your app is not localized, however, the SDK respects that and stays in English to preserve consistency and uniformity across your app.