简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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