class Pusher::PushNotifications::Token
Attributes
config[R]
Public Class Methods
new(config: PushNotifications)
click to toggle source
# File lib/pusher/push_notifications/token.rb, line 9 def initialize(config: PushNotifications) @config = config end
Public Instance Methods
generate(user)
click to toggle source
# File lib/pusher/push_notifications/token.rb, line 13 def generate(user) exp = Time.now.to_i + 24 * 60 * 60 # Current time + 24h iss = "https://#{instance_id}.pushnotifications.pusher.com" payload = { 'sub' => user, 'exp' => exp, 'iss' => iss } JWT.encode payload, secret_key, 'HS256' end