Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Xcode
build/
.build/
*.pbxuser
!default.pbxuser
*.mode1v3
Expand Down
6 changes: 3 additions & 3 deletions Example/mParticleExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ - (void)selectDarkOverlayPlacement {
roktConfig.colorMode = MPColorModeDark;
[[MParticle sharedInstance].rokt selectPlacements:@"RoktLayout"
attributes:customAttributes
placements:nil
embeddedViews:nil
config:roktConfig
callbacks:nil];
}
Expand Down Expand Up @@ -235,9 +235,9 @@ - (void)selectEmbeddedPlacement {
[self setupUI:size];
};

NSDictionary *placements = @{@"Location1": self.roktView};
NSDictionary *embeddedViews = @{@"Location1": self.roktView};

[[MParticle sharedInstance].rokt selectPlacements:@"testiOS" attributes:customAttributes placements:placements config:nil callbacks:callbacks];
[[MParticle sharedInstance].rokt selectPlacements:@"testiOS" attributes:customAttributes embeddedViews:embeddedViews config:nil callbacks:callbacks];
}

- (void)getAudience {
Expand Down
58 changes: 29 additions & 29 deletions UnitTests/MPRoktTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ - (void)testSelectPlacementsSimpleWithValidParameters {
}] identify:[OCMArg any] completion:[OCMArg any]];

// Set up test parameters
NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"email": @"test@gmail.com", @"sandbox": @"false"};

