Cordova Slack Digest

Wed, 28 Oct 2020 08:33:33 GMT

User count: 4201

Join the conversation at slack.cordova.io

Channel #general (35 messages)


Tue, 27 Oct 2020 13:01:54 GMT

@abul.asar22 says

Hello everyone, when my cordova iOS app loads it navigate to the landing page and on that page keyboard opens up and it pushes entire dashboard screen to the top above the keyboard. How to fix this ? Any recommendation ?

Tue, 27 Oct 2020 13:03:34 GMT

@gh says

Are you setting focus to an input field?

Tue, 27 Oct 2020 13:03:52 GMT

@abul.asar22 says

no there is no input field on that page.

Tue, 27 Oct 2020 13:04:36 GMT

@abul.asar22 says

what KeyboardShrinksView does ? can this be helpful ?

Tue, 27 Oct 2020 13:06:41 GMT

@norman137 says

Unless you are using some plugin to control keyboard behaviour, the webview will only ever display the keyboard if an input field is focused.

Tue, 27 Oct 2020 14:34:31 GMT

@reis says

hey guys, I‘m stuck on an issue related CORS. Recently the app was updated to use WKWebView and the CORS was implemented on my BE side. But I have a feature where the app needs to connect with a local device (a sensor like an arduino) . And his BE is not be reached to implement the CORS. I’m trying a lot of things, my research appoint to the use of native code to do this requests is the best way, for now I'm trying to use this plugin: https://github.com/silkimen/cordova-plugin-advanced-http with he I get to made others requests but not this local request. Someone could help me? (this issue is just on ios, Android works fine)

Tue, 27 Oct 2020 14:46:09 GMT

@norman137 says

From the screenshot it looks like you're still using XMLHttpRequest from the webview and not a http plugin. And the ios webview expects the server to implement CORS which it is incorrectly doing so.

Tue, 27 Oct 2020 14:47:01 GMT

@reis says

yeah, it is my original log, before the plugin implementation

Tue, 27 Oct 2020 14:47:02 GMT

@norman137 says

preflight response errors means it's not properly responding to the OPTIONS request

Tue, 27 Oct 2020 14:48:23 GMT

@reis says

I remove him and retry using XMLHttpRequest

Tue, 27 Oct 2020 14:50:21 GMT

@norman137 says

See https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Preflighted_requests to see the flow when request requires a preflight request.

Tue, 27 Oct 2020 14:52:15 GMT

@reis says

yeah, I've already read it

Tue, 27 Oct 2020 15:12:05 GMT

@reis says

well forgetting the screenshot, (I not should‘ve sent him, just wanted to confirm the CORS issue). About this issue have any idea of how can I solve? my research say that is not more possible bypass the the CORS using XMLHttpRequest, in this case I’ll need to make this request using native code, right? If yes, you know something about this plugin above with this kind of request, or recommend another think?

Tue, 27 Oct 2020 15:15:54 GMT

@timbru says

Why is using cors not an option?

Tue, 27 Oct 2020 15:26:00 GMT

@norman137 says

Using the native http api will allow you to bypass cors because cors is not enforced in the native layer, it‘s only enforced in the browser. But routing all your connections through the cordova bridge to do this isn’t going to be very efficient, especially when it comes to binary data; so it might not be a solution for everyone. As annoying as CORS is to deal with, it's always best to stay within the webview realm as much as possible.

And you shouldn‘t need to go through that trouble if the server just implements CORS properly. I can’t tell you exactly what is wrong without seeing code/your API responses, but the error stated the preflight request failed to respond, so that hints where to look:

  • Ensure that you're server responds to the OPTIONS http method on your URL endpoint
  • Ensure that the OPTIONS http method response includes the necessary Access-Control headers.
  • Use https://www.postman.com/|postman to hit your server, which makes testing your URL end points easier. The only reason that someone should bypass CORS imo, is because they don‘t have control over the BE and they don’t have the resources to setup and run a proxy server.

Tue, 27 Oct 2020 16:21:18 GMT

