Skip to content

Commit e62f090

Browse files
committed
Image Optimisation method implemented, Deprecated includeSchema from query, Added includeContentType in Query
1 parent e8d7302 commit e62f090

File tree

12 files changed

+286
-71
lines changed

12 files changed

+286
-71
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Contentstack.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22
s.name = 'Contentstack'
3-
s.version = '3.1.1'
4-
s.summary = 'Built.io Contentstack is a headless CMS with an API-first approach that puts content at the centre.'
3+
s.version = '3.2.0'
4+
s.summary = 'Contentstack is a headless CMS with an API-first approach that puts content at the centre.'
55

66
s.description = <<-DESC
7-
Built.io Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content.
7+
Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content.
88
9-
In a world where content is consumed via countless channels and form factors across mobile, web and IoT, Built.io Contentstack reimagines content management by decoupling code from content. Business users manage content – no training or development required. Developers can create cross-platform apps and take advantage of a headless CMS that delivers content through APIs. With an architecture that’s extensible – but without the bloat of legacy CMS – Built.io Contentstack cuts down on infrastructure, maintenance, cost and complexity.
9+
In a world where content is consumed via countless channels and form factors across mobile, web and IoT, Contentstack reimagines content management by decoupling code from content. Business users manage content – no training or development required. Developers can create cross-platform apps and take advantage of a headless CMS that delivers content through APIs. With an architecture that’s extensible – but without the bloat of legacy CMS – Built.io Contentstack cuts down on infrastructure, maintenance, cost and complexity.
1010
DESC
1111

1212
s.homepage = 'https://www.built.io/products/contentstack/overview'

Readme.md

