Skip to content

Commit b0a4036

Browse files
Merge pull request #23 from Iterable/feature/itbl-5996-additional-fields
[itbl-5996] - add additional fields
2 parents 61b3839 + 5cbbd92 commit b0a4036

35 files changed

+1204
-1616
lines changed

Iterable-iOS-SDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Pod::Spec.new do |s|
7272
# Not including the public_header_files will make all headers public.
7373
#
7474

75-
s.source_files = "swift-sdk/*.{h,m,swift}"
75+
s.source_files = "swift-sdk/**/*.{h,m,swift}"
7676

7777
s.pod_target_xcconfig = {
7878
'SWIFT_VERSION' => '4.1'

Tests/swift-sdk-objc-tests/IterableAPIInternalTests.m renamed to Tests/swift-sdk-objc-tests/IterableAPIObjCTests.m

Lines changed: 26 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
static CGFloat const IterableNetworkResponseExpectationTimeout = 5.0;
1818

19-
@interface IterableAPIInternalTests : XCTestCase
19+
@interface IterableAPIObjCTests : XCTestCase
2020
@end
2121

22-
@implementation IterableAPIInternalTests
22+
@implementation IterableAPIObjCTests
2323

2424
NSString *redirectRequest = @"https://httpbin.org/redirect-to?url=http://example.com";
2525
NSString *exampleUrl = @"http://example.com";
@@ -31,28 +31,14 @@ @implementation IterableAPIInternalTests
3131

3232
- (void)setUp {
3333
[super setUp];
34-
[IterableAPIInternal initializeWithApiKey:@""];
34+
[IterableAPI initializeWithApiKey:@""];
3535
}
3636

3737
- (void)tearDown {
3838
// Put teardown code here. This method is called after the invocation of each test method in the class.
3939
[super tearDown];
4040
}
4141

42-
- (void)testPushServicePlatformToString {
43-
XCTAssertEqualObjects(@"APNS", [IterableAPIInternal pushServicePlatformToString:APNS]);
44-
XCTAssertEqualObjects(@"APNS_SANDBOX", [IterableAPIInternal pushServicePlatformToString:APNS_SANDBOX]);
45-
}
46-
47-
- (void)testUserInterfaceIdionEnumToString {
48-
XCTAssertEqualObjects(@"Phone", [IterableAPIInternal userInterfaceIdiomEnumToString:UIUserInterfaceIdiomPhone]);
49-
XCTAssertEqualObjects(@"Pad", [IterableAPIInternal userInterfaceIdiomEnumToString:UIUserInterfaceIdiomPad]);
50-
// we don't care about TVs for now
51-
XCTAssertEqualObjects(@"Unspecified", [IterableAPIInternal userInterfaceIdiomEnumToString:UIUserInterfaceIdiomTV]);
52-
XCTAssertEqualObjects(@"Unspecified", [IterableAPIInternal userInterfaceIdiomEnumToString:UIUserInterfaceIdiomUnspecified]);
53-
XCTAssertEqualObjects(@"Unspecified", [IterableAPIInternal userInterfaceIdiomEnumToString:192387]);
54-
}
55-
5642
- (void)testUniversalDeeplinkRewrite {
5743
XCTestExpectation *expectation = [self expectationWithDescription:@"High Expectations"];
5844
NSURL *iterableLink = [NSURL URLWithString:iterableRewriteURL];
@@ -61,7 +47,7 @@ - (void)testUniversalDeeplinkRewrite {
6147
XCTAssertTrue(NSThread.isMainThread);
6248
[expectation fulfill];
6349
};
64-
[IterableAPIInternal getAndTrackDeeplink:iterableLink callbackBlock:aBlock];
50+
[IterableAPI getAndTrackDeeplink:iterableLink callbackBlock:aBlock];
6551

6652
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
6753
}
@@ -73,7 +59,7 @@ - (void)testUniversalDeeplinkNoRewrite {
7359
XCTAssertEqualObjects(iterableNoRewriteURL, redirectUrl);
7460
[expectation fulfill];
7561
};
76-
[IterableAPIInternal getAndTrackDeeplink:normalLink callbackBlock:uBlock];
62+
[IterableAPI getAndTrackDeeplink:normalLink callbackBlock:uBlock];
7763

7864
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
7965
}
@@ -90,9 +76,9 @@ - (void)testHandleUniversalLinkRewrite {
9076

9177
IterableConfig *config = [[IterableConfig alloc] init];
9278
config.urlDelegate = urlDelegateMock;
93-
[IterableAPIInternal initializeWithApiKey:@"" config:config];
79+
[IterableAPI initializeWithApiKey:@"" config:config];
9480
NSURL *iterableLink = [NSURL URLWithString:iterableRewriteURL];
95-
[[IterableAPIInternal sharedInstance] handleUniversalLink:iterableLink];
81+
[IterableAPI handleUniversalLink:iterableLink];
9682

9783
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
9884
}
@@ -105,12 +91,12 @@ - (void)testDeeplinkAttributionInfo {
10591
XCTestExpectation *expectation = [self expectationWithDescription:@"High Expectations"];
10692
NSURL *normalLink = [NSURL URLWithString:iterableRewriteURL];
10793
ITEActionBlock uBlock = ^(NSString* redirectUrl) {
108-
XCTAssertEqualObjects(IterableAPIInternal.sharedInstance.attributionInfo.campaignId, campaignId);
109-
XCTAssertEqualObjects(IterableAPIInternal.sharedInstance.attributionInfo.templateId, templateId);
110-
XCTAssertEqualObjects(IterableAPIInternal.sharedInstance.attributionInfo.messageId, messageId);
94+
XCTAssertEqualObjects(IterableAPI.attributionInfo.campaignId, campaignId);
95+
XCTAssertEqualObjects(IterableAPI.attributionInfo.templateId, templateId);
96+
XCTAssertEqualObjects(IterableAPI.attributionInfo.messageId, messageId);
11197
[expectation fulfill];
11298
};
113-
[IterableAPIInternal getAndTrackDeeplink:normalLink callbackBlock:uBlock];
99+
[IterableAPI getAndTrackDeeplink:normalLink callbackBlock:uBlock];
114100

115101
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
116102
}
@@ -123,7 +109,7 @@ - (void)testNoURLRedirect {
123109
XCTAssertNotEqual(exampleUrl, redirectUrl);
124110
XCTAssertEqualObjects(redirectRequest, redirectUrl);
125111
};
126-
[IterableAPIInternal getAndTrackDeeplink:redirectLink callbackBlock:redirectBlock];
112+
[IterableAPI getAndTrackDeeplink:redirectLink callbackBlock:redirectBlock];
127113

