Back to Cordova

2021 05 19

slack-digest/2021-05-19.md

latest11.3 KB
Original Source

Cordova Slack Digest

Wed, 19 May 2021 08:22:57 GMT

User count: 4488

Join the conversation at slack.cordova.io

Channel #general (27 messages)


Tue, 18 May 2021 14:22:58 GMT

@matt226 says

Hi All! Im adding cordova-plugin-file to my app, to save a pdf. When trying to write the file to temp storage on device ( works in simulator ) I get this

"Cannot load blob:null/ac4b70c9-e2fb-4378-91eb-6deb7d9ca4c0 due to access control checks. (anonymous function) — FileReader.js:288 (anonymous function) — FileWriter.js:139 (anonymous function) — app-e221e3fa273c87d12fa7e29efa76f45f.js:381:355 (anonymous function) — FileEntry.js:69 (anonymous function) — FileEntry.js:85 callbackFromNative — cordova.js:295 (anonymous function) — cordova.js:972 promiseReactionJob cordova.js:1413"

FileWriter error: NotReadableError: The I/O read operation failed. code: 0 message: "The I/O read operation failed." name: "NotReadableError" Error Prototype fileName: "" length: 0 localURL: "<cdvfile://localhost/persistent/document.pdf>" onabort: null onerror: function() onprogress: null onwrite: null onwriteend: function() onwritestart: null position: 0 readyState: 2 result: null

Am I missing something obvious, I have added blob: file: cdvfile: to CORS and Whitelist

Tue, 18 May 2021 15:17:13 GMT

@andrew867 says

On which platform are you seeing the error?

Tue, 18 May 2021 15:19:18 GMT

@andrew867 says

blob:null/ I can’t recall seeing null in a blob’s URI before.

Tue, 18 May 2021 15:20:52 GMT

@norman137 says

null here references the origin, which will be null if the cordova app is hosted on the file:// protocol.

blob: should be sufficient for CSP

Tue, 18 May 2021 15:20:58 GMT

@andrew867 says

That said, you don’t tend to see the value, especially when stuff works.

Tue, 18 May 2021 15:21:10 GMT

@andrew867 says

Ah, ha.

Tue, 18 May 2021 15:22:08 GMT

@norman137 says

I suspect it's an API 29 issue with the app not having read/write external storage access -- but not 100% where <cdvfile://localhost/persistent> translates to

Tue, 18 May 2021 15:22:34 GMT

@norman137 says

But I'm not really confident in that answer

Tue, 18 May 2021 15:23:00 GMT

@andrew867 says

I was just checking that myself :

https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-file/#page-toc-source

Tue, 18 May 2021 15:27:28 GMT

@matt226 says

It is iOS 14, the null: is without adding the following, it become file:/// after

