Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Setting urlDelegate on Braze instance #90

Merged
merged 1 commit into from
May 28, 2024
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
12 changes: 6 additions & 6 deletions Sources/mParticle-Appboy/MPKitAppboy.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
static NSString *const impressionKey = @"impressions";

#if TARGET_OS_IOS
__weak static id<BrazeInAppMessageUIDelegate> inAppMessageControllerDelegate = nil;
static id<BrazeInAppMessageUIDelegate> inAppMessageControllerDelegate = nil;
static BOOL shouldDisableNotificationHandling = NO;
#endif
__weak static id<BrazeDelegate> urlDelegate = nil;
static id<BrazeDelegate> urlDelegate = nil;
static Braze *brazeInstance = nil;
static id brazeLocationProvider = nil;
static NSSet<BRZTrackingProperty*> *brazeTrackingPropertyAllowList;
Expand Down Expand Up @@ -367,6 +367,10 @@ - (void)start {
}
[self->appboyInstance setAdTrackingEnabled:[self isAppTrackingEnabled]];

if ([MPKitAppboy urlDelegate]) {
self->appboyInstance.delegate = [MPKitAppboy urlDelegate];
}

#if TARGET_OS_IOS
BrazeInAppMessageUI *inAppMessageUI = [[BrazeInAppMessageUI alloc] init];
inAppMessageUI.delegate = [MPKitAppboy inAppMessageControllerDelegate];
Expand Down Expand Up @@ -447,10 +451,6 @@ - (void)start {
}
#endif

if ([MPKitAppboy urlDelegate]) {
optionsDictionary[ABKURLDelegateKey] = (NSObject *)[MPKitAppboy urlDelegate];
}

return optionsDictionary;
}

Expand Down
5 changes: 3 additions & 2 deletions mParticle_AppboyTests/mParticle_AppboyTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ - (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
[MPKitAppboy setBrazeInstance:nil];
[MPKitAppboy setURLDelegate:nil];
}

- (void)tearDown {
Expand Down Expand Up @@ -261,7 +262,7 @@ - (void)testSetMessageDelegate {
[self waitForExpectationsWithTimeout:1 handler:nil];
}

- (void)testWeakMessageDelegate {
- (void)testStrongMessageDelegate {
id<BrazeInAppMessageUIDelegate> delegate = (id)[NSObject new];

[MPKitAppboy setInAppMessageControllerDelegate:delegate];
Expand All @@ -271,7 +272,7 @@ - (void)testWeakMessageDelegate {
XCTestExpectation *expectation = [self expectationWithDescription:@"async work"];

dispatch_async(dispatch_get_main_queue(), ^{
XCTAssertNil([MPKitAppboy inAppMessageControllerDelegate]);
XCTAssertNotNil([MPKitAppboy inAppMessageControllerDelegate]);
[expectation fulfill];
});

Expand Down
Loading