Skip to content

Kitaboo Service implementation

  • To use the Kitaboo services, "Kitaboo SDK" provides an adapter called "KitabooServiceAdapter" which uses Kitaboo services and supports the required API calls [ ie; Fetch/Save UGC request and others].
  • "ServiceHandler" is a class of "KitabooSampleReader" which extends "KitabooServiceAdapter class" and exposes the set of service apis. For more details of all listed apis,Please download the package "Service Adapter" available here. and refer the index.html.
  • Service triggering from Reader[PlayerActivity] : services can be triggered from Reader on specific event.

Example

We are triggering the "FetchUGC" request while opening the book in onReaderAttached() callback. Similarly, other Service API can be triggered based on the requirement at Reader end.

@Override
public void onReaderAttached() {
    //Add the code to initialize kitaboo SDK here
    //Create kitaboo renderer instance
    //Clear all data of history Component

    clearPageHistoryData();
    bookId = getIntent().getLongExtra(BOOK_ID, 0);
    bookVersion = getIntent().getStringExtra(BOOK_VERSION);
    userID = getIntent().getLongExtra(USER_ID, 0);
    token = getIntent().hasExtra(TOKEN) ?  getIntent().getStringExtra(TOKEN) : "";
    isbn=getIntent().getStringExtra(ISBN);
    // send the specific user id to sdk to keep track of UGC data for User
    KitabooSDKModel.getInstance().setUserID(userID);
    KitabooSDKModel.getInstance().setUserToken(token);

    accountType=getIntent().getStringExtra(ROLE_NAME);
    IsClassAccociated =getIntent().getExtras().getBoolean(IS_CLASSACCOCIATED,false);
    GlobalDataManager.getInstance().setClassAssociated(IsClassAccociated);
    mthumbnailpath = getIntent().getStringExtra(MEDIA_PATH);
    BookInfo book = new BookInfo(
            getIntent().getStringExtra(MEDIA_PATH),
            bookId,
            getIntent().getStringExtra(ISBN));
    book.setBookEncrypt(getIntent().getBooleanExtra(IS_BOOK_ENCRYPT, false));

    //call fetch ugc requst
    mServicehandler.sendFetchUGCRequest(bookId,accountType,userID,  bookVersion,this);

}