收到 iOS 推送通知,但不会在设备上显示。铁路,休斯顿

标签 ios ruby-on-rails push-notification apple-push-notifications

通过使用休斯顿,我得到了推送通知信息,如附图所示。但是,设备不会显示通知消息,信息只会出现在控制台。我允许我的设备接受推送通知。问题是什么?

resource "push" do
    params do
      requires :device_token, type: String
    end
    post do
      APN = Houston::Client.development
      APN.certificate = File.read(Rails.root.join('certificates', 'apns', '150927Development.pem'))
      # An example of the token sent back when a device registers for notifications
      token = params[:device_token]

      # Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app
      notification = Houston::Notification.new(device: token)
      notification.alert = "Hello, World!"

      # Notifications can also change the badge count, have a custom sound, indicate available Newsstand content, or pass along arbitrary data.
      notification.badge = 57
      notification.sound = "sosumi.aiff"
      notification.content_available = true
      notification.custom_data = {foo: "bar"}

      Rails.logger.debug
      APN.push(notification)
    end
end

enter image description here

最佳答案

确保您的应用处于后台或已关闭,否则推送通知消息将不会在屏幕上显示。当应用程序在前台运行时,iOS 直接将推送通知消息传递给宿主应用程序,而不会在主屏幕或通知屏幕上显示。

关于收到 iOS 推送通知,但不会在设备上显示。铁路,休斯顿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32815637/

相关文章:

iphone - 当我在不同类别中有多个同名节点时,如何使用 NSXMLParser 读取 XML?

ios - UIScrollView 不完全滚动

ruby-on-rails - 使用 <% provide( :title, “Page Title” ) %> 的各种错误

google-chrome - 谷歌浏览器: DOMException: Registration failed - manifest empty or missing

ios - 如何在应用程序处于后台(ios)时让 FCM 通知工作?

ios - 在远程通知上打开正确的消息线程 - 带解析的 iOS Swift Chat 应用程序

ios - 根据数据更新 TableView 单元格的标签属性

ios - 设置 ImageView 的位置

ruby-on-rails - 奇怪的 Spree 登录问题 - 可能与 cookie、浏览器、NGINX 相关

ruby-on-rails - 将 routes.rb 文件分成多个文件以便更好地管理的好方法是什么?