ryanflores-bayalarm commented on issue #244:
URL: 
https://github.com/apache/cordova-plugin-splashscreen/issues/244#issuecomment-1452731628

   I know that this is really old and I apologize for grave digging, but I just 
wanted to provide some information in regards to this and how I got 
**cordova-plugin-splashscreen** to work with Electron.
   
   - **Issue 1:** Regardless of what's mentioned in [the 
docs](https://cordova.apache.org/docs/en/11.x/reference/cordova-plugin-splashscreen/index.html#browser-quirks),
 not only do you need to define the `SplashScreen` preference, but you MUST 
also define the `<splash>` tag as a relative path to your project directory 
(i.e. "res/splash.png").
   - **Issue 2:** The value defined for `SplashScreen` does not get honored or 
maintained. The image defined by the `<splash>` tag will get copied to a new 
`platform/electron/www/.cdv/` directory, and the image will get renamed to 
`splashScreen.png`. The `platform/electron/config.xml` file will then get 
updated such that both the `<splash>` tag and the `SplashScreen` preference 
will get (force) set to `.cdv/splashScreen.png`, not matter what.
   - **Issue 3:** Basically, the JavaScript errors that @globules-io mentioned 
above were being caused by a timing issue. More specifically, the 
`initAndShow()` function in 
`platform/electron/www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js`
 would get called/executed before the `<body>` tag was fully initialized in the 
DOM. The `document` node would exist, but not `document.body`, as as result 
producing the **appendChild** error.
   
   Basically, the way I resolved this issue was by:
   
   - Adding `<splash>` to `config.xml` within `<platform name="electron">`
   - Adding the `SplashScreen` preference as well, but leaving the value empty. 
It doesn't appear to matter if it's populated or not.
   - Wrapping the `(function initAndShow () {` block of code in 
`platform/electron/platform_www/plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js`
 in a `setTimeout()`. There's no need to specify a delay. Just using 
`setTimeout()` will cause a long enough delay to wait for `document.body` to 
initialize.
   
   For that last bullet, please take not that I mentioned **platform_www** and 
not **www**. Whenever you run/build the app, the plugin(s) will get copied from 
**platform_www/plugins/** to **www/pugins/**.
   
   I hope anyone who comes across this will find this useful. I wasted 2-3 days 
just trying to figure all this out.
   
   As far as whose responsible for fixing what, for sure the maintainers of 
**cordova-plugin-splashscreen** must fix `SplashScreenProxy.js`.  However, in 
regards to `<splash>` and the `SplashScreen` preference, I have no clue who 
needs to address that.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to