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

Add demo app google client id #187

Merged
merged 3 commits into from
Oct 12, 2023
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
16 changes: 12 additions & 4 deletions DemoApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,25 @@
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh</string>
<string>$(GOOGLE_CLIENT_ID)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh</string>
<string>$(GOOGLE_CLIENT_ID)</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(REVERSED_GOOGLE_CLIENT_ID)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(REVERSED_GOOGLE_CLIENT_ID)</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>GIDClientID</key>
<string>com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>NSAppTransportSecurity</key>
Expand Down
4 changes: 2 additions & 2 deletions DemoApp/Resources/GoogleSignIn.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>347024607410-48j4atipav0tcr4pesap4elr1u9t11uh.apps.googleusercontent.com</string>
<string>$(GOOGLE_CLIENT_ID)</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.347024607410-48j4atipav0tcr4pesap4elr1u9t11uh</string>
<string>$(REVERSED_GOOGLE_CLIENT_ID)</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
Expand Down
6 changes: 2 additions & 4 deletions DemoApp/Sources/Components/AppEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ extension AppEnvironment {
return .production
}
}()

static var googleClientId: String = {
return "347024607410-48j4atipav0tcr4pesap4elr1u9t11uh.apps.googleusercontent.com"
}()
}

extension AppEnvironment {
Expand Down Expand Up @@ -115,6 +111,8 @@ extension AppEnvironment {

enum Variable: String {
case JWTExpiration = "JWT_EXPIRATION"
case googleClientId = "GOOGLE_CLIENT_ID"
case googleReversedClientId = "REVERSED_GOOGLE_CLIENT_ID"
}

static func contains(_ argument: Argument) -> Bool {
Expand Down
2 changes: 0 additions & 2 deletions DemoApp/Sources/DemoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ struct DemoApp: App {

@StateObject var appState: AppState
private let router: Router

lazy var signInConfig = GIDConfiguration(clientID: AppEnvironment.googleClientId)

// MARK: - Lifecycle

Expand Down
7 changes: 5 additions & 2 deletions DemoApp/Sources/Views/Login/GoogleHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ enum GoogleHelper {
private static let directoryScope = "https://www.googleapis.com/auth/directory.readonly"

static func signIn() async throws -> UserCredentials {
guard let rootViewController = UIApplication.shared.windows.first?.rootViewController else {
guard
let rootViewController = UIApplication.shared.windows.first?.rootViewController,
let clientId = AppEnvironment.value(for: .googleClientId)
else {
throw ClientError.Unexpected("No view controller available")
}

let config = GIDConfiguration(clientID: AppEnvironment.googleClientId)
let config = GIDConfiguration(clientID: clientId)
return try await withCheckedThrowingContinuation { continuation in
GIDSignIn.sharedInstance.signIn(with: config, presenting: rootViewController) { user, error in
guard let userProfile = user?.profile else {
Expand Down
21 changes: 13 additions & 8 deletions DemoApp/Sources/Views/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ struct LoginView: View {
Image(systemName: "person.crop.circle.badge.clock.fill")
}

LoginItemView {
Task {
let credentials = try await GoogleHelper.signIn()
completion(credentials)
if
AppEnvironment.value(for: .googleClientId)?.isEmpty == false,
AppEnvironment.value(for: .googleReversedClientId)?.isEmpty == false
{
LoginItemView {
Task {
let credentials = try await GoogleHelper.signIn()
completion(credentials)
}
} title: {
Text("Login with Stream account")
} icon: {
Image(systemName: "person.crop.circle.badge.clock.fill")
}
} title: {
Text("Login with Stream account")
} icon: {
Image(systemName: "person.crop.circle.badge.clock.fill")
}

LoginItemView {
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'badge'
gem 'cocoapods'
gem 'danger'
gem 'danger-commit_lint'
Expand Down
9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ GEM
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
badge (0.13.0)
fastimage (>= 1.6)
fastlane (>= 2.0)
mini_magick (>= 4.9.4, < 5.0.0)
claide (1.1.0)
claide-plugins (0.9.2)
cork
Expand Down Expand Up @@ -189,7 +193,7 @@ GEM
bundler
fastlane
pry
fastlane-plugin-stream_actions (0.3.20)
fastlane-plugin-stream_actions (0.3.22)
xctest_list (= 1.2.1)
fastlane-plugin-versioning (0.5.2)
ffi (1.16.2)
Expand Down Expand Up @@ -400,13 +404,14 @@ PLATFORMS
ruby

DEPENDENCIES
badge
cocoapods
danger
danger-commit_lint
fastlane
fastlane-plugin-emerge
fastlane-plugin-lizard
fastlane-plugin-stream_actions (= 0.3.20)
fastlane-plugin-stream_actions (= 0.3.22)
fastlane-plugin-versioning
jazzy
json
Expand Down
59 changes: 1 addition & 58 deletions StreamVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3247,7 +3247,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 842D8BD12865B31D00801910 /* Build configuration list for PBXNativeTarget "DemoApp" */;
buildPhases = (
82DE10C72A827B010057BDA8 /* ShellScript */,
842D8BBF2865B31B00801910 /* Sources */,
842D8BC02865B31B00801910 /* Frameworks */,
842D8BC12865B31B00801910 /* Resources */,
Expand Down Expand Up @@ -3299,7 +3298,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 8493225D2908378B0013C029 /* Build configuration list for PBXNativeTarget "DemoAppUIKit" */;
buildPhases = (
82010CAD2A851C06005C125D /* ShellScript */,
84932248290837890013C029 /* Sources */,
84932249290837890013C029 /* Frameworks */,
8493224A290837890013C029 /* Resources */,
Expand Down Expand Up @@ -3347,7 +3345,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 84F737FF287C13AD00A363F4 /* Build configuration list for PBXNativeTarget "StreamVideoTests" */;
buildPhases = (
827297E42A4585EA00774306 /* ShellScript */,
84F737F0287C13AD00A363F4 /* Sources */,
84F737F1287C13AD00A363F4 /* Frameworks */,
84F737F2287C13AD00A363F4 /* Resources */,
Expand Down Expand Up @@ -3664,61 +3661,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
82010CAD2A851C06005C125D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"$CONFIGURATION\" == \"Test\" ]; then\n touch \"$SRCROOT/TestTools/Credentials.xcconfig\"\nfi\n";
};
827297E42A4585EA00774306 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"$CONFIGURATION\" == \"Test\" ]; then\n touch \"$SRCROOT/TestTools/Credentials.xcconfig\"\nfi\n";
showEnvVarsInLog = 0;
};
82DE10C72A827B010057BDA8 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"$CONFIGURATION\" == \"Test\" ]; then\n touch \"$SRCROOT/TestTools/Credentials.xcconfig\"\nfi\n";
};
8434C53A289BBDF30001490A /* SwiftGen */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -5208,6 +5150,7 @@
};
842D8BD22865B31D00801910 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 8206D84F2A5DB9300099F5EC /* Credentials.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
Expand Down
39 changes: 39 additions & 0 deletions StreamVideo.xcodeproj/xcshareddata/xcschemes/DemoApp.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "touch &quot;$SRCROOT/TestTools/Credentials.xcconfig&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "842D8BC22865B31B00801910"
BuildableName = "StreamVideoCallApp.app"
BlueprintName = "DemoApp"
ReferencedContainer = "container:StreamVideo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down Expand Up @@ -57,6 +75,15 @@
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "touch &quot;$SRCROOT/TestTools/Credentials.xcconfig&quot;&#10;">
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand All @@ -67,6 +94,18 @@
ReferencedContainer = "container:StreamVideo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "GOOGLE_CLIENT_ID"
value = "$(GOOGLE_CLIENT_ID)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "REVERSED_GOOGLE_CLIENT_ID"
value = "$(REVERSED_GOOGLE_CLIENT_ID)"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.3">
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "touch &quot;$SRCROOT/TestTools/Credentials.xcconfig&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8493224B290837890013C029"
BuildableName = "DemoAppUIKit.app"
BlueprintName = "DemoAppUIKit"
ReferencedContainer = "container:StreamVideo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
18 changes: 18 additions & 0 deletions StreamVideo.xcodeproj/xcshareddata/xcschemes/StreamVideo.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "touch &quot;$SRCROOT/TestTools/Credentials.xcconfig&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84F737EC287C13AC00A363F4"
BuildableName = "StreamVideo.framework"
BlueprintName = "StreamVideo"
ReferencedContainer = "container:StreamVideo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
Loading
Loading