Skip to content

Commit

Permalink
WKApplication is only available on WatchOS 7+
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenerud committed Oct 12, 2023
1 parent e307d03 commit 8af8080
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Bugsnag/Helpers/BSGRunContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ static bool GetIsActive(void) {
if ([BSG_KSSystemInfo isRunningInAppExtension]) {
WKExtension *ext = [WKExtension sharedExtension];
return ext && ext.applicationState == WKApplicationStateActive;
} else {
} else if (@available(watchOS 7.0, *)) {
WKApplication *app = [WKApplication sharedApplication];
return app && app.applicationState == WKApplicationStateActive;
} else {
return true;
}
#endif
}
Expand Down Expand Up @@ -175,9 +177,11 @@ static bool GetIsForeground(void) {
if ([BSG_KSSystemInfo isRunningInAppExtension]) {
WKExtension *ext = [WKExtension sharedExtension];
return ext && ext.applicationState != WKApplicationStateBackground;
} else {
} else if (@available(watchOS 7.0, *)) {
WKApplication *app = [WKApplication sharedApplication];
return app && app.applicationState == WKApplicationStateBackground;
} else {
return true;
}
#endif
}
Expand Down

0 comments on commit 8af8080

Please sign in to comment.