Sha256: 3c12fe7c455ad1b3116e1dcd4f37cf7cea4ff9c6b2bfbf35ebfa118f261e3786

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Zuckermo
  class AccountStore

    def init
      @app_id = nil
      @account_store ||= ACAccountStore.alloc.init
      self
    end

    attr_accessor :app_id
    attr_reader :account_store

    def account_type
      self.account_store.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierFacebook)
    end

    def accounts
      self.account_store.accountsWithAccountType(account_type).collect do |ac_account|
        Zuckermo::User.new ac_account
      end
    end

    def sign_in permissions, audience, &block
      @permissions, @audience, @callback = permissions, audience, block

      @options =
        {
          ACFacebookAppIdKey       => @app_id,
          ACFacebookPermissionsKey => @permissions
        }

      self.account_store.requestAccessToAccountsWithType( self.account_type,
          options: @options,
          completion: -> granted, error do
            Dispatch::Queue.main.sync do
              @callback.call(granted, error)
            end
          end
      )
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zuckermo-0.0.1 motion/zuckermo/account_store.rb