<preference
&lt;preference name="hostname" value="localhost" /&gt;```
I was writing like this

`window.requestFileSystem( window.LocalFileSystem.PERSISTENT , 0 , function( fileSystem ) {fileSystem.root.getFile( "newPersistentFile.txt" , { create: create , exclusive: false } , resolve , reject );`
                
            `} , reject );`

Tue, 18 May 2021 15:28:11 GMT

@andrew867 says

> iOS Quirkscordova.file.applicationStorageDirectory is read-only; attempting to store files within the root directory will fail. Use one of the other cordova.file.* properties defined for iOS (only applicationDirectory and applicationStorageDirectory are read-only).

Tue, 18 May 2021 15:29:34 GMT

@andrew867 says

But, it is /persistent/ so that can’t be the case. Plus it’s not a write error; it’s a Read Error.

Tue, 18 May 2021 15:29:54 GMT

@matt226 says

It seems to write then read in the FileWriter code

Tue, 18 May 2021 15:31:36 GMT

@matt226 says

Other weird thing, is if I try a second time in same session in app, it workd

Tue, 18 May 2021 15:32:31 GMT

@andrew867 says

Ah, in that case it might just be speed. The I/O hasn’t completed, so you’re read after the write is failing b/c the writer still has exclusive rights, or similar.

Tue, 18 May 2021 15:34:45 GMT

@matt226 says

But this is just saving an empty .txt file at the moment

Tue, 18 May 2021 15:35:03 GMT

@matt226 says

Tue, 18 May 2021 15:40:32 GMT

@andrew867 says

What happens if you defer the execution of the getFile - in case it’s being caused by the requestFileSystem executing the success callback too soon, before the device has initialised the local storage?

Tue, 18 May 2021 15:56:07 GMT

@andrew867 says

Might be a bit like “teaching ma to suck eggs”, but you are waiting on the deviceReady state before attempting to access the File System

Tue, 18 May 2021 15:58:04 GMT

@matt226 says

Yes, and then some, it is a used based interaction that initiates the save, just putting a 5 second sleep before writing the file

Tue, 18 May 2021 16:00:50 GMT

@matt226 says

Well sleeping for 5 seconds seems promising, I wonder why the callback would fire before it is ready

Tue, 18 May 2021 16:05:17 GMT

@matt226 says

500ms solves the issue as well, thanks for pointing me in the right direction @andrew867

Tue, 18 May 2021 16:05:54 GMT

@andrew867 says

You’re welcome, sorry that a I suggested a timeout, I hate using them!

Tue, 18 May 2021 16:06:20 GMT

@andrew867 says

One thing…

Tue, 18 May 2021 16:06:36 GMT

@andrew867 says

I’ve always initialized the FileSystem when the app starts.

Tue, 18 May 2021 16:08:03 GMT

@andrew867 says

So I’d execute the requestFileSystem early on, storing the reference to root off somewhere for use later.

Tue, 18 May 2021 16:08:43 GMT

@andrew867 says

However, as you say, the callback should only be executed when it really is ready.

Channel #cordova-windows (7 messages)


Tue, 18 May 2021 19:28:25 GMT

@alex678 says

Hello everybody, i use Cordova + windows platform + VS 2017. I know that VS 2019 didn't worked yet, but do you know please if there is an easy way to migrate to VS 2019 ?

Tue, 18 May 2021 19:30:58 GMT

@dpogue says

My understanding is that Microsoft dropped support for Cordova projects in VS2019

Tue, 18 May 2021 19:33:53 GMT

@alex678 says

yes , i heard that there are maybe some "replacement" (webview2 ? electron ?) i don't know the easiest way to do that

Tue, 18 May 2021 19:34:23 GMT

@dpogue says

Electron will work for making Windows apps, but doesn't involve VS at all (as far as I know)

Tue, 18 May 2021 21:10:38 GMT

@andrew867 says

I just use a windows server with cygwin, node & bash - what do you need the VS ide for?

Tue, 18 May 2021 21:13:39 GMT

@alex678 says

I use VS to "build" my cordova app for Windows Store

Wed, 19 May 2021 07:31:41 GMT

@andrew867 says

What’s wrong with the command line msbuild or just vanilla cordova build?

Channel #cordova-android (19 messages)


Tue, 18 May 2021 20:35:19 GMT

@info460 says

Evening, I like to ask about op@ening specific app by clicking link. Not sure if its deeplinking as reading about it but confused. What I need is to click on Google maps url and instead of having Android prompt about which app to use for action, open the link directly in G Maps if user have install.ed

Tue, 18 May 2021 20:42:52 GMT

@dpogue says

I think https://developer.android.com/training/app-links/ is what you want

Tue, 18 May 2021 20:52:16 GMT

@info460 says

Thanks for link but its where I am confused, Deep links and App links talk about opening something in MY app (specific location or as handler for the link. What I need is to call 3 rd party app to handle the link.

Tue, 18 May 2021 21:01:22 GMT

@pieter.vanpoyer says

I think opening in Google maps can be done with the geo - scheme. Very old link: https://stackoverflow.com/a/10204962/12467297

Tue, 18 May 2021 22:06:23 GMT

@jcesarmobile says

If you want to open a specific app, you need to know the package and use it to open. If you want to open the app using https url then they need to have the app links configured and should just work you shouldn’t need to do anything. If you already have the https url to google maps it shouldn’t prompt you to use a different app, unless they didn’t configure the app links properly

Tue, 18 May 2021 22:07:05 GMT

@jcesarmobile says

Geo scheme should also work, but could prompt to open other apps that also support it

Tue, 18 May 2021 22:12:51 GMT

@mathewp.94 says

If you're willing to write a custom plugin and use some native code, you can use this method https://developer.android.com/training/basics/intents/sending

Tue, 18 May 2021 22:13:14 GMT

@mathewp.94 says

You're always going to run into the case of Android asking which app to use unless the user has selected a default though

Tue, 18 May 2021 22:22:32 GMT

@mathewp.94 says

Using a geo: link is probably your best bet though tbh

Tue, 18 May 2021 22:23:35 GMT

@info460 says

thanks you all, didnt know the geo: option before

Tue, 18 May 2021 22:46:35 GMT

@mathewp.94 says

Is there a reason that not using Androidx is recommended?

[Gradle
[Gradle Properties] Detected Gradle property "android.enableJetifier" with the value of "true", Cordova's recommended value is "false"```

Tue, 18 May 2021 22:47:47 GMT

@dpogue says

I think it prints that warning if you aren't using the default value... if AndroidX works for your app, you should definitely use it

Tue, 18 May 2021 23:15:34 GMT

@mathewp.94 says

That makes sense

Tue, 18 May 2021 23:15:47 GMT

@mathewp.94 says

Are there plans to shift to AndroidX by default at some point?

Tue, 18 May 2021 23:57:20 GMT

@jcesarmobile says

Yeah, cordova android 10 will only use androidX

Wed, 19 May 2021 03:40:23 GMT

@amit.agarwal.1980 says

Hi, When we are trying to upload the .apk into google play store got the below three warning, can any one help us to fix this.   Warning This APK results in unused code and resources being sent to users. Your app could be smaller if you used the Android App Bundle. By not optimizing your app for device configurations, your app is larger to download and install on users’ devices than it needs to be. Larger apps see lower install success rates and take up storage on users’ devices. Warning This APK contains Java/Kotlin code, which might be obfuscated. We recommend you upload a deobfuscation file to make your crashes and ANRs easier to analyze and debug.  Warning This APK contains native code, and you’ve not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug.

Wed, 19 May 2021 04:05:39 GMT

@mathewp.94 says

For the first one, choose "Android App Bundle" when you are building your app for the play store

Wed, 19 May 2021 04:06:25 GMT

@mathewp.94 says

The other two warnings don't really matter in my experience but others might have a better informed opinion on that

Wed, 19 May 2021 05:50:30 GMT

@amit.agarwal.1980 says

Hi, Is any way to configure android mixed_content_always_allow (e.g. config.xml etc) and not by the code?