Skip to content

Commit

Permalink
goggle sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
paigekeller committed May 13, 2021
1 parent b47348a commit 8ada371
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 11 deletions.
38 changes: 36 additions & 2 deletions IncidentTableView/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,53 @@
import UIKit
import CoreData
import Firebase
import GoogleSignIn

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {



func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if let error = error {
if (error as NSError).code == GIDSignInErrorCode.hasNoAuthInKeychain.rawValue {
print("The user has not signed in before or they have since signed out.")
} else {
print("\(error.localizedDescription)")
}
return
}
// Perform any operations on signed in user here.
let userId = user.userID // For client-side use only!
let idToken = user.authentication.idToken // Safe to send to the server
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
// ...
}

func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!,
withError error: Error!) {
// Perform any operations when the user disconnects from app here.
// ...
}


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

FirebaseApp.configure()

GIDSignIn.sharedInstance().clientID = "panicapp.login"
GIDSignIn.sharedInstance().delegate = self

return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
return GIDSignIn.sharedInstance().handle(url)
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
Expand Down
24 changes: 19 additions & 5 deletions IncidentTableView/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,32 @@
</objects>
<point key="canvasLocation" x="1845" y="938"/>
</scene>
<!--View Controller-->
<scene sceneID="VW1-Tl-Wbb">
<objects>
<viewController id="IKN-Ty-wGJ" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="hTA-Gt-EWl">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="zH7-TZ-zXS"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rPm-hG-uOk" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-666" y="78"/>
</scene>
<!--Login-->
<scene sceneID="toq-gp-Dwf">
<objects>
<viewController id="u3h-Gj-bgh" customClass="LoginViewController" customModule="IncidentTableView" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" userInteractionEnabled="NO" contentMode="scaleToFill" id="URT-a3-o0j">
<view key="view" userInteractionEnabled="NO" contentMode="scaleToFill" id="URT-a3-o0j" customClass="GIDSignInButton">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LIa-Dc-vBX">
<rect key="frame" x="130" y="350.66666666666669" width="154" height="35"/>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LIa-Dc-vBX">
<rect key="frame" x="133" y="351" width="148" height="34"/>
<color key="backgroundColor" red="0.41850540510000001" green="0.50857814570000004" blue="1" alpha="0.64308647259999996" colorSpace="custom" customColorSpace="displayP3"/>
<fontDescription key="fontDescription" name="GillSans" family="Gill Sans" pointSize="20"/>
<state key="normal" title="Login With Google">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
Expand Down Expand Up @@ -778,7 +792,7 @@
</designables>
<inferredMetricsTieBreakers>
<segue reference="eao-D6-2IS"/>
<segue reference="2Hi-lu-GmA"/>
<segue reference="OQ7-gx-zyA"/>
<segue reference="Pfu-Rg-ckc"/>
<segue reference="ed9-N9-3Wt"/>
</inferredMetricsTieBreakers>
Expand Down
21 changes: 21 additions & 0 deletions IncidentTableView/GIDSignIn.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// signInBtn.swift
// IncidentTableView
//
// Created by Tiger Coder on 5/11/21.
//

import UIKit
import GoogleSignIn

class GIDSignIn: GIDSignInButton {

/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/

}
15 changes: 13 additions & 2 deletions IncidentTableView/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -18,8 +16,21 @@
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>17709293166-vh9up4hqumkahtpp8h98f6o7v2fiaiuq.apps.googleusercontent.com</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
Expand Down
7 changes: 5 additions & 2 deletions IncidentTableView/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
//

import UIKit
import GoogleSignIn
import Firebase

class LoginViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.

GIDSignIn.sharedInstance().presentingViewController = self

}

//comment
Expand Down

0 comments on commit 8ada371

Please sign in to comment.