@osaintilien55 says

I did “run android” command yesterday or maybe 2 days ago and it was working just fine on my phone, but now it‘s not. The app apk can play in my bluestacks emulator but it won’t start on my phone. I can see my phone in chrome inspect. I have already tried platform remove and platform add to start fresh. Not sure what else could be the problem. I am trying to get it on my phone so that I can troubleshoot some issues with remote.

Tue, 27 Oct 2020 16:23:42 GMT

@norman137 says

The fact that adb is failing to install the apk kinda signals either a device problem or an adb problem. Usually there is a reason explained on the very next line...

Tue, 27 Oct 2020 16:26:11 GMT

@osaintilien55 says

Hmm ok well unfortunately it doesnt seem to give a reason here, the only hint I am getting is “error code 1”.

Tue, 27 Oct 2020 16:27:04 GMT

@norman137 says

does adb devices -l works?

Tue, 27 Oct 2020 16:28:52 GMT

@osaintilien55 says

Sorry I do not know what to do with this, adb devices -l. How do I use it

Tue, 27 Oct 2020 16:29:16 GMT

@norman137 says

its a command to be used in the command prompt

Tue, 27 Oct 2020 16:30:25 GMT

@osaintilien55 says

Right that's what I thought but nothing happened, I tried it both with the word cordova and without

Tue, 27 Oct 2020 16:31:30 GMT

@norman137 says

no cordova, it isn't a cordova command

Tue, 27 Oct 2020 16:31:36 GMT

@norman137 says

adb is an executable provided by the android sdk

Tue, 27 Oct 2020 16:31:53 GMT

@norman137 says

so just...

adb devices -l

and -l is a lowercase L.

Tue, 27 Oct 2020 16:32:03 GMT

@norman137 says

oh

Tue, 27 Oct 2020 16:32:14 GMT

@norman137 says

dope I should have read everything 😅 sorry

Tue, 27 Oct 2020 16:32:31 GMT

@osaintilien55 says

no problem

Tue, 27 Oct 2020 16:35:52 GMT

@norman137 says

you don't have your environment variables setup, cordova probably figures it out for you... the executable should be located in $ANDROID_HOME/platform-tools/ but not sure if windows follows the $ variable syntax

Tue, 27 Oct 2020 16:50:58 GMT

@osaintilien55 says

okay I found it

Tue, 27 Oct 2020 16:51:25 GMT

@osaintilien55 says

So then I should add it to the the env variable path?

Tue, 27 Oct 2020 16:51:56 GMT

@osaintilien55 says

referring to adb.exe to be exact

Tue, 27 Oct 2020 16:52:47 GMT

@mcsd says

Hi there, does anybody knows how to handle Azure Active Directory B2C with a Cordova App (Android/iOS) to authenticate users?

Wed, 28 Oct 2020 07:50:12 GMT

@sumeet.hindinkeri says

Is there way to restrict google api key usage without using referrers for ionic app?

Wed, 28 Oct 2020 08:11:49 GMT

@abul.asar22 says

Hello Everyone, I am using phonegap-plugin-push for notification.If app is background and on clicking notification the app is not opening.I have written redirect logic to open specific page and it is happening in background but app does not open. On opening the app manually from background I can see the app is redirected. Has anyone faced this issue ?

Channel #cordova-electron (2 messages)


Tue, 27 Oct 2020 12:38:06 GMT

@savoier says

Hi! And thanks for the reply! 🙂 I just figured for the hooks that the before_compile is never called, so I used after_prepare and this one is called. My script modifies every style paths for windows and electron builds to remove the leading ‘/’ from paths. I needed a script because Android and iOS require the leading slash.

As for icons, would you use the after_prepare hook to run such a script?

Tue, 27 Oct 2020 17:11:45 GMT

@prasunjajodia says

before_compile works for me. I use it for electron to do some cleanup before compiling. I add the script inside <platform name="electron">

This is the part of config.xml

        <hook src="res/electron/doElectronCleanup.js" type="before_compile" />```