Object Model - Readmill/ios-wrapper GitHub Wiki
If you’d like to completely control your users’ experience with Readmill in your application, the object model classes ReadmillUser, ReadmillBook, ReadmillReading and ReadmillReadingSession are for you:
-
ReadmillUserrepresents a Readmill user’s account, and will be the base class for integrating with Readmill from in your application. -
ReadmillBookrepresents a book in the Readmill system. -
ReadmillReadingrepresents a user’s interaction with a book, from marking it as interesting all the way through reading and completing it. -
ReadmillReadingSessionrepresents a user sitting down and reading a book for a period of time. Your application should periodically call the-pingWithProgress:pingDuration:delegate:method on this class while the user is reading.
This part of the SDK is designed to follow your application’s flow as a user opens your app, picks a book and starts reading. Here’s how you’d integrate with Readmill at each stage:
- If the user has logged into Readmill through your application before, create a
ReadmillUserobject from saved credentials. - If the user hasn’t logged into Readmill through your application before, allow the user to log in through the Readmill website and create a
ReadmillUserobject from the returned authorisation information. Store the user's saved credentials (an example on how to do this is available in the app).
- Find or create the book in the Readmill service using the ReadmillUser method
-findOrCreateBookWithISBN:title:author:. - Optionally ask the user if they’d like to track their reading in Readmill and if they’d like to make their reading of this book public or private (setting this in the Settings section of your app and not asking the user each time is OK, too).
- Create a ReadmillReading object for the ReadmillBook by using the
-createReadingForBook:state:isPrivate:delegate:method of the ReadmillUser class. This method will return an existing “reading” in the user’s account for the given book if it already exists, or create a new one if it does not. - Set the state of the
ReadmillReadingobject to ReadingStateReading using the-updateState:delegate:method to tell Readmill that the user is reading the book.
- Create a
ReadmillReadingSessionobject using the-createReadingSessionmethod of theReadmillReadingobject. This is used to track this specific reading session. - Periodically call the
-pingWithProgress:pingDuration:delegate:method on yourReadmillReadingSessionobject while the user is reading. The progress is percentage represented by an integer (0-100), and pingDuration is an integer representing the duration with which you are pinging (300 seconds is the recommended interval). This informs Readmill in real-time that the user is reading the book and the progress they are making.
- There’s nothing further to do. When you stop calling
-pingWithProgress:, Readmill will automatically do the right thing and understand that the user isn’t reading any more.
- Set the state of your
ReadmillReadingobject toReadStateFinished, using-updateState:delegate:method in yourReadmillReadingobject to tell Readmill that the user has finished their book. - Optional, but recommended: Ask the user to provide a “closing remark” for the book — a mini-review, if you will, and tell Readmill using the
-updateClosingRemark:delegate:method ofReadmillReading. This really helps enhance the social aspect of Readmill.
The sample iPad application provided with the SDK uses the model objects of the SDK in places, including saving login credentials and authenticating with the Readmill website. To get started, check it out — the Xcode project provides everything you need to integrate with Readmill, and all the class headers in the Readmill SDK are documented if you need more help.