128114
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
129115
}
@@ -136,7 +122,7 @@ - (void)testUniversalDeeplinkHttp {
136122
XCTAssertEqualObjects(googleHttps, redirectUrl);
137123
XCTAssertNotEqual(googleHttp, redirectUrl);
138124
};
139-
[IterableAPIInternal getAndTrackDeeplink:googleHttpLink callbackBlock:googleHttpBlock];
125+
[IterableAPI getAndTrackDeeplink:googleHttpLink callbackBlock:googleHttpBlock];
140126

141127
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
142128
}
@@ -150,47 +136,11 @@ - (void)testUniversalDeeplinkHttps {
150136
[expectation fulfill];
151137
XCTAssertEqualObjects(googleHttps, redirectUrl);
152138
};
153-
[IterableAPIInternal getAndTrackDeeplink:googleHttpsLink callbackBlock:googleHttpsBlock];
139+
[IterableAPI getAndTrackDeeplink:googleHttpsLink callbackBlock:googleHttpsBlock];
154140

155141
[self waitForExpectationsWithTimeout:IterableNetworkResponseExpectationTimeout handler:nil];
156142
}
157143

158-
- (void)testURLQueryParamRewrite {
159-
[IterableAPIInternal initializeWithApiKey:@""];
160-
161-
NSCharacterSet* set = [NSCharacterSet URLQueryAllowedCharacterSet];
162-
163-
NSMutableString* strSet =[NSMutableString string];
164-
for (int plane = 0; plane <= 16; plane++) {
165-
if ([set hasMemberInPlane:plane]) {
166-
UTF32Char c;
167-
for (c = plane << 16; c < (plane+1) << 16; c++) {
168-
if ([set longCharacterIsMember:c]) {
169-
UTF32Char c1 = OSSwapHostToLittleInt32(c);
170-
NSString *s = [[NSString alloc] initWithBytes:&c1 length:4 encoding:NSUTF32LittleEndianStringEncoding];
171-
[strSet appendString:s];
172-
}
173-
}
174-
}
175-
}
176-
177-
//Test full set of possible URLQueryAllowedCharacterSet characters
178-
NSString* encodedSet = [[IterableAPIInternal sharedInstance] encodeURLParam:strSet];
179-
XCTAssertNotEqual(encodedSet, strSet);
180-
XCTAssert([encodedSet isEqualToString:@"!$&'()*%2B,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~"]);
181-
182-
NSString* encoded = [[IterableAPIInternal sharedInstance] encodeURLParam:@"[email protected]"];
183-
XCTAssertNotEqual(encoded, @"[email protected]");
184-
XCTAssert([encoded isEqualToString:@"you%[email protected]"]);
185-
186-
NSString* emptySet = [[IterableAPIInternal sharedInstance] encodeURLParam:@""];
187-
XCTAssertEqual(emptySet, @"");
188-
XCTAssert([emptySet isEqualToString:@""]);
189-
190-
NSString* nilSet = [[IterableAPIInternal sharedInstance] encodeURLParam:nil];
191-
XCTAssertEqualObjects(nilSet, nil);
192-
}
193-
194144
- (void)testRegisterToken {
195145
XCTestExpectation *expectation = [[XCTestExpectation alloc] initWithDescription:@"Request is sent"];
196146
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
@@ -209,27 +159,27 @@ - (void)testRegisterToken {
209159

210160
IterableConfig *config = [[IterableConfig alloc] init];
211161
config.pushIntegrationName = @"pushIntegration";
212-
[IterableAPIInternal initializeWithApiKey:@"apiKey" config:config];
213-
[[IterableAPIInternal sharedInstance] setEmail:@"[email protected]"];
214-
[[IterableAPIInternal sharedInstance] registerToken:[@"token" dataUsingEncoding:kCFStringEncodingUTF8]];
162+
[IterableAPI initializeWithApiKey:@"apiKey" config:config];
163+
IterableAPI.email = @"[email protected]";
164+
[IterableAPI registerToken:[@"token" dataUsingEncoding:kCFStringEncodingUTF8]];
215165

216166
[self waitForExpectations:@[expectation] timeout:5.0];
217167
[OHHTTPStubs removeAllStubs];
218168
}
219169

220170
- (void)testEmailUserIdPersistence {
221-
[IterableAPIInternal initializeWithApiKey:@"apiKey"];
222-
[[IterableAPIInternal sharedInstance] setEmail:@"[email protected]"];
171+
[IterableAPI initializeWithApiKey:@"apiKey"];
172+
IterableAPI.email = @"[email protected]";
223173

224-
[IterableAPIInternal initializeWithApiKey:@"apiKey"];
225-
XCTAssertEqualObjects([IterableAPIInternal sharedInstance].email, @"[email protected]");
226-
XCTAssertNil([IterableAPIInternal sharedInstance].userId);
174+
[IterableAPI initializeWithApiKey:@"apiKey"];
175+
XCTAssertEqualObjects(IterableAPI.email, @"[email protected]");
176+
XCTAssertNil(IterableAPI.userId);
227177

228-
[[IterableAPIInternal sharedInstance] setUserId:@"testUserId"];
178+
IterableAPI.userId = @"testUserId";
229179

230-
[IterableAPIInternal initializeWithApiKey:@"apiKey"];
231-
XCTAssertEqualObjects([IterableAPIInternal sharedInstance].userId, @"testUserId");
232-
XCTAssertNil([IterableAPIInternal sharedInstance].email);
180+
[IterableAPI initializeWithApiKey:@"apiKey"];
181+
XCTAssertEqualObjects(IterableAPI.userId, @"testUserId");
182+
XCTAssertNil(IterableAPI.email);
233183
}
234184

235185

0 commit comments

Comments
 (0)