SDK - iOS
Lune's Data API function is to simplify financial data for businesses, offering a transformative approach to managing and interpreting transaction data, a key aspect of transaction data enrichment. The way it works is that the API serves as a bridge, connecting raw transactional information that's hard to understand for regular teams and end-consumers to a world of enriched, meaningful insights.
Version 3
This version includes several changes to improve authentication, streamline and simplify the API, and improve international support.
Integration
![](https://cdn.prod.website-files.com/645cc47082c0e871f3f1618c/65c8c8fa0ab204d27c3bd3fa_installation-ezgif.com-resize%20(2).gif)
- Add the
.xcframework
provided to you into your Xcode project by simply dragging it into the Project navigator. - In the resulting pop-up, ensure that the "Copy items if needed" option is checked and click "Finish"
- Select your project in the Project Navigator, and allow the Targets settings to load.
- Under the General tab, scroll to reveal the Frameworks, Libraries and Embedded Content section
- In that section, click the dropdown button next to
LuneSDK.xcframework
and select "Embed and Sign"
With that done, you should be able to import the SDK into any of your Swift files as shown below.
import LuneSDK
Initialization
To initialize the SDK, you simply have to create an instance of LuneSDKManager
(or LuneSDKObjcManager
for Objective-C) that would be used across your app.
💡 SwiftUI Tip:
While you could create multiple instances of LuneSDKManager
, we recommend that you create just one instance per app. You could share that single instance with other views using Environment Objects.
The SDK takes in necessary credentials as arguments to the LuneSDKManager
constructor, as shown below.
Swift
// MyApp.Swift
import SwiftUI
import LuneSDK // 1.
@main
struct MyApp: App {
// 2. create the `LuneSDKManager` instance to be shared
@StateObject private var luneSDKManager = LuneSDKManager(
baseUrl: "<your.base.url>"
email: "<your.email.address>",
password: "<your.password>",
customerId: "<user.customer.id>"
)
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(luneSDKManager) // 3. share instance with other views in the app's hierarchy
}
}
}
You can then use the LuneSDKManager
instance in any view of your app as shown below.
// HomeView.Swift
import SwiftUI
import LuneSDK // 1.
struct HomeView: View {
// 2. Get instance with @EnvironmentObject
@EnvironmentObject var luneSDK: LuneSDKManager
var body: some View {
ScrollView{
// 3. Use instance to inject any view of your choice
luneSDK.TransactionListComponent()
}
}
}
Objective-C
// YourViewController.m
@import LuneSDK;
@interface YourViewController ()
// Declare luneSDK as a property of the class
@property (nonatomic, strong) LuneSDKObjcManager *luneSDK;
@end
@implementation YourViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize the SDK with your credentials.
_luneSDK = [
[LuneSDKObjcManager alloc]
initWithBaseUrl:@"<your.base.url>"
email:@"<your.email.address>"
password:@"<your.password>"
customerId:@"<user.customer.id>"
];
}
You can then use the LuneSDKObjcManager
instance in any view of your app as shown below.
// YourViewController.m
// budget summary setup, after the above setup is complete
// Create a new view controller instance using the BudgetSummaryComponentWithConfig method of the LuneSDK.
UIViewController *hostingController = [self.luneSDK BudgetSummaryComponent];
// Add the new view controller as a child view controller of the current view controller.
[self addChildViewController:hostingController];
// Add the new view controller's view as a subview of the current view controller's view.
[self.view addSubview:hostingController.view];
// Disable the autoresizing mask translation for the new view controller's view to enable the use of Auto Layout constraints.
hostingController.view.translatesAutoresizingMaskIntoConstraints = NO;
// Activate Auto Layout constraints to pin the new view controller's view to the edges of the current view controller's view.
[NSLayoutConstraint activateConstraints:@[
[hostingController.view.topAnchor constraintEqualToAnchor:self.view.topAnchor],
[hostingController.view.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[hostingController.view.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[hostingController.view.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
]];
Lune Views
Cashflow Chart Component
Category Trend Chart Component
Brand Trend Chart Component
Transaction List Component
Transaction Detail Component
Brand List Component
Budget Form Component
Budget Summary Component
Category Spend Chart Component
Category Spend List Component
Cashflow Component
Brand Trends Component
Category Trends Component
Expenses Component
Budget Component
Customization
The SDK has lots of configurable parameters which can be overridden by setting up a JSON
file with a schema similar to the one below.You could just copy the example below and modify the values you wish to change.
The SDK has lots of configurable parameters which can be overridden by setting up a JSON
file with a schema similar to the one below.You could just copy the example below and modify the values you wish to change.
{
"meta": {
"name": "config",
"version": "0.03"
},
"global": {
"palette": {
"light": {
"primary": "#002E2A",
"secondary": "#469B93",
"error": "#E86161",
"success": "#4BB543",
"warning": "#FFAA59",
"accent": "#EDF5F4",
"active": "#469B93",
"hint": "#66827F",
"foreground": "#002E2A",
"background": "#FFFFFF",
"card-background": "#FFFFFF",
"success-background": "#EDF5F4",
"error-background": "#FCEFEF",
"warn-background": "#FFF5E3"
},
"dark": {
"primary": "#002E2A",
"secondary": "#469B93",
"error": "#E86161",
"success": "#4BB543",
"warning": "#FFAA59",
"active": "#B3C0BF",
"selections": "#FFFFFF",
"hint": "#B3C0BF",
"foreground": "#FFFFFF",
"background": "#151515",
"card-background": "#2A292E",
"success-background": "#EDF5F4",
"error-background": "#FCEFEF",
"warn-background": "#FFF5E3"
}
},
"typography": {
"h0": {
"font": "Poppins",
"weight": 600,
"size": 20,
"line-height": 30
},
"h1": {
"font": "Poppins",
"weight": 600,
"size": 16,
"line-height": 24
},
"h2": {
"font": "Poppins",
"weight": 500,
"size": 16,
"line-height": 24
},
"body": {
"font": "Poppins",
"weight": 400,
"size": 14,
"line-height": 14
},
"hint": {
"font": "Poppins",
"weight": 400,
"size": 12,
"line-height": 12
}
},
"textfields": {
"radius": 10,
"border": 1,
"show-label": true,
"type": "outlined"
},
"buttons": {
"radius": 70,
"border": 1,
"type": ""
},
"cards": {
"radius-small": 10,
"radius-medium": 15,
"radius-large": 15,
"shadow": {
"radius": 40,
"offset-x": 0,
"offset-y": 4
}
},
"tiles": {
"use-cards": true,
"icon-width": 32,
"icon-border-radius": 100,
"horizontal-spacing": 10,
"vertical-spacing": 10
},
"structure": {
"prefix-amount-currency": false,
"prefix-amount-sign": true,
"show-amount-sign": true,
"use-centered-header": false,
"show-summary-icon": false,
"highlight-summary-amount": true,
"use-warn-color-for-summary": false
},
"assets": {
"calendar": "lune_asset_calendar",
"filter": "lune_asset_filter",
"arrow-up": "lune_asset_arrow_up",
"arrow-down": "lune_asset_arrow_down",
"arrow-left": "",
"arrow-right": "",
"chevron-left": "",
"chevron-right": "",
"income": "lune_asset_income",
"expense": "lune_asset_expenses",
"check": "",
"no-transaction": "lune_asset_no_data",
"budget-feature": "lune_asset_budget_img",
"goal-feature": "lune_asset_goal_img",
"no-achieved-goal": "lune_asset_no_achieved_goal_img",
"savings-feature": "lune_asset_savings_img",
"no-data": "lune_asset_no_data",
"summary-bad": "",
"summary-warn": "",
"summary-good": "",
"feedback-success": "lune_asset_feedback_success"
}
},
"component-specific": {
"cashflow": {
"structure": {
"show-top-amount": false,
"show-chart-center-amount": true,
"show-chart-center-label": false,
"chart-stroke-width": 10,
"chart-stroke-offset": 0,
"chart-round-stroke-cap": false,
"alert-before-tiles": true,
"income-before-expense": false
},
"theme": {
"light": {
"expense": "#7EB8B3",
"income": "#1A433F",
"summary-bg": "#FFF5E3"
},
"dark": {
"expense": "#7EB8B3",
"income": "#ffffff",
"summary-bg": "#FFF5E3"
}
}
},
"expense": {},
"budget-summary": {},
"budget-form": {},
"brand-trend": {
"structure": {
"use-card-chart": true,
"use-tile-divider": false,
"chart-stroke-width": 6,
"chart-round-stroke-cap": false
}
},
"category-trend": {
"structure": {
"use-card-chart": true,
"use-tile-divider": false,
"chart-stroke-width": 6,
"chart-round-stroke-cap": false
}
},
"activity": {},
"category-activity": {},
"transaction-detail": {
"structure": {
"use-centered-layout": false,
"show-report-icon": true,
"show-category-icon": true,
"allow-cancel-report": true,
"use-tile-divider-for-categories": false
},
"theme": {
"light": {
"reported-text": "#7E7D7D",
"reported-bg": "#F0F0F0",
"closed-text": "#E86161",
"closed-bg": "#FCEFEF",
"updated-text": "#469B93",
"updated-bg": "#DEF1EF",
"tag-text": "#FFFFFF",
"tag-bg": "#637185"
},
"dark": {
"reported-text": "#7E7D7D",
"reported-bg": "#F0F0F0",
"closed-text": "#E86161",
"closed-bg": "#FCEFEF",
"updated-text": "#469B93",
"updated-bg": "#DEF1EF",
"tag-text": "#FFFFFF",
"tag-bg": "#637185"
}
}
},
"category-spend-chart": {
"theme": {
"light": ["#102D2A", "#3B5755", "#5D9993", "#9AC0BE", "#CCE0DF"],
"dark": ["#102D2A", "#3B5755", "#5D9993", "#9AC0BE", "#CCE0DF"]
}
},
"brand-list": {},
"transaction-list": {},
"category-spend-list": {
"category-budget-increment": 50
}
}
}
The assets specified in the config file should be present within your XCAssets
file with the same name used in the config file.
![](https://cdn.prod.website-files.com/645cc47082c0e871f3f1618c/65c8d17ab02e7eb54f771b94_Screenshot%202024-02-11%20at%203.53.37%E2%80%AFPM.png)
Localization
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.