Ruby on rails 3 如何从rails应用程序发送c2dm消息 编辑3

Ruby on rails 3 如何从rails应用程序发送c2dm消息 编辑3,ruby-on-rails-3,push-notification,android-c2dm,rhomobile,Ruby On Rails 3,Push Notification,Android C2dm,Rhomobile,我使用RhoMobile获取设备_令牌,并将其发送到服务器 def register_device @person = Person.find(:first) unless System.get_property('is_emulator') url = "#{@base}/users/#{@person.remote_id}/register_device?os=#{System.get_property('platform')}&device_token=#

我使用RhoMobile获取设备_令牌,并将其发送到服务器

def register_device
    @person = Person.find(:first)
    unless System.get_property('is_emulator')
     url = "#{@base}/users/#{@person.remote_id}/register_device?os=#{System.get_property('platform')}&device_token=#{System.get_property('device_id')}"
     Rho::AsyncHttp.get(
        :url => url,
        :headers => {'User-Agent' => Rho::RhoConfig.user_agent}
      )
    end
    finish_and_go_to_venue
  end
编辑2 拥有设备\u令牌,但继续获取
Error=NotRegistered

编辑 好的,第一个错误是使用了错误的设备ID。现在可以工作了,但手机没有提示信息

起初的 第一次从rails服务器发送android推送消息的用户

使用

我在谷歌注册并收到了白名单邮件

正在尝试下面的test.rb,但未向手机发送任何内容

require 'rubygems'
require 'bundler'
Bundler.setup(:default, :development)
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'speedy_c2dm'


TEST_EMAIL = "my_push_email@gmail.com"
TEST_PASSWORD = "MY_PASSWORD"
TEST_REGISTRATION_ID = "DEVICE_TOKEN_RECEIVED_FROM_PHONE"

speedyC2DM = SpeedyC2DM::API.new(TEST_EMAIL, TEST_PASSWORD)

options = {
  :registration_id => TEST_REGISTRATION_ID,
  :message => "Hi!",
  :extra_data => 42,
  :collapse_key => "some-collapse-key"
}


response = speedyC2DM.send_notification(options) 

尝试添加名为Push的控制器,并在控制器内添加以下内容:

require 'rho/rhocontroller'
require 'helpers/browser_helper'

class PushController < Rho::RhoController
  include BrowserHelper

  def push_callback

    Alert.show_popup @params['message'] #this will show you a popup with your push message
    puts "push_callback : #{@params}" #you'll see what you are receiving with this
    "rho_push"  #to run rhodes push command processing (for alerts, sounds, etc…)
  end


end
另外,您是否正确配置了build.yml

android:
  push:
    notification: always
    sender: your-sender-email@gmail.com
capabilities:
  - push
  - vibrate

至少在我的应用程序中,我需要让应用程序运行才能获得消息。

android代码呢?我从rhomobile功能中获得令牌。用代码更新了问题,使其正常工作。手机上的设置错误。你是如何在手机上修复它的?我还尝试将push notif发送到rhodes android应用程序。thnx,而不是刚刚添加到设置文件夹下controller.rb的另一个控制器。
android:
  push:
    notification: always
    sender: your-sender-email@gmail.com
capabilities:
  - push
  - vibrate