This sample project covers:
- Setting up ImageKit iOS SDK
- Rendering images
- Setting authentication context for the SDK
- Applying common image manipulations
- Adding overlays to images
- Client-side file uploading
This project was bootstrapped with CocoaPods. Head over to the link for installation if not already done.
pod install
In ImageKitDemo/Constants.swift
, set the following parameters for authentication:
let IK_PUBLIC_KEY = "your_public_key"
let IK_URL_ENDPOINT = "https://ik.imagekit.io/your_imagekit_id"
let AUTH_SERVER_API_ENDPOINT = "http://localhost:8080/auth"
IK_URL_ENDPOINT
is a required parameter. IK_PUBLIC_KEY
and AUTH_SERVER_API_ENDPOINT
parameters are optional and only needed if you want to use the SDK for client-side file upload.
You can get the value of URL-endpoint from your ImageKit dashboard.
API public key can be obtained from the developers section in your ImageKit dashboard.
Run in terminal:
open ImageKitDemo.xcworkspace
Move to the server directory
cd Server
Create .env
file by copying sample.env
cp sample.env .env
Set the following keys in .env
PUBLIC_KEY=public_XXXXXXXXXXXX
PRIVATE_KEY=private_XXXXXXXXXXXX
API private key can be obtained from the developers section in your ImageKit dashboard.
Please note that file upload will only work if, along with the above, IK_PUBLIC_KEY
and AUTH_SERVER_API_ENDPOINT
are set in Constants.swift
file.
Install packages:
npm install
npm start
Node server will run at http://localhost:8080
.
Since iOS enforces App Transport Security
, for the demo, the project has http://localhost:8080
as an exception.
If the following error is encountered Transport security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
, the following code should be added to Info.plist
file
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost:8000</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- Offical iOS quickstart guide - https://docs.imagekit.io/getting-started/quickstart-guides/ios
- iOS SDK and documentation - https://github.com/imagekit-developer/imagekit-ios
If something doesn't work as expected, report a bug at support@imagekit.io.