简体   繁体   English

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

[英]iOS push notification is received but will not be shown on a device. Rails, Houston

By using Houston, I've got push notification information, as attached picture. 通过使用休斯顿,我获得了推送通知信息,如下图。 However, the device will not show notification message, the info only appear console. 但是,设备不会显示通知消息,该信息仅显示在控制台中。 I allow my device to accept push notification. 我允许我的设备接受推送通知。 What is the problem? 问题是什么?

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

在此处输入图片说明

Make sure, your app is in background, or closed , otherwise Push Notification Messages won't be visible on Screen. 确保您的应用处于后台或关闭状态 ,否则“推送通知消息”将不会在屏幕上显示。 When app is running in foreground, iOS directly passes push Notification message to host app, without showing it on Home screen or Notification Screen. 当应用程序在前台运行时,iOS直接将推送通知消息传递给主机应用程序,而不在主屏幕或通知屏幕上显示它。

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

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