Git Product home page Git Product logo

firebase-simple-login-objc's Introduction

Status: Archived

This repository has been archived and is no longer maintained.

status: inactive

Firebase Simple Login - iOS Client

Firebase Simple Login is a simple, easy-to-use authentication service built on top of Firebase Custom Login, allowing you to authenticate users without any server code.

Enable authentication via a number of third-party providers, anonymous login, or email / password authentication without having to manually store authentication credentials or run a server.

Deprecation Warning!

Firebase Simple Login for iOS is now a part of the core Firebase iOS library. As a result, this standalone Simple Login client is being deprecated. We encourage everyone to upgrade to the latest version of the Firebase iOS Client to get the latest and greatest features. If you are still using this deprecated Simple Login client, you can find documentation for it here.

You can read more about this change on our blog and see the updated login documentation on our website. The updated documentation includes migration plans, but if you have any other questions, please reach out to us.

Installation

To get started with the iOS SDK, see the Firebase iOS Quickstart Guide.

To install in your application, download from the Firebase CDN.

Using Simple Login with Swift

In order to use Simple Login in a Swift project, you'll also need to setup a bridging header in addition to adding required frameworks to your project. To do that, follow these instructions, and then add the following line to your bridging header:

#import <FirebaseSimpleLogin/FirebaseSimpleLogin.h>

Configuration

The Firebase Simple Login iOS Client supports email & password, Facebook, Google, Twitter, and anonymous authentication methods. Before adding to your application, you'll need to first enable these auth. providers in your app.

To get started, visit the Simple Login tab in Firebase Forge, at https://<YOUR-FIREBASE>.firebaseio.com. There you may enable / disable auth. providers, setup OAuth credentials, and configure valid OAuth request origins.

Usage

Start monitoring user authentication state in your application by instantiating the Firebase Simple Login client with a Firebase reference, and callback.

Objective-C
Firebase* ref = [[Firebase alloc] initWithUrl:@"https://SampleChat.firebaseIO-demo.com"];
FirebaseSimpleLogin* authClient = [[FirebaseSimpleLogin alloc] initWithRef:ref];
Swift
let ref = Firebase(url:"https://SampleChat.firebaseIO-demo.com")
var authClient = FirebaseSimpleLogin(ref:ref)

Once you have instantiated the client library, check the user's authentication status:

Objective-C
[authClient checkAuthStatusWithBlock:^(NSError* error, FAUser* user) {
    if (error != nil) {
      // Oh no! There was an error performing the check
    } else if (user == nil) {
      // No user is logged in
    } else {
      // There is a logged in user
    }
}];
Swift
authRef.checkAuthStatusWithBlock({ error, user in
    if (error != nil) {
        // Oh no! There was an error performing the check
    } else if (user == nil) {
        // No user is logged in
    } else {
        // There is a logged in user
    }
})

In addition, you can monitor the user's authentication state with respect to your Firebase by observing events at a special location: .info/authenticated

Objective-C
Firebase* authRef = [ref.root childByAppendingPath:@".info/authenticated"];
[authRef observeEventType:FEventTypeValue withBlock:^(FDataSnapshot* snapshot) {
    BOOL isAuthenticated = [snapshot.value boolValue];
}];
Swift
var authRef = ref.root.childByAppendingPath(".info/authenticated")
authRef.observeEventType(.Value, withBlock: { snapshot in
    var isAuthenticated = snapshot.value as? Bool
})

If the user is logged out, try authenticating using the provider of your choice:

Objective-C
[authClient loginWithEmail:@"[email protected]" andPassword:@"very secret"
    withCompletionBlock:^(NSError* error, FAUser* user) {

    if (error != nil) {
        // There was an error logging in to this account
    } else {
        // We are now logged in
    }
}];
Swift
authRef.loginWithEmail("[email protected]", andPassword: "very secret") { (error, user) in
    if (error != nil) {
        // There was an error logging in to this account
    } else {
        // We are now logged in
    }
}

Testing / Compiling From Source

Interested in manually debugging from source, or submitting a pull request? Don't forget to read the Contribution Guidelines .

To deploy:

$ ./build.sh
$ cp FirebaseSimpleLogin.framework-$SEMVER.zip ../firebase-clients/ios/.
$ cp CHANGELOG.md ../firebase-clients/ios/.
$ pushd ../firebase-clients/ios/
$ cp FirebaseSimpleLogin.framework-$SEMVER.zip FirebaseSimpleLogin.framework-LATEST.zip
$ ...

License

The MIT License

Copyright © 2014 Firebase [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

firebase-simple-login-objc's People

Contributors

robertdimarco avatar katfang avatar samtstern avatar vikrum avatar brettthepark avatar dstaley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.