Noti - 桌面通知未发送

时间:2016-06-30 06:36:56

标签: ruby-on-rails ruby notifications

在rails 4项目中,我尝试通过引用此http://api.notiapp.com/tutorials/rails来实现桌面通知功能。如果我点击一个链接(setup_noti_path),按照这些程序,它将进入登录页面(例如:https://notiapp.com/auth/fa574800-dbbb-1a5b-9c05-dfff043c405e)。从此站点登录后,它会显示我的项目页面,其中包含Flash消息(“Noti现已配置为您的帐户!”)。已安装的gem为noti (1.0.2)

控制器就像

class NotiAuthorisationsController < ApplicationController

  def new
    token = Noti::Token.create_request_token(noti_callback_url)
    session[:noti_rt] = token.request_token
    redirect_to token.redirect_url
  end

  def create
    token = Noti::Token.get_access_token(session[:noti_rt])
    current_hospital_admin.update_attribute(:noti_token, token)
    session[:noti_rt] = nil
    redirect_to root_path, :flash =>{:ok=>"Noti has now been configured for your account!"}
  end

end

路线是,

get '/noti' => 'noti_authorisations#new', :as => 'setup_noti'
get 'noti/callback' => 'noti_authorisations#create', :as => 'noti_callback'

在rails控制台中,我尝试通过以下方法发送通知,但它只返回true值。

notification = Noti::Notification.new
notification.title = "An example notification"
notification.text = "Some further information about this notification"
notification.deliver_to(user.noti_token)

在哪里可以在我的项目中添加以上方法?此通知相关代码应在rake任务中连续检查。请帮助我实现同样的目标。

0 个答案:

没有答案