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 UI api on background thread when running unit tests #1120

Merged
merged 2 commits into from
Aug 29, 2022
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
6 changes: 6 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
DE3CD2FF270FA9F200A5BECD /* OneSignalOutcomes.m in Sources */ = {isa = PBXBuildFile; fileRef = DE3CD2FE270FA9F200A5BECD /* OneSignalOutcomes.m */; };
DE3CD300270FA9F200A5BECD /* OneSignalOutcomes.m in Sources */ = {isa = PBXBuildFile; fileRef = DE3CD2FE270FA9F200A5BECD /* OneSignalOutcomes.m */; };
DE5EFECA24D8DBF70032632D /* OSInAppMessageViewControllerOverrider.m in Sources */ = {isa = PBXBuildFile; fileRef = DE5EFEC924D8DBF70032632D /* OSInAppMessageViewControllerOverrider.m */; };
DE75B3E028BD432800162A95 /* OneSignalUNUserNotificationCenterOverrider.m in Sources */ = {isa = PBXBuildFile; fileRef = DE75B3DE28BD432700162A95 /* OneSignalUNUserNotificationCenterOverrider.m */; };
DE7D17EA27026B95002D3A5D /* OneSignalCore.docc in Sources */ = {isa = PBXBuildFile; fileRef = DE7D17E927026B95002D3A5D /* OneSignalCore.docc */; };
DE7D17EB27026B95002D3A5D /* OneSignalCore.h in Headers */ = {isa = PBXBuildFile; fileRef = DE7D17E827026B95002D3A5D /* OneSignalCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
DE7D17FD27026BA3002D3A5D /* OneSignalExtension.docc in Sources */ = {isa = PBXBuildFile; fileRef = DE7D17FC27026BA3002D3A5D /* OneSignalExtension.docc */; };
Expand Down Expand Up @@ -917,6 +918,8 @@
DE3CD2FE270FA9F200A5BECD /* OneSignalOutcomes.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalOutcomes.m; sourceTree = "<group>"; };
DE5EFEC924D8DBF70032632D /* OSInAppMessageViewControllerOverrider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSInAppMessageViewControllerOverrider.m; sourceTree = "<group>"; };
DE5EFECB24D8DC0E0032632D /* OSInAppMessageViewControllerOverrider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSInAppMessageViewControllerOverrider.h; sourceTree = "<group>"; };
DE75B3DE28BD432700162A95 /* OneSignalUNUserNotificationCenterOverrider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OneSignalUNUserNotificationCenterOverrider.m; sourceTree = "<group>"; };
DE75B3DF28BD432800162A95 /* OneSignalUNUserNotificationCenterOverrider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneSignalUNUserNotificationCenterOverrider.h; sourceTree = "<group>"; };
DE7D17E627026B95002D3A5D /* OneSignalCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OneSignalCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DE7D17E827026B95002D3A5D /* OneSignalCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalCore.h; sourceTree = "<group>"; };
DE7D17E927026B95002D3A5D /* OneSignalCore.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = OneSignalCore.docc; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1133,6 +1136,8 @@
4529DECD1FA81DE000CEAB1D /* Shadows */ = {
isa = PBXGroup;
children = (
DE75B3DF28BD432800162A95 /* OneSignalUNUserNotificationCenterOverrider.h */,
DE75B3DE28BD432700162A95 /* OneSignalUNUserNotificationCenterOverrider.m */,
7A65D628246627AD007FF196 /* OSInAppMessageViewOverrider.h */,
7A65D629246627AD007FF196 /* OSInAppMessageViewOverrider.m */,
5B58E4F3237CE7B3009401E0 /* UIDeviceOverrider.h */,
Expand Down Expand Up @@ -2530,6 +2535,7 @@
9129C6C01E89E7AB009CB6A0 /* OSSubscription.m in Sources */,
7AC8D3A824993A0E0023EDE8 /* OSDeviceState.m in Sources */,
A6D7093E26962C96007B3347 /* OneSignalSetLanguageParameters.m in Sources */,
DE75B3E028BD432800162A95 /* OneSignalUNUserNotificationCenterOverrider.m in Sources */,
7AFE856D2368DDB80091D6A5 /* OSFocusCallParams.m in Sources */,
CA8E19082193C76D009DA223 /* OSInAppMessagingHelpers.m in Sources */,
4529DEE11FA82AB300CEAB1D /* NSBundleOverrider.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/UIApplication+OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@implementation UIApplication (OneSignal)

+ (BOOL)applicationIsActive {
if ([self isAppUsingUIScene]) {
if ([self isAppUsingUIScene] && [NSThread isMainThread]) {
if (@available(iOS 13.0, *)) {
UIWindow *keyWindow = UIApplication.sharedApplication.keyWindow;
id windowScene = [keyWindow performSelector:@selector(windowScene)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,20 @@ + (void)load {
[OSInAppMessageViewOverrider class],
@selector(overrideLoadedHtmlContent:withBaseURL:)
);
injectSelector(
[OSInAppMessageView class],
@selector(setIsFullscreen:),
[OSInAppMessageViewOverrider class],
@selector(overrideSetIsFullscreen:)
);
}

- (void)overrideLoadedHtmlContent:(NSString *)html withBaseURL:(NSURL *)url {

}

- (void)overrideSetIsFullscreen:(BOOL)isFullscreen {

}

@end