Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google sign in ambiguous reference to member 'subscript'

application:openURL:options: method of app delegate. The method should call the handleURL method of the GIDSignIn instance, which will properly handle the URL that your application receives at the end of the authentication process.

Directly copied from firebase guide docs but still has errors.

func application(application: UIApplication, openURL url: NSURL, options: [String: AnyObject]) -> Bool {
    return GIDSignIn.sharedInstance().handleURL(url as URL!, sourceApplication: 
        options[UIApplicationOpenURLOptionsSourceApplicationKey]  //Error is here
        //Ambiguous reference to member 'subscript' error is shown.

        as? String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}
like image 961
Manish Ojha Avatar asked Sep 29 '16 03:09

Manish Ojha


1 Answers

You have a few issues. The delegate method should have the following signature in Swift 3:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool

and the whole method would be:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
like image 158
rmaddy Avatar answered Nov 11 '22 00:11

rmaddy