首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ios 5推送通知和rhomobile

ios 5推送通知和rhomobile
EN

Stack Overflow用户
提问于 2011-12-19 05:09:40
回答 1查看 372关注 0票数 0

我可以让推送工作,除了在应用程序关闭时收到的消息。

消息确实会显示在通知中心上,但只有当用户按1点击实际的消息1时才会传递给应用程序。

有没有人知道有没有办法用Rhomobile从通知中心获取所有消息?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-23 20:10:40

对于任何感兴趣的人,

无法找到从iOS通知中心检索通知的方法,因此我执行了以下操作:

在application.rb中添加

代码语言:javascript
复制
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中

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8554831

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档