简体   繁体   English

Apple在POC的Rails应用中推送通知

[英]Apple push notifications in rails app for POC

I have to develop Apple push notifications service for a rails app for POC purpose. 我必须为POC开发用于Rails应用程序的Apple推送通知服务。 I have gone through the documentation for APNS gem and apns_on_rails gem. 我已经阅读了有关APNS gem和apns_on_rails gem的文档。 Now I am confused that which gem to use. 现在,我对使用哪个宝石感到困惑。 I haven't worked with push notifications in rails and therefore don't want to spoil the application structure. 我没有在Rails中处理过推送通知,因此不想破坏应用程序的结构。 This is the first time that I have to try. 这是我第一次尝试。 So please guide on which gem should be easier to use and implement for as a first timer. 因此,请先指导哪个宝石应该更容易使用和实现。 Another thing, is it the same for iPhone and iPad ? 另一件事,iPhone和iPad是否相同?

Any help and guidance from your side is acceptable. 您身边的任何帮助和指导都是可以接受的。

Thanks in advance. 提前致谢。

I have experienced with APNS gem, you can check the sample code below: 我有使用APNS gem的经验,可以查看以下示例代码:

def self.ios_client_push(message, device_token, other = nil)
  return if device_token.blank?
  APNS.pem  = Rails.root.join('vendor/plugins/pem/YOUR-PEM.pem').to_s
  APNS.pass = 'YOUR_PASSPHARSE'
  APNS.send_notification(device_token, :alert => message, :sound => 'default', :other => other)
end 

I think it's an easy way to push notification and there is no difference between iPhone and iPad. 我认为这是推送通知的简便方法,iPhone和iPad之间没有区别。 In the sample code, I reseted the PEM configuration each time I call it because I used 2 PEM files for pushing notification. 在示例代码中,我每次调用时都会重置PEM配置,因为我使用了2个PEM文件来推送通知。 You can set it in RAILS application configuration for the first application launching. 您可以在首次启动应用程序时在RAILS应用程序配置中对其进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM