Sha256: 905211a1e2093b687a40439af2615cf96f03487aca879e22e518b52448968d7b

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

# see https://www.firebase.com/docs/ios/guide/login/facebook.html for more info
# (that's where this code came from)
class Firebase
  def self.open_facebook_session(options={}, &block)
    self.new.open_facebook_session(options={}, &block)
  end

  def open_facebook_session(options={}, &block)
    ref = self
    permissions = options[:permissions] || ['email']
    fb_login = FBSDKLoginManager.alloc.init
    fb_login.logInWithReadPermissions(permissions, 
      handler: -> (facebookResult, facebookError) do
        if facebookError
          block.call(facebookError, nil)
        elsif facebookResult.isCancelled
          block.call("Facebook login got cancelled.", nil)
        else
          access_token = FBSDKAccessToken.currentAccessToken.tokenString

          ref.authWithOAuthProvider('facebook', token: access_token, withCompletionBlock:block)
        end
      end)
    nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
motion-firebase-4.0.0 lib/firebase/firebase_facebook_helper.rb
motion-firebase-3.2.1 lib/firebase/firebase_facebook_helper.rb
motion-firebase-3.3.0 lib/firebase/firebase_facebook_helper.rb
motion-firebase-3.2.0 lib/firebase/firebase_facebook_helper.rb
motion-firebase-3.1.8 lib/firebase/firebase_facebook_helper.rb