Thu, 03 Dec 2020 08:31:25 GMT
Join the conversation at slack.cordova.io
Wed, 02 Dec 2020 11:16:32 GMT
@pratiksha.bhavsar0895 says
Why :active and :focus css does not work on iphone ? The same css properly works on android. What could be a proper solution so that on active or on focus I can add css on my buttons. Tried ontouchstart on body as well as button tag but didn't work . Please let me know if anybody has gone through this while doing mobile app development. Thanks and Kind Regards,Pratiksha
Wed, 02 Dec 2020 11:42:37 GMT
@norman137 says
according to the safari docs,
:active
is only enabled on elements with a touchstart on the element.> On iOS, mouse events are sent so quickly that the down or active state is never received. Therefore, the
:active
pseudo state is triggered only when there is a touch event set on the HTML element—for example, whenontouchstart
is set on the element as follows: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/AdjustingtheTextSize/AdjustingtheTextSize.html (bottom of the page)
Wed, 02 Dec 2020 11:43:00 GMT
@norman137 says
Not sure if
:focus
works the same way, couldn't find a mention on that.
Wed, 02 Dec 2020 11:52:19 GMT
@pratiksha.bhavsar0895 says
Thank you so much Norman , Ya I tried to set ontouchstart and had :active css mentioned in styles but does not seem to work.
Wed, 02 Dec 2020 11:55:22 GMT
@norman137 says
The docs I linked is an archive, so perhaps it's out-dated
Wed, 02 Dec 2020 15:12:27 GMT
@mpriddy says
Still working through WKWebView vs CORS.
Wed, 02 Dec 2020 15:12:53 GMT
@mpriddy says
My DevOps team replied to me today: > Yes, you would need your applications to return proper access control headers. CORS in general is a bad idea unless there are no other options.
Wed, 02 Dec 2020 15:13:05 GMT
@mpriddy says
I really don’t know what this means, yet.
Wed, 02 Dec 2020 15:24:04 GMT
@norman137 says
If you were accessing http://example.com|example.com - http://example.com|example.com needs to send the
Access-Control-...
headers in their responses. Additionally they may also need to respond to theOPTIONS
method of each URL handler.Unfortunately WKWebView enforces CORS with no api to disable them. So if you need to make network requests from within the webview there are no other options.
There is only 1 workaround that I know of and that‘s to use the native http libraries, which aren’t bound to the restrictions set fourth by the webview. This would involve creating a cordova plugin or finding an existing one that provides an interface to use the native APIs instead of the JS‘s
XMLHttpRequest
class. The drawback of this method is that you can’t use the web inspector to see those network requests and debug/troubleshoot. And transferring data across the cordova bridge is incredibly inefficient, so if you make requests that results in large data being transferred, you will receive a performance penalty with this approach.
Wed, 02 Dec 2020 15:28:24 GMT
@mpriddy says
That’s what I thought. But Mr. DevOps His Holiness, Long May He Reign says my app shall send control headers, verily.
Wed, 02 Dec 2020 15:28:47 GMT
@mpriddy says
Oinkheaded DevOps. Aren’t they supposed to help me?
Wed, 02 Dec 2020 15:33:53 GMT
@norman137 says
I think the moment they add the header, it will block all cross-origin request (from CORS-enabled browsers) unless if the origin is in the allowed origin header. If they want to just allow all origin, they can use
*
wildcard or dynamically read the requestOrigin
header and set that as theAccess-Control-Allow-Origin
response.
Wed, 02 Dec 2020 15:37:06 GMT
@mpriddy says
This particular server is specific to this app. So, I would think the simple solution would be to add the header.
Wed, 02 Dec 2020 15:37:45 GMT
@norman137 says
Probably
Wed, 02 Dec 2020 15:38:03 GMT
@mpriddy says
Hmmm. Since … I can run PHP on the server, maybe it’s up to me to return the headers.
Wed, 02 Dec 2020 15:38:19 GMT
@mpriddy says
And when he says “applications” he means “your PHP running on the server.”
Wed, 02 Dec 2020 15:38:27 GMT
@norman137 says
Ah that makes more sense
Wed, 02 Dec 2020 15:39:01 GMT
@norman137 says
Yes it can be done at the server level (nginx or apache, or whatever) or it can be done at the backend app level, like your PHP app.
Wed, 02 Dec 2020 15:40:00 GMT
@mpriddy says
It’s my mental model, again. “App” (to me) means “that stuff running on the mobile device”
Wed, 02 Dec 2020 15:40:08 GMT
@mpriddy says
And not “the code running on the server.”
Wed, 02 Dec 2020 15:42:36 GMT
@mpriddy says
Well shoot, I’m already sending
Access-Control-Allow-Origin: *
Wed, 02 Dec 2020 15:43:39 GMT
@norman137 says
CORS protocol has 2 types of requests... “simple” and “preflight”. You might be triggering a preflight request.
Wed, 02 Dec 2020 15:44:03 GMT
@mpriddy says
Hmm. Maybe I’m not sending it “everywhere.”
Wed, 02 Dec 2020 15:44:09 GMT
@mpriddy says
I have some more looking to do, I think.
Wed, 02 Dec 2020 15:45:24 GMT
@norman137 says
Which means you need to handle the
OPTIONS
method of that request... so say you were making aPOST /example/api/
... you not only need to handle that method, but the browser behind-the-scenes will send aOPTIONS /example/api/
request, before sending thePOST
request.Postman is your friend, you can hit your server and ensure that all your headers are present and correct.
Couple of things that got me:
Wed, 02 Dec 2020 15:45:42 GMT
@norman137 says
- No duplicate headers
Wed, 02 Dec 2020 16:02:15 GMT
@mpriddy says
Yaaay! Got it working. Thank you again, again.
Wed, 02 Dec 2020 16:11:45 GMT
@norman137 says
good cause I forget what the second gotcha was
Wed, 02 Dec 2020 16:11:47 GMT
@norman137 says
😆
Wed, 02 Dec 2020 16:11:58 GMT
@mpriddy says
😄
Wed, 02 Dec 2020 11:40:06 GMT
@jakob.pfab says
is there a way to set resizeOnFullScreen in cordova-plugin-ionic-keyboard programmatically?
As this setting fixes the problem that in fullscreen view the keyboard does not resize the content, but ads a new issue were content on the bottom is not visible anymore (see https://github.com/ionic-team/cordova-plugin-ionic-keyboard/issues/117 or https://github.com/ionic-team/cordova-plugin-ionic-keyboard/issues/116) ?
I could set it programatically then only for those views were its needed
Wed, 02 Dec 2020 11:45:27 GMT
@norman137 says
Based on https://github.com/ionic-team/cordova-plugin-ionic-keyboard/blob/master/www/android/keyboard.js
I‘m gunna say no, it doesn’t look like there is an API to change the mode programmatically.
Wed, 02 Dec 2020 11:48:42 GMT
@norman137 says
There appears to be some API functions for programmatic control for some preferences... like this iOS only resize mode preference https://github.com/ionic-team/cordova-plugin-ionic-keyboard#keyboardresizemode-for-ios-only so maybe you can do a feature request.
Wed, 02 Dec 2020 13:11:29 GMT
@jakob.pfab says
i modified this pull request a bit and with those changes its working for me
Wed, 02 Dec 2020 13:11:30 GMT
@jakob.pfab says
https://github.com/ionic-team/cordova-plugin-ionic-keyboard/pull/145
Wed, 02 Dec 2020 13:12:21 GMT
@jakob.pfab says
i guess i will work with my own fork of the plugin until this gets merged (i hope at some point 🙏 )
Wed, 02 Dec 2020 13:46:34 GMT
@jakob.pfab says
this is what fixed the issue for me: https://github.com/jakob-p/cordova-plugin-ionic-keyboard/commit/dcba76059798fbadd7b6c3c52e4abb970e593b72