- Citykey uses native NSURLSession for network management
- APIs are organized by service domains (e.g., Waste Calendar, Digital Administration)
- App follows MVP (Model-View-Presenter) architecture pattern
- Create a Service Worker
- Each service requires its own dedicated worker class
- All APIs related to a specific service are implemented within its worker
- API Implementation
- Implement service-specific API endpoints in the worker class
- Use native NSURLSession for network requests
- Handle response parsing and error management
- Service Consumption
- Inject the appropriate worker into ViewModels that need the service
- ViewModels communicate with workers to fetch/send data
- Presenters update the Views based on data from ViewModels
The Citykey app provides various city services through a modular architecture where each service is defined in a JSON response. This documentation will help you understand the API structure and how to integrate new services into the app.
Base Response Format:
{
"content": [{
"cityServiceCategoryList": [
{
"categoryId": string,
"category": string,
"icon": string,
"image": string,
"description": string,
"cityServiceList": [Service]
}
],
"cityId": number
}]
}
Service Object Structure:
{
"serviceId": number,
"service": string,
"description": string,
"icon": string,
"image": string,
"function": string,
"serviceType": string,
"isNew": boolean,
"new": boolean,
"residence": boolean,
"restricted": boolean,
"serviceParams": {
// Optional parameters specific to the service
},
"serviceAction": [Action],
"templateId": number
}
Action Object Structure:
{
"actionId": number,
"action": string,
"actionOrder": number,
"androidUri": string,
"buttonDesign": string,
"iosAppStoreUri": string,
"iosUri": string,
"visibleText": string,
"actionType": string
}
Category Fields categoryId: Unique identifier for the service category category: Display name of the category description: Brief description of the category cityServiceList: Array of services within this category
Service Fields serviceId: Unique identifier for the service service: Display name of the service description: HTML-formatted description of the service function: Service type identifier used for routing serviceType: Classification of the service restricted: Boolean indicating if the service requires authentication
Action Fields: actionId: Unique identifier for the action actionOrder: Order in which actions should be displayed iosUri: URI scheme or URL for handling the action visibleText: Button text to display actionType: Type of action to perform
- Add your service JSON to the mock response file
- Build and run the app
- Verify your service appears in the correct category
- Test all actions and links
- Verify the service description renders correctly
- Test both authenticated and unauthenticated scenarios if applicable