Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Ruby On Rails发送IOS推送通知_Ios_Ruby On Rails_Ruby_Push Notification_Apple Push Notifications - Fatal编程技术网

从Ruby On Rails发送IOS推送通知

从Ruby On Rails发送IOS推送通知,ios,ruby-on-rails,ruby,push-notification,apple-push-notifications,Ios,Ruby On Rails,Ruby,Push Notification,Apple Push Notifications,我需要向IOS mobile发送推送通知 我使用apn_on_rails发送此通知 我从IOS开发者那里得到我的pem文件。 我对它进行了以下配置 在config/configtran/*.rb中进行生产和开发 RAILS_ROOT, APN::App::RAILS_ENV='production' configatron.apn.passphrase = 'leo_123' configatron.apn.port = 2195 configatron.apn.host = 'gatew

我需要向IOS mobile发送推送通知

我使用apn_on_rails发送此通知

我从IOS开发者那里得到我的pem文件。 我对它进行了以下配置

在config/configtran/*.rb中进行生产和开发

RAILS_ROOT, APN::App::RAILS_ENV='production'
configatron.apn.passphrase  = 'leo_123'
configatron.apn.port  = 2195
configatron.apn.host  = 'gateway.sandbox.push.apple.com'
configatron.apn.cert = File.join(Rails.root, 'config', ' apple_push_notification_development.pem')
然后我按照文档创建了一个通知

在我运行了下面的命令之后,它运行得非常理想并且响应良好

从控制台

APN::App.send_通知

使用耙子 RAILS_ENV=生产rake apn:notifications:deliver

我在生产和开发环境中都试过了。 在下一行之后,它没有响应。我也没有在日志中找到任何东西

APN::App Load (0.1ms)  SELECT "apn_apps".* FROM "apn_apps"
我没有在任何云服务器上托管过此应用程序。此应用程序是否应托管在任何云服务器上才能正常运行

感谢您的帮助。

使用gem更容易


您应该创建通知:我已经在
apn\u on\u rails
中创建了通知,您需要运行迁移。它使用db表。如果您不需要任何表,可以使用grocer gem。我为apn_on_rails的生产运行了迁移。让我检查一下杂货商gem也发给我们。让你再次发送通知。我请发送通知,请分叉我的代码并合并你的代码,我的消息无法发送。两天以来我一直在工作,我需要你的帮助,请共享代码。它返回了数字,但我在设备中没有收到任何通知。你能从你方发一份通知吗
pusher = Grocer.pusher(certificate: "#{Rails.root}/lib/dev_cert.pem", # required
                       passphrase:  "XXXXXX",                         # optional
                       gateway:     "gateway.sandbox.push.apple.com", # optional
                       port:        2195,                             #optional
                       retries:     3)

feedback = Grocer.feedback( certificate: "#{Rails.root}/lib/dev_cert.pem", 
                                  passphrase:  "XXXXXX",                        
                                  gateway:     "feedback.sandbox.push.apple.com", 
                                  port:        2196,                     
                                  retries:     3)

 notification = Grocer::Notification.new(
    device_token:      push_id,
    alert:             message,
    badge:             3,
    sound:             "siren.aiff",         # optional
    expiry:            Time.now + 60*60,     # optional; 0 is default, meaning the message is not stored
    # identifier:        1234,                 # optional
    content_available: true                  # optional; any truthy value will set 'content-available' to 1
  )

  feedback.each do |attempt|
    puts "Device #{attempt.device_token} failed at #{attempt.timestamp}"
  end

  pusher.push(notification)