From 4068ebfbc13a690e93da91db57c71414971fc155 Mon Sep 17 00:00:00 2001 From: Bob De Kort Date: Thu, 11 Jul 2019 16:31:26 +0200 Subject: [PATCH] Expanded documentation --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 22e61ec..14fa385 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,63 @@ To use nstack for translations, you need to install the [nstack translations gen } ~~~~ +### Responses +Responses allow you to define and update JSON files on the NStack web console and retrieve them using the NStack sdk or using a normal get request. +~~~~swift +NStack.sharedInstance.getContentResponse(id) { (data, error) in + guard error == nil else { + print("Error fetching response with id: \(id)") + return + } + + // Use data +} +~~~~ + +### Collections +Collections is a more structured version of Responses and can be used as an alternative to an simple read API. +See the [feature overview](https://nstack-io.github.io/documentation/features.html) for a more detailed explaination. + +~~~~swift +let completion: (NStack.Result) -> Void = { result in + switch result { + case .success(let data): + print("Fetching collection successful") + print(data) + case .failure(let error): + print("Error fetching collection: \(error)") + } +} + +NStack.sharedInstance.fetchCollectionResponse(for: id, completion: completion) +~~~~ + +### Files +With files you can retrieve files defined on the NStack web console using a normal get request. +The files functionality has not been implemented in the sdk. + +~~~~swift +if let url = URL(string: url) { + URLSession.shared.downloadTask(with: url) { (localURL, urlResponse, error) in + guard error == nil else { + print("Error fetching file with url: \(url)") + print(error) + return + } + + if let localURL = localURL { + print("Local URL: \(localURL)") + // Use the localURL to modify, use your newly downloaded file + } + }.resume() +} +~~~~ ### Version control Version control informs the user when a new version is available and what new changes are available. You don't have to do anything to use the version control feature, just include the NStack sdk in your project. -To enable it create a new version on the NStack website. +To enable it create a new version on the NStack web console. Checkout the [feature overview](https://nstack-io.github.io/documentation/features.html) on how to setup version control. > **NOTE:** This feature is not yet supported on macOS and watchOS. @@ -106,7 +157,7 @@ Checkout the [feature overview](https://nstack-io.github.io/documentation/featur Messages shows the user a custom message when the app is launched, for example warning them about a server outage. You don't have to do anything to use the messages feature, just include the NStack sdk in your project. -To show the users a message create one on the NStack website. +To show the users a message create one on the NStack web console. Checkout the [feature overview](https://nstack-io.github.io/documentation/features.html) on how to setup messages. > **NOTE:** This feature is not yet supported on macOS and watchOS. @@ -115,7 +166,7 @@ Checkout the [feature overview](https://nstack-io.github.io/documentation/featur Rate reminder shows the user Apple's build in rate reminder after the user has launched the app a certain amount of times. You don't have to do anything to use the rate reminder feature, just include the NStack sdk in your project. -To enable the rate reminder configure it on the NStack website. +To enable the rate reminder configure it on the NStack web console. Checkout the [feature overview](https://nstack-io.github.io/documentation/features.html) on how to setup rate reminders. > **NOTE:** This feature is not yet supported on macOS and watchOS. @@ -131,17 +182,6 @@ NStack.sharedInstance.timezone(lat: 12.0, lng: 55.0) { (timezone, error) in } ~~~~ -### Content responses - -If you want to make a quick read API you can use NStacks Content Response feature. If you created a content response in the NStack web console fetch the data in the app as: -~~~~swift -NStack.sharedInstance.getContentResponse(60) { (response, error) in - if let _ = response { - //You have the content response - } -} -~~~~ - ### Validation NStack makes it possible to validate the syntax and domain of an email, just use: