|
|
@@ -23,6 +23,17 @@ static NSString *const kUserInfoServer = @"www.googleapis.com";
|
|
|
// The name of the query parameter used for logging the SDK version.
|
|
|
NSString *const kSDKVersionLoggingParameter = @"gpsdk";
|
|
|
|
|
|
+// The name of the query parameter used for logging the Apple execution environment.
|
|
|
+NSString *const kEnvironmentLoggingParameter = @"gidenv";
|
|
|
+
|
|
|
+// Supported Apple execution environments
|
|
|
+static NSString *const kAppleEnvironmentUnknown = @"unknown";
|
|
|
+static NSString *const kAppleEnvironmentIOS = @"ios";
|
|
|
+static NSString *const kAppleEnvironmentIOSSimulator = @"ios-sim";
|
|
|
+static NSString *const kAppleEnvironmentMacOS = @"macos";
|
|
|
+static NSString *const kAppleEnvironmentMacOSIOSOnMac = @"macos-ios";
|
|
|
+static NSString *const kAppleEnvironmentMacOSMacCatalyst = @"macos-cat";
|
|
|
+
|
|
|
#ifndef GID_SDK_VERSION
|
|
|
#error "GID_SDK_VERSION is not defined: add -DGID_SDK_VERSION=x.x.x to the build invocation."
|
|
|
#endif
|
|
|
@@ -39,6 +50,36 @@ NSString* GIDVersion(void) {
|
|
|
return [NSString stringWithFormat:@"gid-%@", @STR(GID_SDK_VERSION)];
|
|
|
}
|
|
|
|
|
|
+// Get the current Apple execution environment.
|
|
|
+NSString* GIDEnvironment(void) {
|
|
|
+ NSString *appleEnvironment = kAppleEnvironmentUnknown;
|
|
|
+
|
|
|
+#if TARGET_OS_MACCATALYST
|
|
|
+ appleEnvironment = kAppleEnvironmentMacOSMacCatalyst;
|
|
|
+#elif TARGET_OS_IOS
|
|
|
+#if TARGET_OS_SIMULATOR
|
|
|
+ appleEnvironment = kAppleEnvironmentIOSSimulator;
|
|
|
+#else // TARGET_OS_SIMULATOR
|
|
|
+#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
|
|
|
+ if (@available(iOS 14.0, *)) {
|
|
|
+ if ([NSProcessInfo.processInfo respondsToSelector:@selector(isiOSAppOnMac)]) {
|
|
|
+ appleEnvironment = NSProcessInfo.processInfo.iOSAppOnMac ? kAppleEnvironmentMacOSIOSOnMac :
|
|
|
+ kAppleEnvironmentIOS;
|
|
|
+ } else {
|
|
|
+ appleEnvironment = kAppleEnvironmentIOS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+#else // defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
|
|
|
+ appleEnvironment = kAppleEnvironmentIOS;
|
|
|
+#endif // defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
|
|
|
+#endif // TARGET_OS_SIMULATOR
|
|
|
+#elif TARGET_OS_OSX
|
|
|
+ appleEnvironment = kAppleEnvironmentMacOS;
|
|
|
+#endif // TARGET_OS_MACCATALYST
|
|
|
+
|
|
|
+ return appleEnvironment;
|
|
|
+}
|
|
|
+
|
|
|
@implementation GIDSignInPreferences
|
|
|
|
|
|
+ (NSString *)googleAuthorizationServer {
|