I am building a react-native app that utilizes the Google Books API. The API provides a property known as "ACSTokenLink" which downloads an .acsm file, not an .epub. A simple Google Search tells me that this .acsm file is for content protection and can only be opened with Adobe Digital Editions.
Google completely dropped the ball, failing to mention any of this in their API contract:
https://developers.google.com/books/docs/v1/using
Google API forums are a ghost-town, so I'm asking here in an attempt to learn more about these files and their use.
So, if I am developing a react-native e-reader, am I completely barred from using such a file?
Looking at the accessInfo slice sample from Google Books API :
The accessInfo section is of particular interest in determining what features are available for an eBook.
"accessInfo": {
"country": "US",
"viewability": "PARTIAL",
"embeddable": true,
"publicDomain": false,
"textToSpeechPermission": "ALLOWED_FOR_ACCESSIBILITY",
"epub": {
"isAvailable": true,
"acsTokenLink": "https://books.google.com/books/download/The_Google_story-sample-epub.acsm?id=zyTCAlFPjgYC&format=epub&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api"
},
"pdf": {
"isAvailable": false
},
"accessViewStatus": "SAMPLE"
}
The epub section will have an isAvailable property indicating if this type of ebook is available.
We can use acsTokenLink as the "download epub link" and can set up our conditional:
if( book.accessInfo.epub.isAvailable ) {
axios.get(acsTokenLink).then( responseData => /* store epub in app storage here */ )
}
Looking further: I have found Epub.js as one solution to display epub files with React Native. Additionally, here's an example repo.
Related
I am developing an internal company app that does not reach out to the internet, therefore I can not use CDNs or Google Fonts.
In my developer console for Chrome (and not Firefox for some reason) I get errors pointing to the fact it get the following urls
https://dcn.jsdeliver.net/npm/#mdi/font#latest/materialdesignicons.min.css
and
https://fonts.googleapis.com/css?family=Roberto:100,300,400,500,700,900&display=swap
How (in nuxt/vuetify) can I turn these off?
First of all you need to set nuxtjs/vuetify to offline mode with this configuration:
{
buildModules: [
'#nuxtjs/vuetify'
],
vuetify: {
defaultAssets: false // <= this will disable autoloading Google font and MDI icons
}
}
Then you can import these icons and fonts as here.
I come from a react web background and I'm familiar with the online payments api. Currently, I am using the react native quick start for the square reader SDK. The SDK uses:
await startCheckoutAsync(checkoutParams)
which is a function that handles payment through the mobile application without connecting to a backend (which is what I'm used to in Web application development). The checkout parameters look like this:
// A checkout parameter is required for this checkout method
const checkoutParams = {
amountMoney: {
amount: 100,
currencyCode: 'USD', // optional, use authorized location's currency code by default
},
// Optional for all following configuration
skipReceipt: false,
collectSignature: true,
allowSplitTender: false,
delayCapture: false,
note: 'Hello 💳 💰 World!',
tipSettings: {
showCustomTipField: true,
showSeparateTipScreen: false,
tipPercentages: [15, 20, 30],
},
additionalPaymentTypes: ['cash', 'manual_card_entry', 'other'],
};
However my issue is that there is no way to associate an order with this checkout flow.
According to the Square Reader documentation:
https://github.com/square/react-native-square-reader-sdk/blob/master/docs/reference.md#checkoutparameter
checkout parameter does not take in an order id, or someway to map what is getting sold, unlike the online create payment api:
https://developer.squareup.com/reference/square/payments-api/create-payment
which specifies an order id in the API call.
How do I properly handle associating an order Id to the react-native card reader sdk checkout flow
At this time, there is no proper way to link an order to a ReaderSDK payment. ReaderSDK does not allow itemization currently, per the docs.
I was trying to let users see web page previews in react-native like the link previews seen on Facebook and other apps. I've done some research.
I've seen some library that provides the function for node, but it doesn't work for react-native (because the original cheerio.js doesn't work directly with react-native)
https://github.com/cheeriojs/cheerio
I've checked the oEmbed library too, but it doesn't seem to work either.
I was wondering what might be the good ways for getting web page previews
Ended up writing a small library that does the job. Hopefully it's useful to some people
https://github.com/changey/react-native-page-previewer
Usage
import preview from 'react-native-page-previewer';
preview("http://www.google.com", function(err, data) {
if(!err) {
console.log(data);
}
});
sample return
{ url: 'https://www.google.com',
loadFailed: false,
title: 'Google',
description: 'Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for.',
contentType: 'text/html',
mediaType: 'website',
images: [ 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png' ],
videos: undefined,
audios: undefined }
I have implemented Universal links in iOS app. It works perfectly when I put the url in external app such as "Notes" and then tap it. It opens the app.
What I want to achieve is that when someone visits a specific url of my webpage, the ios app should be launched by itself. So in order to accomplish this, I have put:
applinks:www.mydomain.com
in my entitlements.
And the following in my "apple-app-site-association" file
{
"applinks":
{
"apps": [ ],
"details":
[
{
"appID": "team_id.com.teamname.app_name",
"paths": ["/path-CompA/path-CompB/"]
}
]
}
}
But When I navigate through my website, and I reach the path mentioned in json file, it only shows the bar at top of web page saying "Open in App_name" with "Open" button on right side.
I want to know if its the default behaviour of Universal links to not open the app if user is coming from the same domain? If its not the case then how does it open the app form "Notes".
Please note that my json file is not signed but I have put it on my website which is on https.
Thanks,
A couple of things. Can you try changing your apple-app-site-association file code as such?
{
"applinks": {
"apps": [],
"details": [
{
"appID": "team_id.com.teamname.app_name",
"paths": [
"*",
"/"
]
}
]
}
}
You can check your format with this validation tool: https://search.developer.apple.com/appsearch-validation-tool/
The answer is that basically, this behavior is expected as of iOS9.2, with Universal links. Universal links only work from a different domain.
With Branch (https://branch.io/), you can use one domain for links (bnc.lt), so that when you (as a developer using branch) host universal links on your site, they still operate as expected.
Also, for universal links from other domains (not to the same domain), you can 'unbreak' the safari redirect behavior by long-pressing on the link from an application and choosing 'Open in «App»'. I hope this helps!
I've read several sources now but did not find a solution: I'm using Facebook C# SDK with ASP.net 4 and VB.net 2010. I have a Facebook Canvas application. I'm using Canvas Auth.Authorize and it works fine. Now I want to know whether the currently logged in user already likes my app. How could I do that?
'SignedRequest' does not seem to work because according to Facebook Documentation "This field is only present if your app is being loaded within a Page Tab".
graph/user/likes is also not an option because I don't want to ask the user to grant access for my app to all his likes.
But the Facebook Plugin is able to differ whether the current user likes my app or not, so I'm quite optimistic that there is a way which I just did not find yet.
Many thanks!
You can use the graph API to call the users likes. Instead of requesting all of the likes simply request the single one you want.
https://graph.facebook.com/userId/likes/appId
If you the user has liked the page the result will return details about the page. For example:
{
"data": [
{
"name": "Microsoft Office Web Apps",
"category": "Software",
"id": "121883824529155",
"created_time": "2012-03-14T06:48:47+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/me/likes/121883824529155?format=json&limit=5000&offset=5000&__after_id=121883824529155"
}
}
If the user has not liked the page you will receive empty data.
{
"data": [
]
}
With the Facebook C# SDK you would make this request as follows:
var client = FacebookClient("access_token_here");
dynamic result = client.Get('/me/appId');
if (result.data.Length == 1) {
// User has liked page
}