我可以让推送工作,除了在应用程序关闭时收到的消息。
消息确实会显示在通知中心上,但只有当用户按1点击实际的消息1时才会传递给应用程序。
有没有人知道有没有办法用Rhomobile从通知中心获取所有消息?
发布于 2011-12-23 20:10:40
对于任何感兴趣的人,
无法找到从iOS通知中心检索通知的方法,因此我执行了以下操作:
在application.rb中添加
def on_activate_app
# Had to do this for iOS not getting all the messages from Notification Center
Rho::Timer.start(100, "/app/Settings/check_for_pending_friends", "nil")
super
end然后在设置文件夹中的controller.rb中
def check_for_pending_friends
person = Person.find(:first)
url = "http://my_app.com/users/#{person.remote_id}/pending_msgs
# which looks for any msgs sent to that person with read_at = nil from server
Rho::AsyncHttp.get(
:url => url,
:headers => {'User-Agent' => Rho::RhoConfig.user_agent},
:callback => url_for(:action => :see_if_pending_messages_callback)
) if person
end
def see_if_pending_messages_callback
# Check to see if msg does not already exist in device, if not then add it
endhttps://stackoverflow.com/questions/8554831
复制相似问题