Shout Controller

The app should display the most recent shouts at the top of the list. To do this, you need to change the sort order of shouts in the default index method in app/controllers/shouts_controller.rb:

@shouts = Shout.all.sort_by(&:shout_date).reverse

Next, you need to modify the create method to send a push notification when a new shout has been created. Add this line after you have created the new shout object:

sendPush (@shout.name + ' just shouted ' + @shout.shout_message)

This implies a new method in the controller class called sendPush. This method looks like the following:

def sendPush (message)  deviceList = Device.all  deviceList.each ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.