0

I can get push working except for messages that come in while app is closed.

Messages do show up on Notification Center, but only passed to app when user clicks on the actual msg 1 by 1.

Does anyone know if there is a way to fetch all the messages from the Notification Center with Rhomobile?

pcasa
  • 3,710
  • 7
  • 39
  • 67

1 Answers1

0

For anyone interested,

Could not find a way to retrieve notifications from iOS Notifications Center so I did the following:

added in 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

Then in controller.rb inside the Settings folder

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
pcasa
  • 3,710
  • 7
  • 39
  • 67