Skip to content
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
19 changes: 19 additions & 0 deletions GoogleUtilities/Environment/GULAppEnvironmentUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,25 @@ + (BOOL)isAppExtension {
#endif
}

+ (BOOL)isAppClip {
#if TARGET_OS_IOS
// Documented by <a
// href="https://developer.apple.com/documentation/bundleresources/information-property-list/nsappclip">Apple</a>
// App clips have an NSAppClip entry in the top level of their Info.plist.
NSDictionary *appClipEntry = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSAppClip"];
return appClipEntry != nil;
#elif TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_VISION
return NO;
#endif
}

+ (BOOL)supportsBackgroundURLSessionUploads {
// Neither app extensions nor App Clips support background uploads.
BOOL isExtension = self.isAppExtension;
BOOL isAppClip = self.isAppClip;
return !(isExtension || isAppClip);
}

+ (NSString *)applePlatform {
NSString *applePlatform = @"unknown";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ NS_ASSUME_NONNULL_BEGIN
/// Indicates whether it is running inside an extension or an app.
+ (BOOL)isAppExtension;

/// Indicates whether it is running inside an app clip or a full app.
+ (BOOL)isAppClip;

/// Indicates whether the current target supports background URL session uploads.
/// App extensions and app clips do not support background URL sessions.
+ (BOOL)supportsBackgroundURLSessionUploads;

/// @return An Apple platform. Possible values "ios", "tvos", "macos", "watchos", "maccatalyst", and
/// "visionos".
+ (NSString *)applePlatform;
Expand Down