This repository demonstrates how to implement background uploads in iOS applications using SwiftUI and the URLSession
API with a .background
configuration. The app allows you to upload images to imgBB while running code in the background, even when the app is suspended Or terminated (in case your app is terminated, you can send a silent push to wake it up and then call a method that requests the service to continue uploading).
- SwiftUI Integration: Modern UI designed using SwiftUI.
- Background Upload: Uploads files using
URLSession
with.background
configuration. - imgBB API Integration: Utilizes the imgBB API for uploading and managing image files.
- Error Handling: Handles upload errors and provides success/error feedback.
To upload images, the project uses the imgBB API. This REST API allows you to upload images and retrieve their URLs up to 32 MB free.
Before running the project, you must obtain an API key from imgBB:
- Visit the imgBB API Key Page.
- Create an account (if you don’t already have one).
- Generate an API key.
git clone https://github.com/diananareiko/backgroundUpload.git
cd your-repo-name
- Open the project in Xcode.
- Navigate to
Info.plist
. - Fill in IMGBB_API_KEY
- Open the project in Xcode.
- Select a real device as the build target (simulators don’t support background uploads effectively).
- Build and run the app.
The app enables users to upload images to imgBB. The upload process runs in the background, allowing it to continue even if the app is suspended.
- A
URLSession
instance with a.background
configuration handles file uploads. - The app saves the image data as a temporary file and uploads it to the imgBB API using
uploadTask
.
- SwiftUI: For building the app's user interface.
- URLSession: For managing background upload tasks.
- imgBB API: For handling image uploads.
- Xcode: For iOS app development.
Screenshot 1 | Screenshot 2 | Screenshot 3 |
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch.
- Make your changes and submit a pull request.
Diana Nareiko
Email: diananareiko8@gmail.com
GitHub: https://github.com/diananareiko