Lines changed: 198 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,198 @@
1-
# Contentstack SDK for iOS
2-
Built.io Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content. For more information see the [website](https://contentstackdocs.built.io/developer).
3-
4-
#### Installation Options
5-
##### Manual
6-
7-
1. Download the [Latest iOS SDK release](https://github.com/raweng/BuiltIOContentstack-iOS/releases) and extract the zip file to your local disk.
8-
9-
2. Drag and drop Contentstack.framework into your project folder in Xcode.
10-
11-
A window will appear, prompting you to choose one of the options for adding files. Click the ‘Destination’ checkbox to copy items into the destination group’s folder. This will add the SDK to your project.
12-
13-
3. In the project editor, select your app under `TARGETS`. Under the `General` tab, open `Linked Frameworks and Libraries` and add the following libraries:
14-
- CoreGraphics.framework
15-
- MobileCoreServices.framework
16-
- Security.framework
17-
- SystemConfiguration.framework
18-
19-
4. In your target app, click on the `Build Settings` tab and add the `-ObjC` flag to `Other Linker Flags`.
20-
21-
##### **[CocoaPods](https://cocoapods.org)**
22-
23-
Add the following line to your Podfile:
24-
```sh
25-
pod 'Contentstack'
26-
```
27-
Run `pod install`, and you should now have the latest Contentstack release.
28-
29-
#### Import Header/Module
30-
You can import header file in Objective-C project as:
31-
```sh
32-
#import <Contentstack/Contentstack.h>
33-
```
34-
You can also import as a Module:
35-
36-
```sh
37-
//Objc
38-
@import Contentstack
39-
40-
//Swift
41-
import Contentstack
42-
```
43-
#### Other Links
44-
- [QuickStart](https://contentstackdocs.built.io/developer/ios/quickstart)
45-
- [Developer Guide](https://contentstackdocs.built.io/developer/guides)
46-
- [API Docs](https://contentstackdocs.built.io/ios/api)
47-
48-
## License
49-
```
50-
Copyright (c) 2017, Contentstack.io.
51-
All rights reserved.
52-
```
1+
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2+
3+
## iOS SDK for Contentstack
4+
5+
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
6+
7+
Contentstack provides iOS SDK to build application on top of iOS. Given below is the detailed guide and helpful resources to get started with our iOS SDK.
8+
9+
10+
### Prerequisite
11+
12+
13+
Latest Xcode and Mac OS X
14+
15+
16+
### Setup and Installation
17+
18+
19+
To use this SDK on iOS platform, you will have to install the SDK according to the steps given below.
20+
21+
22+
##### Manual
23+
24+
25+
1. Download the [Latest iOS SDK release](https://github.com/raweng/BuiltIOContentstack-iOS/releases) and extract the zip file to your local disk.
26+
2. Drag and drop Contentstack.framework into your project folder in Xcode. A window will appear, prompting you to choose one of the options for adding files. Click the ‘Destination’ checkbox to copy items into the destination group’s folder. This will add the SDK to your project.
27+
3. In the project editor, select your app under TARGETS. Under the General tab, open Linked Frameworks and Libraries and add the following libraries:
28+
- CoreGraphics.framework
29+
- MobileCoreServices.framework
30+
- Security.framework
31+
- SystemConfiguration.framework
32+
33+
4. In your target app, click on the Build Settings tab and add the -ObjC flag to Other Linker Flags.
34+
35+
##### CocoaPods
36+
37+
1. Add the following line to your Podfile:
38+
2. pod 'Contentstack'
39+
3. Run pod install, and you should now have the latest Contentstack release.
40+
41+
##### Import Header/Module
42+
43+
You can import header file in Objective-C project as:
44+
```sh
45+
#import &lt;Contentstack/Contentstack.h&gt;
46+
47+
You can also import as a Module:
48+
49+
//Objc
50+
51+
@import Contentstack
52+
53+
//Swift
54+
55+
import Contentstack
56+
```
57+
### Key Concepts for using Contentstack
58+
59+
#### Stack
60+
61+
A stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).
62+
63+
#### Content Type
64+
65+
Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).
66+
67+
#### Entry
68+
69+
An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).
70+
71+
72+
#### Asset
73+
74+
75+
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).
76+
77+
78+
#### Environment
79+
80+
A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
81+
82+
### Contentstack iOS SDK: 5-minute Quickstart
83+
84+
#### Initializing your SDK
85+
86+
To start using the SDK in your application, you will need to initialize the stack by providing the required keys and values associated with them:
87+
```sh
88+
//Objc
89+
90+
Stack *stack = [Contentstack stackWithAPIKey: API_KEY accessToken: ACCESS_TOKEN environmentName: ENVIRONMENT];
91+
//Swift
92+
93+
let stack:Stack = Contentstack.stackWithAPIKey(API_KEY, accessToken: ACCESS_TOKEN, environmentName: ENVIRONMENT)
94+
```
95+
To get the api credentials mentioned above, you need to log into your Contentstack account and then in your top panel navigation, go to Settings -&gt; Stack to view both your API Key and your Access Token
96+
97+
The stack object that is returned is a Contentstack client object, which can be used to initialize different modules and make queries against our [Content Delivery API](https://contentstack.com/docs/apis/content-delivery-api/). The initialization process for each module is explained in the following section.
98+
99+
100+
#### Querying content from your stack
101+
102+
To fetch all entries of of a content type, use the query given below:
103+
```sh
104+
//Obj-C
105+
106+
ContentType *contentTypeObject = [stack contentTypeWithName:@"my_content_type"];
107+
108+
Query *queryObject = [contentTypeObj query];
109+
110+
111+
112+
//Swift
113+
114+
var contentTypeObject:ContentType = stack.contentTypeWithName("my_content_type")
115+
116+
var queryObject:Query = contentTypeObj.query()
117+
```
118+
119+
120+
To fetch a specific entry from a content type, use the following query:
121+
```sh
122+
//Obj-C
123+
124+
ContentType * contentTypeObject = [stack contentTypeWithName:@"my_content_type"];
125+
126+
Entry *entryObject = [contentTypeObject entryWithUID:@"ENTRY_UID"];
127+
128+
//Swift
129+
130+
var contentTypeObject:ContentType = stack.contentTypeWithName("my_content_type")
131+
132+
var entryObject:Entry = contentTypeObject.entryWithUID("ENTRY_UID")
133+
```
134+
### Advanced Queries
135+
136+
You can query for content types, entries, assets and more using our iOS API Reference.
137+
138+
[iOS API Reference Doc](https://www.contentstack.com/docs/platforms/ios/api-reference/)
139+
140+
### Working with Images
141+
142+
We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
143+
144+
For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400. There are several more parameters that you can use for your images.
145+
146+
[Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
147+
148+
You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.
149+
150+
```sh
151+
//Obj-C
152+
/* set the image quality to 100 */
153+
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:100], @"quality", nil];
154+
NSString *transformedUrl = [stack imageTransformWithUrl:imageURL andParams:params];
155+
156+
/* resize the image by specifying width and height */
157+
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:100], @"width", [NSNumber numberWithInt:100], @"height", nil];
158+
NSString *transformedUrl = [stack imageTransformWithUrl:imageURL andParams:params];
159+
160+
/* enable auto optimization for the image */
161+
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:@"webp", @"auto", nil];
162+
NSString *transformedUrl = [stack imageTransformWithUrl:imageURL andParams:params];
163+
164+
165+
//Swift
166+
/* set the image quality to 100 */
167+
let params:[String : AnyObject?] = [
168+
"quality":100 as AnyObject
169+
];
170+
let transformedUrl:String = stack.imageTransformation(withUrl: imageURL, andParams: params);
171+
172+
/* resize the image by specifying width and height */
173+
let params:[String : AnyObject?] = [
174+
"width":100 as AnyObject,
175+
"height":100 as AnyObject,
176+
];
177+
let transformedUrl:String = stack.imageTransformation(withUrl: imageURL, andParams: params);
178+
179+
let params:[String : AnyObject?] = [
180+
"auto":"webp" as AnyObject
181+
];
182+
let transformedUrl:String = stack.imageTransformation(withUrl: imageURL, andParams: params);
183+
184+
```
185+
186+
### Helpful Links
187+
188+
- [Contentstack Website](https://www.contentstack.com)
189+
- [Official Documentation](http://contentstack.com/docs)
190+
- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
191+
192+
## License
193+
```
194+
Copyright (c) 2017, Contentstack.io.
195+
All rights reserved.
196+
```
197+
198+
6.06 MB
Binary file not shown.

SDK/Contentstack.framework/Headers/Contentstack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright (c) 2015 Built.io. All rights reserved.
77
//
88

9-
// sdk-version: 3.1.1
9+
// sdk-version: 3.2.0
1010

1111
#import <Foundation/Foundation.h>
1212
#import <Contentstack/Config.h>

SDK/Contentstack.framework/Headers/Query.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,19 @@ This method also includes the schema of the contenttype for the entries returned
251251
blogQuery.includeSchema()
252252
253253
*/
254-
- (void)includeSchema;
254+
- (void)includeSchema __attribute((deprecated("Use the includeContentType instead.")));;
255+
256+
/**
257+
This method also includes the contenttype for the entries returned in the response.
258+
259+
//Obj-C
260+
[blogQuery includeContentType];
261+
262+
//Swift
263+
blogQuery.includeContentType()
264+
265+
*/
266+
- (void)includeContentType;
255267

256268
/**
257269
This method also includes owner information for all the entries returned in the response.

SDK/Contentstack.framework/Headers/QueryResult.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ BUILT_ASSUME_NONNULL_BEGIN
5555
@return Returns schemas.
5656
*/
5757
- (BUILT_NULLABLE NSArray *)schema;
58+
/**
59+
@abstract Gets the content type of objects returned by Query alongwith objects themselves.
60+
61+
//Obj-C
62+
[projectQuery execInBackground:^(ResponseType type, QueryResult *result, NSError *error) {
63+
NSDictionary *result = [result content_type];
64+
}];
65+
66+
//Swift
67+
projectQuery.execInBackground { (ResponseType, QueryResult!, NSError!) -> Void in
68+
var schema:NSDictionary = QueryResult.content_type()
69+
}
70+
71+
@return Returns content type.
72+
*/
73+
- (BUILT_NULLABLE NSDictionary *)content_type;
5874

5975
//MARK: Count -
6076
/**---------------------------------------------------------------------------------------

SDK/Contentstack.framework/Headers/Stack.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,25 @@ BUILT_ASSUME_NONNULL_BEGIN
159159
*/
160160
- (Asset *)assetWithUID:(NSString *)uid;
161161

162+
/**
163+
Transforms provided image url based on transformation parameters.
164+
165+
//Obj-C
166+
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:100], @"width", [NSNumber numberWithInt:100], @"height", nil];
167+
NSString *transformedUrl = [stack imageTransformWithUrl:imageURL andParams:params];
168+
169+
//Swift
170+
let params:[String : AnyObject?] = [
171+
"width":100 as AnyObject,
172+
"height":100 as AnyObject,
173+
];
174+
let transformedUrl:String = stack.imageTransformation(withUrl: imageURL, andParams: params);
175+
176+
@param url Url on which transformations to be applied.
177+
@param params Transformation parameters.
178+
@return new instance of transform url.
179+
*/
180+
- (NSString *)imageTransformWithUrl:(NSString *)url andParams:(NSDictionary *)params;
162181

163182
@end
164183

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)