Vinícius Albino
Vinícius Albino

Reputation: 547

Open Epub directly inside app Swift

Im trying to open an ePub file directly inside my iOS app.

The problem is that i need the user, to save some notes.

So far i've been using the :

https://github.com/FolioReader/FolioReaderKit

Library.

Is there a way i can open iBooks inside the app?

open with UIDocumentationController unfortunately is no an option right now.

Is there any other lib that i can do that?

Thanks

Upvotes: 1

Views: 6847

Answers (3)

CloudBalancing
CloudBalancing

Reputation: 1676

First, there is a deprecated library, FolioReaderKit that does a very lovely work presenting different *.epub files. However, it is not maintained and is using UIWebView which will prevent from applications using it to upload to the AppStore.

[UPDATE] There are several forks 1, 2 of the above repository which have migrated to WebKit. I have not tested them nor, not how they work.

Second, the only actual out-of-the-box iOS SDK I found that gives you a full UI solution are skyepub and Adobe which are partially asking for payment.

But looking around the cod, examples, and tutorials I learned a lot...

After evading a lot I come up to the following conclusions:

  1. EPUB is basically a zip file that incorporates within a website, usually including some index.html file with some pictures, CSS, and fonts. What is an EPUB.

  2. To supply EPUB locally on iOS you will have to parse unzip it locally and serve the main file behind it (again we are talking bout the main use case of an html file). you can use different libraries such EPUBKit

  3. You might need to allow access to the local files when parsing them, this might require allowing non-tls requests...

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0">
    <dict>
    <key>NSAllowsArbitraryLoads</key> <true/> 
    <key>NSExceptionDomains</key> <dict>
    <key>localhost</key> <dict>
    <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/>  
    <key>NSExceptionMinimumTLSVersion</key> <string>TLSv1.2</string>  
    <key>NSExceptionRequiresForwardSecrecy</key> <true/>
    <key>NSIncludesSubdomains</key> <true/>
    <key>NSRequiresCertificateTransparency</key> <false/>
    <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <true/>   
    <key>NSThirdPartyExceptionMinimumTLSVersion</key <string>TLSv1.2</string>    
    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <true/>
    </dict> 
    </dict>
    </dict> 
    </plist>
    
  4. You might need to add custom css and js code (evaluate within the WKWebView you will use to load the html file into) to accommodate to the UI you desire to supply. A great example that helped me a lot is the Style.css and Bridge.js files and their usage in FolioReaderKit

Hopes it shed some light over EPUBs and iOS

Upvotes: 4

Franco Meloni
Franco Meloni

Reputation: 156

I don't know a library that can resolve your problem, but a solution could be

Upvotes: 2

Heberti Almeida
Heberti Almeida

Reputation: 1450

Today FolioReaderKit do not support Notes like iBooks, although it is on our roadmap. You can join the discussion on #16, the screens are already designed and there are discussions on implementation.

Regarding iBooks there is no way to use it inside your app.

Upvotes: 2

Related Questions