Posts

Showing posts from August, 2017

Authenticating with Cloud Functions for Firebase from your iOS Swift app

My "blog" seems to be a random collection of things that I want people to be able to find. So be it! Right now (August 2017) I can't find good documentation about how take an iOS app in which the user is logged into Firebase, and use those credentials to communicate with a Cloud Function for Firebase. Here's how, inspired partly by the authorized-https-endpoint  example function, and partly by a helpful post by Kato Richardson . Unfortunately this method doesn't work to access the database directly, as in Kato's post. The "authorization" header set below doesn't appear to be read for that. Nobody should copy/paste this code and use it unmodified. It handles errors poorly.     static func getJson( url: URL ,           completion callback: (( _ json: [ String : Any ]?, _ error: String ?) -> Void )?) {       Auth . auth (). currentUser !. getIDToken (completion: { (token, error) in         if let error = error {           c