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: Infinite recursion when custom config is used #9

Merged
merged 1 commit into from
Jan 10, 2023
Merged
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
14 changes: 9 additions & 5 deletions mParticle-iterable/MPKitIterable.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ @interface MPKitIterable() <IterableURLDelegate>
@implementation MPKitIterable

@synthesize kitApi = _kitApi;
static IterableConfig *_customConfig = nil;
static NSURL *_clickedURL = nil;
static __strong IterableConfig *_customConfig = nil;
static __strong id <IterableURLDelegate> _customUrlDelegate = nil;
static __strong NSURL *_clickedURL = nil;

+ (NSNumber *)kitCode {
return @1003;
Expand All @@ -24,13 +25,16 @@ + (void)load {

+ (void)setCustomConfig:(IterableConfig *_Nullable)config {
_customConfig = config;
_customUrlDelegate = config.urlDelegate;
}

- (BOOL)handleIterableURL:(NSURL *)url context:(IterableActionContext *)context {
BOOL result = YES;
if (_customConfig.urlDelegate != nil && [((NSObject *)_customConfig.urlDelegate) respondsToSelector:@selector(handleIterableURL:context:)]) {
result = [_customConfig.urlDelegate handleIterableURL:url context: context];
} else if (_customConfig.urlDelegate != nil) {
if (_customUrlDelegate == self) {
NSLog(@"mParticle -> Error: Iterable urlDelegate was set in custom config but points to the MKKitIterable instance. It should be a different object.");
} else if (_customUrlDelegate != nil && [((NSObject *)_customUrlDelegate) respondsToSelector:@selector(handleIterableURL:context:)]) {
result = [_customUrlDelegate handleIterableURL:url context: context];
} else if (_customUrlDelegate != nil) {
NSLog(@"mParticle -> Error: Iterable urlDelegate was set in custom config but didn't respond to the selector 'handleIterableURL:context:'");
}

Expand Down