diff --git a/Sources/AdAllianceSDK/Classes/GUJAdViewContext.m b/Sources/AdAllianceSDK/Classes/GUJAdViewContext.m index 5dd7d2669c6d72a605a0af436db57b5bc15711b8..5a4d5fc0edbd19aba825be052539a375f139dc9c 100755 --- a/Sources/AdAllianceSDK/Classes/GUJAdViewContext.m +++ b/Sources/AdAllianceSDK/Classes/GUJAdViewContext.m @@ -116,10 +116,16 @@ static NSString *const CUSTOM_TARGETING_KEY_APP_NAME = @"app_name"; if (isIndex != nil) { adViewContext.isIndex = [isIndex boolValue]; } + [[GUJIdentity sharedManager] addListener:adViewContext]; return adViewContext; } +- (void)dealloc { + [[GUJIdentity sharedManager] removeListener:self]; +} + + + (GUJAdViewContext *)instanceForAdspaceId:(NSString *)adSpaceId delegate:(id <GUJAdViewContextDelegate>)delegate { GUJAdViewContext *adViewContext = [self instanceForAdspaceId:adSpaceId]; adViewContext.delegate = delegate; @@ -150,6 +156,7 @@ static NSString *const CUSTOM_TARGETING_KEY_APP_NAME = @"app_name"; adViewContext.adUnitId = adUnitId; adViewContext.position = position; adViewContext.rootViewController = rootViewController; + [[GUJIdentity sharedManager] addListener:adViewContext]; return adViewContext; } @@ -326,9 +333,6 @@ static NSString *const CUSTOM_TARGETING_KEY_APP_NAME = @"app_name"; - (GAMBannerView *)adViewWithOrigin:(CGPoint)origin { - // identity listener add - [[GUJIdentity sharedManager] addListener:self]; - // stuff BOOL isLandscape = UIApplication.sharedApplication.statusBarOrientation; self.bannerView = [[GAMBannerView alloc] initWithAdSize:GADAdSizeFromCGSize(CGSizeMake(1, 1)) origin:origin]; diff --git a/Sources/AdAllianceSDK/Classes/GUJIdentity.m b/Sources/AdAllianceSDK/Classes/GUJIdentity.m index a0fac49ff8fd4aa04870af970bfc59669886dab4..619fb89ba84f693bcc3da67442ee0ed180b6cb1f 100644 --- a/Sources/AdAllianceSDK/Classes/GUJIdentity.m +++ b/Sources/AdAllianceSDK/Classes/GUJIdentity.m @@ -23,7 +23,7 @@ NSString* tpid; NSString* url; NSString* hem; - NSMutableArray* listeners; + NSHashTable* listeners; } + (instancetype)sharedManager { @@ -40,7 +40,7 @@ instance->tpid = @""; instance->url = @""; instance->hem = @""; - instance->listeners = [NSMutableArray new]; + instance->listeners = [NSHashTable weakObjectsHashTable]; [[GUJConsent sharedManager] addPurposeListener:instance]; // add Listener for netid & hem [instance addListener:instance];