我可以推送工作,除了应用程序关闭时进来的消息。
消息确实会显示在通知中心,但只有当用户点击实际消息1时才传递给应用。
有没有人知道是否有办法从Rhomobile的Notification Center获取所有消息?
答案 0 :(得分:0)
对于任何有兴趣的人,
无法找到从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
然后在Settings文件夹中的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
end