There is no registered handler for URL scheme com-google-gidconsent error when singning in using GIDSignIn
There's no problem with your implementation. All those warnings mean is the apps which each URL scheme refer to are not installed on the device.
If you're testing on the simulator, you'll get those errors all the time. But, if you test on a device, you can verify the errors will be gone if you have the corresponding apps installed.
For example, if you have the Youtube app on your device, you won't see the line:
2015-09-07 15:44:14.071 Contacts++[82438:4826277] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent-youtube
iOS Google Sign In error
handleURL is looking for arguments of type "String" for sourceApplication and annotation, but options is providing "AnyObject." Casting those dictionary values to "String" oughtta do it.
Try this:
Update: Swift 3
func application(_ application: UIApplication,
open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool
return GIDSignIn.sharedInstance().handle(url,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation] as? String)
}
Swift 2
func application(application: UIApplication,
openURL url: NSURL, options: [String: AnyObject]) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url,
sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String,
annotation: options[UIApplicationOpenURLOptionsAnnotationKey] as? String)
}
This took me forever, too. Hope that helps!
I'm confusing with the Google sign in instruction. [GIDSignIn sharedInstance].clientID = kClientID Where I type that?
It recommends putting that line of code in application:didFinishLaunchingWithOptions: inside your AppDelegate.
Replace kClientID with the ClientID that is found in the GoogleService-Info.plist file.
Make sure you import the needed Google Files as well.
Google auth handler on swift
Do not know is it correct, but I did:
class MyTableViewController: UITableViewController, GIDSignInUIDelegate, GIDSignInDelegate {...
override func viewDidLoad() {
GIDSignIn.sharedInstance().delegate = self
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
funcIneed()
}
}
And it helps me.
What is the correct iOS code for Google Sign-in
Bellow code for Pod file
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.2'
use_frameworks!
target ’App Target’ do
pod 'GoogleSignIn'
end
Then into AppDelegate.swift file add Header import GoogleSignIn
Then
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { GIDSignIn.sharedInstance().clientID = "googlesigninclient id";
}
func application(_ app: UIApplication, open url: URL, options:
[UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return GIDSignIn.sharedInstance().handle(url,
sourceApplication:
options[UIApplicationOpenURLOptionsKey.sourceApplication] as?
String,
annotation:
options[UIApplicationOpenURLOptionsKey.annotation])
}
Now in ViewController class
class LoginViewController:UIViewController
,GIDSignInUIDelegate, GIDSignInDelegate {
//Add Button action for gmail login
@IBAction func loginWithGmail(_ sender: Any) {
GIDSignIn.sharedInstance().signIn()
}
//deleage method will call after gmail login
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if (error == nil) {//login success
} else {
//login fail
}
}
}
Use of unresolved identifier 'GGLContext'
Google/*
pods are deprecated, you should use pod GoogleAnalytics
or pod GoogleSignIn
instead. You can't find GGLContext
in those pods because it no longer exists since it no longer requires a GoogleInfo-Service.plist
file for Analytics or SignIn.
For SignIn you should use the clientID that was previously obtained in the GoogleInfo-Service.plist file to initialize
GIDSignIn.sharedInstance().clientID = kClientID
or if you are using Firebase
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
For Analytics you should use the trackerID that was previously obtained in the GoogleInfo-Service.plist file or in the analytics panel to initialize
let tracker = GAI.sharedInstance().tracker(withTrackingId: kTrackerID)
Google SignIn docs
Google Analytics docs
manual installed google sign-in iso sdk terminates app in setting clientID
Turns out the Other Linker Flags were not completely set. I had 2 of 3 sub-settings to -ObjC and the Other Linker Flags reads . Once set them all to -ObjC, things are fixed. Put a screenshot here in case someone else run into this.
Open AppStore if app is not installed on iOS
Check the return value of openURL:
. If it returns NO
, then create a SKStoreProductViewController
setup for the desired app.
if (![ourApplication openURL:ourURL]) {
// can't launch app for 'fb' scheme
// Create and display SKStoreProductViewController
}
If you don't want to use SKStoreProductViewController
then use the openURL
code you have at the end of your question instead.
Related Topics
Check the Position of the Xcuielement on Screen While Testing iOS Application Using Xctest
Should I Use Realm Objective-C or Realm Swift in My Mixed Objective-C/Swift Project
-Webkit-Overflow-Scrolling: Touch' Broken for Initially Offscreen Elements in iOS7
Random Glitchy Rendering of Svg on iOS/Wkwebview
Responseserializer 'Cannot Call Value of Non-Function Type 'Nshttpurlresponse'' with Swift 3
How to Get Nsnumberformatter Currency Style from Isocurrencycodes
How to Programmatically Wrap Png Texture Around Cube in Scenekit
Uitextview - Can't Set Underline or Strikethrough Attributes on Text
iOS 8 Code Working on iPhone 5S But Not iPhone 5
Proper Sequence to Get Registration Token for Gcm Push Notification on iOS? Is Gcm Unreliable
How to Animate Uilabel's Textcolor Change
iOS 11 CPU Throttling and Idle Timer
Uitableview Has Unwanted Animation When Reloaddata Is Called
Media Query Not Working for iPhone and Ipad
Remove Duplicate Structs in Array Based on Struct Property in Swift
Disable iOS Reachability Swipe Gesture in iOS Game
Scenekit Flattenedclone - Incorrect Use of Objc_Storeweak() and Objc_Loadweak() Error