Method: SelfSDK::Services::Facts#generate_deep_link

Defined in:
lib/services/facts.rb

Generates a deep link to authenticate with self app.

Parameters:

  • facts (Array)

    a list of facts to be requested.

  • callback (String)

    the url you’ll be redirected if the app is not installed.

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :selfid (String)

    the user selfid you want to authenticate.

  • :cid (String)

    The unique identifier of the authentication request.

Returns:

  • (String, String)

    conversation id or encoded body.


110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/services/facts.rb', line 110

def generate_deep_link(facts, callback, opts = {})
  opts[:request] = false
  selfid = opts.fetch(:selfid, "-")
  body = @client.jwt.encode(request(selfid, facts, opts))

  if @client.env.empty?
    return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
  elsif @client.env == 'development'
    return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
  end
  "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
end