Skip to content

Commit d3a1871

Browse files
Merge pull request #27 from michael-patzer/MMC-2041_add_cocoapods_readme
Added Cocoapods installation instructions and table of contents to README.
2 parents baf4e65 + 4bc4859 commit d3a1871

File tree

2 files changed

+80
-64
lines changed

2 files changed

+80
-64
lines changed

MailchimpSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717

1818
s.homepage = 'https://mailchimp.com'
1919
s.social_media_url = 'https://twitter.com/mailchimp'
20-
s.license = { :type => 'Mailchimp Mobile Software Development Kit License Agreement', :file => 'LICENSE' }
20+
s.license = { :type => 'Custom', :file => 'LICENSE' }
2121

2222
s.authors = 'Mailchimp'
2323

README.md

Lines changed: 79 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ The Mailchimp SDK is currently in a private beta. If you'd like to join the beta
44
[<img width="250" height="119" src="https://developer.mailchimp.com/documentation/mailchimp/img/lockup.svg"/>](http://www.mailchimp.com)
55

66
# MailchimpSDK-iOS
7-
MailchimpSDK for iOS
87

9-
Run `bundle exec fastlane create_binary_framework` to build the Swift binary framework for iOS and iOS Simulator.
8+
##### Table of Contents
9+
[Getting Started](#getting-started)
10+
[Installation](#installation)
11+
[Initializing the SDK](#initializing-the-sdk)
12+
[Collecting contact information](#collecting-contact-information)
13+
[Contact Schema](#contact-schema)
14+
[Collecting contact events](#collecting-contact-events)
15+
[Event Schema](#event-schema)
1016

1117
## Getting Started
1218

@@ -20,13 +26,23 @@ Run `bundle exec fastlane create_binary_framework` to build the Swift binary fra
2026

2127
* The Mailchimp SDK is currently in a private beta. If you'd like to join the beta send your Mailchimp username to [[email protected]](mailto:[email protected]?subject=I%27d%20like%20to%20join%20the%20Mailchimp%20SDK%20Private%20Beta).
2228

23-
### Adding the XCFramework
29+
## Installation
30+
### Option 1: Cocoapods
31+
For the latest version of our SDK, add the following to your project's Podfile:
32+
```
33+
pod 'MailchimpSDK'
34+
```
35+
36+
### Option 2: Manual
37+
1. Clone this repository
38+
2. Run `bundle exec fastlane create_binary_framework` to build the Swift binary framework for iOS and iOS Simulator.
39+
3. Add the XCFramework:
2440

25-
Click on the Project navigator, select your app’s target, go to the General tab, scroll down to Frameworks, Libraries, and Embedded Content. Drag the Mailchimp.xcframework from this repo into this section.
41+
Click on the Project navigator, select your app’s target, go to the General tab, scroll down to Frameworks, Libraries, and Embedded Content. Drag the Mailchimp.xcframework from this repo into this section.
2642

27-
![Drag the framework into Frameworks, Libraries, and Embedded Content](https://user-images.githubusercontent.com/42216769/69161161-8f641480-0a9f-11ea-93ec-5599aac85423.gif)
43+
![Drag the framework into Frameworks, Libraries, and Embedded Content](https://user-images.githubusercontent.com/42216769/69161161-8f641480-0a9f-11ea-93ec-5599aac85423.gif)
2844

29-
### Initializing the SDK
45+
## Initializing the SDK
3046

3147
The initialize method has three different fields.
3248

@@ -35,7 +51,7 @@ The initialize method has three different fields.
3551
* Auto Tagging (Optional): Auto Tagging automatically tags contacts with information such as Device Type and Platform. This is on by default.
3652

3753
```swift
38-
MailchimpSDK.initialize(token: sdkKey)
54+
MailchimpSDK.initialize(token: sdkKey)
3955
```
4056

4157
## Collecting contact information
@@ -45,19 +61,19 @@ The initialize method has three different fields.
4561
To add a contact to your Mailchimp audience, first instantiate a new Contact struct. Then pass the contact into the `createOrUpdate()` method. This will add the contact to your Mailchimp audience with applied merge fields and/or tags. If the contact already exists, their information will be updated with the values that were passed in.
4662

4763
```swift
48-
var contact: Contact = Contact(emailAddress: "[email protected]")
49-
let mergeFields = ["FNAME": MergeFieldValue.string("Example"),
50-
"LNAME": MergeFieldValue.string("User")]
51-
contact.mergeFields = mergeFields
52-
contact.tags = [Contact.Tag(name: "mobile-signup", status: .active)]
53-
MailchimpSDK.createOrUpdate(contact: contact) { result in
54-
switch result {
55-
case .success:
56-
print("Successfully added or updated contact")
57-
case .failure(let error):
58-
print("Error: \(error.localizedDescription)")
59-
}
64+
var contact: Contact = Contact(emailAddress: "[email protected]")
65+
let mergeFields = ["FNAME": MergeFieldValue.string("Example"),
66+
"LNAME": MergeFieldValue.string("User")]
67+
contact.mergeFields = mergeFields
68+
contact.tags = [Contact.Tag(name: "mobile-signup", status: .active)]
69+
MailchimpSDK.createOrUpdate(contact: contact) { result in
70+
switch result {
71+
case .success:
72+
print("Successfully added or updated contact")
73+
case .failure(let error):
74+
print("Error: \(error.localizedDescription)")
6075
}
76+
}
6177
```
6278

6379
### Updating a Contact
@@ -77,40 +93,40 @@ Single field update methods include
7793
### Add/Remove Tags
7894

7995
```swift
80-
MailchimpSDK.addTag(name: tagName,
81-
emailAddress: "[email protected]") { result in
82-
switch result {
83-
case .success:
84-
print("Successfully added tag: \(tagName)")
85-
case .failure(let error):
86-
print("Error: \(error.localizedDescription)")
87-
}
88-
}
89-
90-
MailchimpSDK.removeTag(name: tagName,
91-
emailAddress: "[email protected]") { result in
92-
switch result {
93-
case .success:
94-
print("Successfully removed tag: \(tagName)")
95-
case .failure(let error):
96-
print("Error: \(error.localizedDescription)")
97-
}
98-
}
96+
MailchimpSDK.addTag(name: tagName,
97+
emailAddress: "[email protected]") { result in
98+
switch result {
99+
case .success:
100+
print("Successfully added tag: \(tagName)")
101+
case .failure(let error):
102+
print("Error: \(error.localizedDescription)")
103+
}
104+
}
105+
106+
MailchimpSDK.removeTag(name: tagName,
107+
emailAddress: "[email protected]") { result in
108+
switch result {
109+
case .success:
110+
print("Successfully removed tag: \(tagName)")
111+
case .failure(let error):
112+
print("Error: \(error.localizedDescription)")
113+
}
114+
}
99115
```
100116

101117
### Set Merge Fields
102118

103119
```swift
104-
MailchimpSDK.setMergeField(emailAddress: "[email protected]",
105-
name: fieldName,
106-
value: fieldValue) { result in
107-
switch result {
108-
case .success:
109-
print("Successfully added merge field: \(fieldName), \(fieldValue)")
110-
case .failure(let error):
111-
print("Error: \(error.localizedDescription)")
112-
}
113-
}
120+
MailchimpSDK.setMergeField(emailAddress: "[email protected]",
121+
name: fieldName,
122+
value: fieldValue) { result in
123+
switch result {
124+
case .success:
125+
print("Successfully added merge field: \(fieldName), \(fieldValue)")
126+
case .failure(let error):
127+
print("Error: \(error.localizedDescription)")
128+
}
129+
}
114130
```
115131
## Contact Schema
116132

@@ -142,12 +158,12 @@ Merge Fields of type address are represented as an Address struct. Addresses hav
142158
In addition there are three optional fields, Address Line Two, State, and Country. Below is an example of an Address object.
143159

144160
```swift
145-
let address = Address(addressLineOne: "123 Chimp St.",
146-
addressLineTwo: "Suite 456",
147-
city: "Atlanta",
148-
state: "GA",
149-
zipCode: "30308",
150-
country: CountryCode.USA)
161+
let address = Address(addressLineOne: "123 Chimp St.",
162+
addressLineTwo: "Suite 456",
163+
city: "Atlanta",
164+
state: "GA",
165+
zipCode: "30308",
166+
country: CountryCode.USA)
151167
```
152168

153169
### Contact Status
@@ -162,7 +178,7 @@ Appropriate marketing permissions need to be set to communicate with any contact
162178
Marketing permissions are set by instantiating a MarketingPermission struct with the corresponding `marketingPermissionsId` and setting `enabled` if the user granted permission for that permission ID.
163179

164180
```swift
165-
let permission1 = Contact.MarketingPermission(marketingPermissionId: "permission1", enabled: true)
181+
let permission1 = Contact.MarketingPermission(marketingPermissionId: "permission1", enabled: true)
166182
```
167183

168184
## Collecting contact events
@@ -172,15 +188,15 @@ Marketing permissions are set by instantiating a MarketingPermission struct with
172188
To add an event associated with a contact, first instantiate a new Event struct. Then pass the event into the `trackEventWithAttributes()` method. This will add the event to the specified contact.
173189

174190
```swift
175-
let event: Event = try! Event(emailAddress: "[email protected]", name: "signup", properties: ["source": "iOS"])
176-
MailchimpSDK.trackEventWithAttributes(event: event) { result in
177-
switch result {
178-
case .success:
179-
print("Successfully tracked an event")
180-
case .failure(let error):
181-
print("Error: \(error.localizedDescription)")
182-
}
191+
let event: Event = try! Event(emailAddress: "[email protected]", name: "signup", properties: ["source": "iOS"])
192+
MailchimpSDK.trackEventWithAttributes(event: event) { result in
193+
switch result {
194+
case .success:
195+
print("Successfully tracked an event")
196+
case .failure(let error):
197+
print("Error: \(error.localizedDescription)")
183198
}
199+
}
184200
```
185201

186202
## Event Schema

0 commit comments

Comments
 (0)