Sending Notification to App using Rpush Gem Ruby on Rails

扶醉桌前 提交于 2019-12-12 02:04:46

问题


Im trying to implement Push notification in my app using Rpush Gem. This is so far i have tried.

    if @push_notification.present?
    else
      app = Rpush::Apns::App.new
      app.name = "ios_app"
      app.certificate = File.read("config/apns-dev.pem")
      app.environment = "development" # APNs environment.
      app.password = ""
      app.connections = 1
      app.save! 
    end

    n = Rpush::Apns::Notification.new
    n.app = Rpush::Apns::App.find_by_name("ios_app")
    n.device_token = session[:push_notification_token]
    n.alert = "hi im alert!"
    n.data = { foo: :bar }
    n.save!

this save a notification to the database. I want to know how to send this notification.


回答1:


using rpush this should be working to send your push message actually. there is the possibility that your certificates are not set up right, or that the push token is incorrect, or that perhaps you have not started rpush. Do you call Rpush.embed somewhere in your stack? I have placed this in config.ru



来源:https://stackoverflow.com/questions/24161522/sending-notification-to-app-using-rpush-gem-ruby-on-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!