Question

I want my main html file to have a different name than my project.

I have found that Worklight will not reconnect if I don't use the same name. I have tried changing the mainFile tag in the application-descriptor.xml and changing the wlMainFile entry in worklight.plist on iOS.

Direct Update does not work. More importantly the application does not reconnect and I get a grey screen (presumably because iOS is trying to launch using the wrong file).

For example:

Project name: MyProject
main file: home.html
application-descriptor.xml: <mainFile>home.html</mainFile>
worklight.plist: <wlMainFile>home.html</wlMainFile>

The above does not work.

[Edited later to add my application-descriptor.xml]

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Licensed Materials - Property of IBM
             5725-G92 (C) Copyright IBM Corp. 2006, 2012. All Rights Reserved.
         US Government Users Restricted Rights - Use, duplication or
         disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
<!-- Attribute "id" must be identical to application folder name -->
<application xmlns="http://www.worklight.com/application-descriptor" id="agent" platformVersion="5.0.6">
 <displayName>My app</displayName>
 <description>My application description </description>
 <author>
    <name>Redacted</name>
    <email>redacted@foo.com</email>
    <homepage>http://redacted.com</homepage>
    <copyright>(c) redacted LLC</copyright>
 </author>
<height>748</height>
<width>1024</width>
<mainFile>home.html</mainFile>
<thumbnailImage>common/images/ipad-app-icon.png</thumbnailImage>
<!--  -->
<ipad bundleId="com.redacted.myproject" version="1.0">
    <worklightSettings include="true"/>
    <security>
        <encryptWebResources enabled="false"/>
        <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
    </security>
</ipad>
<!--  -->
<android version="1.0">
    <worklightSettings include="true"/>
    <security>
        <encryptWebResources enabled="false"/>
        <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/>
        <publicSigningKey>Replace this text with the public key of the certificate with which you sign the APK. 
        For details see the Worklight Developer's Reference Guide.</publicSigningKey>
    </security>
</android>
<worklightServerRootURL>http://${local.IPAddress}:8080</worklightServerRootURL>
</application>

So, to be clear, if I have encountered an issue with my mainFile being a name other than the project name. Worklight does not always call the filename specified by mainfile, especially after the initial use of the application.

Was it helpful?

Solution

If changing the HTML filename, make sure to also change:

  1. The application folder name
  2. In application-descriptor.xml:

    • id attribute in the application element
    • mainFile element value

All should match each other.

Make sure to delete the native folder and re-build the project. Application will continue loading after the first time, and Direct Update will continue to function.

OTHER TIPS

The only solution I have found is to name my main file the same name as the application within the project. My application runs fine when I do this.

[Note that this has been edited to match @Idan Adar's recommendation above. It's not the PROJECT that must match the mainFile, but the APPLICATION name]

The following works fine:

Project name: MyProject
main file: MyProject.html
application-descriptor.xml: <mainFile>MyProject.html</mainFile>
worklight.plist: <wlMainFile>MyProject.html</wlMainFile> (this is a generated file)

It appears that Worklight launches the iOS application properly the first time using the file specified in wlMainFile. Then when it has to resume or restart, it's looking for the application name rather than the value specified in wlMainFile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top