Sending Notification to App using Rpush Gem Ruby o

2019-09-18 20:00发布

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条回答
Deceive 欺骗
2楼-- · 2019-09-18 20:34

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

查看更多
登录 后发表回答