// Set up expectations for kit container
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for async operation"];
SEL roktSelector = @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:);
SEL roktSelector = @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:);
OCMExpect([self.mockContainer forwardSDKCall:roktSelector
event:nil
parameters:[OCMArg checkWithBlock:^BOOL(MPForwardQueueParameters *params) {
XCTAssertEqualObjects(params[0], viewName);
XCTAssertEqualObjects(params[0], identifier);
XCTAssertEqualObjects(params[1], attributes);
XCTAssertNil(params[2]);
XCTAssertNil(params[3]);
Expand All @@ -101,7 +101,7 @@ - (void)testSelectPlacementsSimpleWithValidParameters {
});

// Execute method
[self.rokt selectPlacements:viewName
[self.rokt selectPlacements:identifier
attributes:attributes];

// Wait for async operation
Expand All @@ -120,11 +120,11 @@ - (void)testSelectPlacementsExpandedWithValidParameters {
[[[self.mockInstance stub] andReturn:self.mockInstance] sharedInstance];

// Set up test parameters
NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"key": @"value"};
NSDictionary *finalAttributes = @{@"key": @"value", @"sandbox": @"true"};
MPRoktEmbeddedView *exampleView = [[MPRoktEmbeddedView alloc] initWithFrame:CGRectZero];
NSDictionary *placements = @{@"placement": exampleView};
NSDictionary *embeddedViews = @{@"placement": exampleView};
MPRoktEventCallback *exampleCallbacks = [[MPRoktEventCallback alloc] init];
exampleCallbacks.onLoad = ^{};
exampleCallbacks.onUnLoad = ^{};
Expand All @@ -139,13 +139,13 @@ - (void)testSelectPlacementsExpandedWithValidParameters {

// Set up expectations for kit container
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for async operation"];
SEL roktSelector = @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:);
SEL roktSelector = @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:);
OCMExpect([self.mockContainer forwardSDKCall:roktSelector
event:nil
parameters:[OCMArg checkWithBlock:^BOOL(MPForwardQueueParameters *params) {
XCTAssertEqualObjects(params[0], viewName);
XCTAssertEqualObjects(params[0], identifier);
XCTAssertEqualObjects(params[1], finalAttributes);
XCTAssertEqualObjects(params[2], placements);
XCTAssertEqualObjects(params[2], embeddedViews);
XCTAssertEqualObjects(params[3], roktConfig);
MPRoktEventCallback *resultCallbacks = params[4];
XCTAssertEqualObjects(resultCallbacks.onLoad, exampleCallbacks.onLoad);
Expand All @@ -161,9 +161,9 @@ - (void)testSelectPlacementsExpandedWithValidParameters {
});

// Execute method
[self.rokt selectPlacements:viewName
[self.rokt selectPlacements:identifier
attributes:attributes
placements:placements
embeddedViews:embeddedViews
config:roktConfig
callbacks:exampleCallbacks];

Expand All @@ -183,25 +183,25 @@ - (void)testSelectPlacementsExpandedWithNilParameters {
[[[self.mockInstance stub] andReturn:self.mockInstance] sharedInstance];

// Set up test parameters
NSString *viewName = @"testView";
NSString *identifier = @"testView";

// Execute method with nil parameters
[self.rokt selectPlacements:viewName
[self.rokt selectPlacements:identifier
attributes:nil
placements:nil
embeddedViews:nil
config:nil
callbacks:nil];

// Wait for async operation
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for async operation"];

SEL roktSelector = @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:);
SEL roktSelector = @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:);
NSDictionary *finalAttributes = @{@"sandbox": @"true"};

OCMExpect([self.mockContainer forwardSDKCall:roktSelector
event:nil
parameters:[OCMArg checkWithBlock:^BOOL(MPForwardQueueParameters *params) {
XCTAssertEqualObjects(params[0], viewName);
XCTAssertEqualObjects(params[0], identifier);
XCTAssertEqualObjects(params[1], finalAttributes);
XCTAssertNil(params[2]);
XCTAssertNil(params[3]);
Expand All @@ -228,17 +228,17 @@ - (void)testSelectPlacementsSimpleWithMapping {
[[[self.mockInstance stub] andReturn:self.mockInstance] sharedInstance];

// Set up test parameters
NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"f.name": @"Brandon"};
NSDictionary *mappedAttributes = @{@"firstname": @"Brandon", @"sandbox": @"true"};

// Set up expectations for kit container
XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for async operation"];
SEL roktSelector = @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:);
SEL roktSelector = @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:);
OCMExpect([self.mockContainer forwardSDKCall:roktSelector
event:nil
parameters:[OCMArg checkWithBlock:^BOOL(MPForwardQueueParameters *params) {
XCTAssertEqualObjects(params[0], viewName);
XCTAssertEqualObjects(params[0], identifier);
XCTAssertEqualObjects(params[1], mappedAttributes);
XCTAssertNil(params[2]);
XCTAssertNil(params[3]);
Expand All @@ -250,7 +250,7 @@ - (void)testSelectPlacementsSimpleWithMapping {
});

// Execute method
[self.rokt selectPlacements:viewName
[self.rokt selectPlacements:identifier
attributes:attributes];

// Wait for async operation
Expand All @@ -268,19 +268,19 @@ - (void)testSelectPlacementsSimpleWithNilMapping {
[[[self.mockInstance stub] andReturn:self.mockContainer] kitContainer_PRIVATE];
[[[self.mockInstance stub] andReturn:self.mockInstance] sharedInstance];

SEL roktSelector = @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:);
SEL roktSelector = @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:);
OCMReject([self.mockContainer forwardSDKCall:roktSelector
event:[OCMArg any]
parameters:[OCMArg any]
messageType:MPMessageTypeEvent
userInfo:[OCMArg any]]);

// Set up test parameters
NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"f.name": @"Brandon"};

// Execute method
[self.rokt selectPlacements:viewName
[self.rokt selectPlacements:identifier
attributes:attributes];

// Verify
Expand Down Expand Up @@ -323,7 +323,7 @@ - (void)testSelectPlacementsIdentifyUser {
[[[self.mockInstance stub] andReturn:self.mockInstance] sharedInstance];

// Set up test parameters
NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"email": @"test@gmail.com", @"sandbox": @"false"};

// Set up expectations for kit container
Expand All @@ -333,7 +333,7 @@ - (void)testSelectPlacementsIdentifyUser {
});

// Execute method
[self.rokt selectPlacements:viewName attributes:attributes];
[self.rokt selectPlacements:identifier attributes:attributes];

// Wait for async operation
[self waitForExpectationsWithTimeout:0.2 handler:nil];
Expand All @@ -358,10 +358,10 @@ - (void)testTriggeredIdentifyWithNoIdentities {
return true;
}] completion:OCMOCK_ANY];

NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"email": @"test@gmail.com", @"sandbox": @"false"};

[self.rokt selectPlacements:viewName attributes:attributes];
[self.rokt selectPlacements:identifier attributes:attributes];

[self.identityMock verifyWithDelay:0.2];
}
Expand Down Expand Up @@ -389,10 +389,10 @@ - (void)testTriggeredIdentifyWithMismatchedEmailIdentity {
return true;
}] completion:OCMOCK_ANY];

NSString *viewName = @"testView";
NSString *identifier = @"testView";
NSDictionary *attributes = @{@"email": @"test@gmail.com", @"sandbox": @"false"};

[self.rokt selectPlacements:viewName attributes:attributes];
[self.rokt selectPlacements:identifier attributes:attributes];

[self.identityMock verifyWithDelay:0.2];
}
Expand Down
4 changes: 2 additions & 2 deletions mParticle-Apple-SDK/Include/MPKitProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@
- (nonnull NSArray<MPForwardRecord *> *)logBatch:(nonnull NSDictionary *)batch;

#pragma mark First Party Kits
- (nonnull MPKitExecStatus *)executeWithViewName:(NSString * _Nullable)viewName
- (nonnull MPKitExecStatus *)executeWithIdentifier:(NSString * _Nullable)identifier
attributes:(NSDictionary<NSString *, NSString *> * _Nonnull)attributes
placements:(NSDictionary<NSString *, MPRoktEmbeddedView *> * _Nullable)placements
embeddedViews:(NSDictionary<NSString *, MPRoktEmbeddedView *> * _Nullable)embeddedViews
config:(MPRoktConfig * _Nullable)config
callbacks:(MPRoktEventCallback * _Nullable)callbacks
filteredUser:(FilteredMParticleUser * _Nonnull)filteredUser;
Expand Down
4 changes: 2 additions & 2 deletions mParticle-Apple-SDK/Include/MPRokt.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ typedef NS_ENUM(NSInteger, MPColorMode) {
*
* @param identifier Unique identifier for the placement
* @param attributes Optional dictionary of attributes to customize the placement
* @param placements Optional dictionary mapping placement names to their embedded views
* @param embeddedViews Optional dictionary mapping placement names to their embedded views
* @param roktEventCallback Optional callback object to handle widget events
*/
- (void)selectPlacements:(NSString *_Nonnull)identifier
attributes:(NSDictionary<NSString *, NSString *> * _Nullable)attributes
placements:(NSDictionary<NSString *, MPRoktEmbeddedView *> * _Nullable)placements
embeddedViews:(NSDictionary<NSString *, MPRoktEmbeddedView *> * _Nullable)embeddedViews
config:(MPRoktConfig * _Nullable)config
callbacks:(MPRoktEventCallback * _Nullable)roktEventCallback;

Expand Down
14 changes: 7 additions & 7 deletions mParticle-Apple-SDK/Kits/MPKitContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2299,18 +2299,18 @@ - (void)attemptToLogEventToKit:(id<MPExtensionKitProtocol>)kitRegister kitFilter
return;
}
execStatus = [kitRegister.wrapperInstance logEvent:((MPEvent *)kitFilter.forwardEvent)];
} else if (selector == @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:)) {
} else if (selector == @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:)) {
if (kitFilter.shouldFilter) {
return;
}
MParticleUser *currentUser = [[[MParticle sharedInstance] identity] currentUser];
FilteredMParticleUser *filteredUser = [[FilteredMParticleUser alloc] initWithMParticleUser:currentUser kitConfiguration:self.kitConfigurations[kitRegister.code]];
execStatus = [kitRegister.wrapperInstance executeWithViewName:parameters[0]
attributes:parameters[1]
placements:parameters[2]
config:parameters[3]
callbacks:parameters[4]
filteredUser:filteredUser];
execStatus = [kitRegister.wrapperInstance executeWithIdentifier:parameters[0]
attributes:parameters[1]
embeddedViews:parameters[2]
config:parameters[3]
callbacks:parameters[4]
filteredUser:filteredUser];
} else if (selector == @selector(logScreen:)) {
if (!kitFilter.forwardEvent || ![kitFilter.forwardEvent isKindOfClass:[MPEvent class]]) {
return;
Expand Down
8 changes: 4 additions & 4 deletions mParticle-Apple-SDK/MPRokt.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ @implementation MPRokt

- (void)selectPlacements:(NSString *)identifier
attributes:(NSDictionary<NSString *, NSString *> * _Nullable)attributes {
[self selectPlacements:identifier attributes:attributes placements:nil config:nil callbacks:nil];
[self selectPlacements:identifier attributes:attributes embeddedViews:nil config:nil callbacks:nil];
}

- (void)selectPlacements:(NSString *)identifier
attributes:(NSDictionary<NSString *, NSString *> * _Nullable)attributes
placements:(NSDictionary<NSString *, MPRoktEmbeddedView *> * _Nullable)placements
embeddedViews:(NSDictionary<NSString *, MPRoktEmbeddedView *> * _Nullable)embeddedViews
config:(MPRoktConfig * _Nullable)config
callbacks:(MPRoktEventCallback * _Nullable)callbacks {
MParticleUser *currentUser = [MParticle sharedInstance].identity.currentUser;
Expand Down Expand Up @@ -68,11 +68,11 @@ - (void)selectPlacements:(NSString *)identifier
MPForwardQueueParameters *queueParameters = [[MPForwardQueueParameters alloc] init];
[queueParameters addParameter:identifier];
[queueParameters addParameter:[self confirmSandboxAttribute:mappedAttributes]];
[queueParameters addParameter:placements];
[queueParameters addParameter:embeddedViews];
[queueParameters addParameter:config];
[queueParameters addParameter:callbacks];

SEL roktSelector = @selector(executeWithViewName:attributes:placements:config:callbacks:filteredUser:);
SEL roktSelector = @selector(executeWithIdentifier:attributes:embeddedViews:config:callbacks:filteredUser:);
[[MParticle sharedInstance].kitContainer_PRIVATE forwardSDKCall:roktSelector
event:nil
parameters:queueParameters
Expand Down
Loading