Device Controller

You have to make a few small modifications to the default controller for devices to make sure that it will work for our purposes. In app/controllers/devices_controller.rb, you need to update the create method. First, you need to reformat the token data sent to us from the device, because it will contain chevron brackets ("<" and ">"). This approach will just remove the brackets from the data.

deviceInfo = params[:device]deviceInfo[:token] = deviceInfo[:token].sub("<","")deviceInfo[:token] = deviceInfo[:token].sub(">","")

Next, the create method built by Rails assumes that you will create a new record only when a POST is received. The logic needs to be able to handle new devices, and updates to ...

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.