Skip to content

Commit

Permalink
feat: test observe did changeSreeenNotification
Browse files Browse the repository at this point in the history
  • Loading branch information
Alyssa.Yu authored and Alyssa.Yu committed Sep 5, 2023
1 parent b0dbcae commit 478f63c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Sources/Amplitude/UIViewController+AMPScreen.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#import "UIViewController+AMPScreen.h"
#import "Amplitude.h"
#import "AMPConstants.h"
#import <UIKit/UIKit.h>

static NSNotificationName const __UIWindowSceneDidChangeScreenNotification = @"__UIWindowSceneDidChangeScreenNotification";


#if !TARGET_OS_OSX && !TARGET_OS_WATCH

Expand Down Expand Up @@ -134,7 +138,10 @@ - (void)amp_viewDidAppear:(BOOL)animated {
}
}

NSLog(@"**********Before print view hierarchy**********");
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(screenChanged:)
name:__UIWindowSceneDidChangeScreenNotification
object:nil];


[[Amplitude instance] logEvent:kAMPScreenViewed withEventProperties:@{
Expand All @@ -143,7 +150,12 @@ - (void)amp_viewDidAppear:(BOOL)animated {

// call original method, this is not recurrsive method call
[self amp_viewDidAppear:animated];

}

- (void)screenChanged:(NSNotification *)notification {
// Handle the screen change here
NSLog(@"**********Before print view hierarchy**********");
NSLog(@"Screen changed!");
printViewHierarchy(self.view, 0);
}

Expand Down

0 comments on commit 478f63c

Please sign in to comment.