AppDelegate.swiftfile, this is where we will initialize our SDK with the following parameters.
authenticationEndpointparameters are optional and only needed if you want to use the SDK for client-side file upload. You can get these parameters from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers.
ImageKitURLConstructorwhich takes the URL endpoint, image path, and transformation position as parameters to create the transformed url.
createfunction to get the final transformed URL
wparameter. It makes your code more readable. See the full list of supported transformations in iOS SDK on Github.
addCustomTransformationfunction and pass the transformation code from ImageKit docs as the first parameter and value as the second parameter. For example -
pad_resizecrop strategy. In this strategy, the output image's dimension (height and width) is the same as requested, no cropping occurs, and the aspect ratio is preserved. This is accomplished by adding padding around the output image to get it to match the exact dimension as requested. You can read more about this here.
authenticationEndpointwhile initializing the SDK. Replace
your_authentication_endpointwith actual values.
Serverfolder inside the tutorial project and install its npm packages:
http://localhost:8080/authwhich is our
curl http://localhost:8080/authin the terminal, you should see a JSON response like this. Actual values will vary.
AppDelegate.swiftand ensure the
authenticationEndpointis set to
ImageKitUploader. For complete API reference for the image upload function, check out the docs on the ImageKit iOS Git Repository.
ImageKit.shared.uploader().uploadfunction can ingest files through
Url of a remote image