Skip to Content

      /wp-content/uploads/2013/11/sap_logo_334666.png

AppUpdate

The AppUpdate plugin is used to enable the contents under the www folder (HTML, JavaScript, CSS, images, etc.) of a deployed Kapsel app and its config.xml to be updated.  As an example, a new project named AppUpdateDemo will be created and used to demonstrate how to update a deployed app.  A Kapsel app with the AppUpdate plugin installed will check with the SMP 3.0 server on startup to see if there is a newer version of the Kapsel app available.  The revision number of the Kapsel app is automatically incremented with each deployment to the SMP 3.0 server.  If the revision on the server is higher than the revision in the config.xml on the device or simulator, then a notification is shown asking the user if they wish to accept the update
image1.PNG

For additional details see the JavaScript file in a project that includes this plugin at

project_name\plugins\com.sap.mp.cordova.plugins.appupdate\www\appupdate.js

or the JS Documentation at Kapsel AppUpdate API Reference.

The following steps will demonstrate this plugin.

  • Follow the steps shown in Configuring a Kapsel App in the Management Cockpit to create an Application with the application ID of
    com.mycompany.appupdate

      This app does not use an OData endpoint so that can be set to a dummy URL such as

    http://www.mycompany.com

    and the Basic SSO mechanism.

  • Create a new project named AppUpdateDemo and add Android or iOS or both.
    cordova -d create C:\Kapsel_Projects\AppUpdateDemo com.mycompany.appupdate AppUpdateDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd AppUpdateDemo
    cordova -d platform add android
    
    cordova -d create ~/Documents/Kapsel_Projects/AppUpdateDemo com.mycompany.appupdate AppUpdateDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}"
    cd ~/Documents/Kapsel_Projects/AppUpdateDemo
    cordova -d platform add ios
  • Add the AppUpdate plugin and optionally the logger plugin if you wish to view the messages logged by the AppUpdate plugin.  The log level is set to debug if sap.Logger is detected on line 12 of index.html.
    cordova -d plugin add com.sap.mp.cordova.plugins.appupdate
    cordova -d plugin add com.sap.mp.cordova.plugins.logger
    
  • Replace the contents of  C:\Kapsel_Projects\AppUpdateDemo\www\index.html with index.html.

    Note the application ID is specified in index.html as

    var appId = "com.mycompany.appupdate";
    

    The user and password values do not matter in this example as an OData endpoint is not being used.

  • Optionally modify the AppUpdateDemo\config.xml and add
    <preference name="hybridapprevision" value="1" />
    <preference name="sap-development-version" value="1.2.3" />

    Also update the description and email fields if desired.

    Due to a long delay on Android while assets are being copied during the first app update, it is recommended to either not specify hybridapprevision or use value=”0″.  When hybridapprevision is not present or set to 0, during the first client update, the client will request the server to send the complete contents of the www folder rather than just the files that changed between the revision that is reported on the client and the version on the server.

  • Copy the contents of the www folder to the platform specific www folder of the project using prepare.
    cordova -d prepare
  • Deploy the Kapsel app to the device or simulator using the Android IDE or Xcode.
  • In the All Output tab in Xcode or in Eclipse under the LogCat view, the debug output from the AppUpdate plugin can be seen.  Note that the LogCat view provides a feature to filter messages.  The filter shown below is based on the Tag SMP_APP_UPDATE.

    image8.PNG
    Notice above that when the app starts, the AppUpdate plugin checks with the SMP server to see if there is a newer version of the app.  The current version of the app is appRevision 1.  We have not yet deployed a version of the app to the server so a 404 error is returned.

  • The Kapsel command line interface (CLI) provides a way to generate a zip file that contains the HTML files that make up the app.  This zip file can then either be uploaded to the SMP 3.0 server using the Management Cockpit or it can be uploaded using the Kapsel command line interface.  Open a command prompt or shell to the folder
    C:\SAP\MobileSDK3\KapselSDK\cli
    
     ~/SAP/MobileSDK3/KapselSDK/cli

    Run

    npm install -g

    On a Mac it may be necessary to run

    sudo npm -g install

    See the section Installing Apache Cordova with Node.js for additional details on setting proxy settings if your company uses a proxy server.

    Change directories to the directory containing the project and run the below commands to generate a zip file containing the HTML files that make up the application and then upload the zip file to the SMP 3.0 server.

    kapsel package
    kapsel deploy com.mycompany.appupdate localhost:8083 smpAdmin s3pAdmin
    

    The package command can optionally take a platform such as android or iOS.  The parameters to the deploy command are the SMP 3.0 server host name, the app ID, the user id, and password for the SMP 3.0 server.  After running this command the Management Cockpit will show that revision 1 has been uploaded to the server.

    image5.PNG

    At this point the version of the application on the device is the same as the version on the server.

  • Update  C:\Kapsel_Projects\AppUpdateDemo\www\index.html and change the body’s background-color to some other color such as silver.
    <style type="text/css">  

    body {     background-color: silver;   } </style>
  • Copy the contents of the www folder to the platform specific www folder of the project using prepare.
    cordova -d prepare
    
  • Deploy a new version of app to the SMP 3.0 server.
    kapsel package
    kapsel deploy com.mycompany.appupdate localhost:8083 smpAdmin s3pAdmin

    image6.PNG

    Close and reopen the AppUpdateDemo app.

    image1.PNGimage2.PNG

    The debug output from the AppUpdate plugin shows that the client has revision 1 and the server has revision 2.  It also lists the changed files which in this case is index.html.
    image7.PNG

  • The www folder on the device or simulator is read only and cannot be updated directly, so the first app update causes the entire contents of the www folder to be copied to a new location causing the size of the deployed application to increase.
  • Note on Android the back button may not exit the app due to BCP issue 1472020039.
  • Note, rather than having the end user ok the update, the update can happen without the user being asked to ok it by overriding the sap.AppUpdate.onupdateready event.
    // Override default handler
    sap.AppUpdate.onupdateready = function(e) {
       // No notification just reload
       console.log("Apply update");
       sap.AppUpdate.reloadApp();
    }
    

    See comments in appupdate.js for further details.

  • Note, it is important to test the changes before publishing them to the server.  If an error is introduced, it could cause the application to break and potentially prevent future updates from being downloaded.  You can also validate your JavaScript with tools like JSLint, or JSHint.  CSS can be validated with CSS Lint.  If you encounter a problem after an update has occurred and you are using an iOS simulator, the contents of the update can be viewed at the following location.
    /Users/user_name/Library/Application Support/iPhone Simulator/6.1/Applications/xxxx-xxx-xxx-xxx-xxxxx/Documents/SMP/appupdate/app/www

    If using an Android emulator, the updated files can be viewed at the following location.

    data\data\com.mycompany.appupdate\files\download\www
    

    One technique to aid with this problem is to open an error page that can check for new updates if an error is detected.
    Replace the contents of  C:\Kapsel_Projects\AppUpdateDemo\www\index.html with index2.html and add error.html.
    Line 12 can be uncommented which makes a call to a non-existent JavaScript method.  The app that now has an error in it can be packaged and deployed to the SMP 3.0 server.  When the app is reopened, the newer version is uploaded and the error handler detects an error and redirects to the error page.
    image9.PNGimage10.PNG

    Correct the error, package and deploy the app.
    Now press check for updates and notice that app has recovered from the error.
    image2.PNG

Back to Getting Started With Kapsel

To report this post you need to login first.

56 Comments

You must be Logged on to comment or reply to a post.

  1. SIVA CHANDU

    Hi Daniel Van Leeuwen

     

    I am trying to use Kapsel command line interface in mac.

     

    I have run these commands in terminal

     

    ~/SAP/MobileSDK3/KapselSDK/cli

    sudo npm -g install

     

    Screen Shot 2014-05-09 at 12.58.22 PM.png

     

    and when i try Kapsel command it throws me

     

    -bash: Kapsel: command not found

     

    please suggest me how to solve it.

     

    Regrads

    Siva Chandu

    (0) 
    1. Daniel Van Leeuwen Post author

      I suppose I would start by checking to see if the kapsel cli was installed by entering

       

      npm ls -g kapsel

       

      For me that returns /usr/local/lib     kapsel@3.0.3

       

      Then try

       

      npm -g bin

       

      For me that returns /usr/local/bin

       

      Then try

       

      $PATH

       

      For me that returns

       

      /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:

       

      Note that /usr/local/bin is in my path

       

       

      ls /usr/local/bin

       

      For me that returns an alias to kapsel, cordova, and npm.

       

       

      Hope that helps,

       

      Dan van Leeuwen

      (0) 
      1. SIVA CHANDU

        Hi Daniel Van Leeuwen


        thanks for the response


        i have used this command npm -ls -g kapsel but not getting any result,


        and after i have checked with this ” npm -g bin ” it has given this output

         

        $ npm -g bin

        /Applications/Titanium Studio/TitaniumStudio.app/Contents/MacOS/Password:/usr/local/bin

        (not in PATH env variable)

        $_

         

        and i have added the same path in env variable, the path has set successfully and then tried again , but no use i cannot run kapsel command.

         

        regards

        Siva Chandu

        (0) 
          1. SIVA CHANDU

            Hi Daniel Van Leeuwen


            thanks for the response


            I have tried the same

             

            Screen Shot 2014-05-13 at 5.56.27 PM.png

             

            i worked around to set the path

             

            Screen Shot 2014-05-13 at 5.53.59 PM.png

             

            i dont know why my path is showing from application -> Titanum Studio->….

             

            please suggest me in this.

            (0) 
            1. Daniel Van Leeuwen Post author

              One workaround would be to install the kapsel cli locally rather than globally.

               

              To do so, go to the folder where you wish to call the kapsel cli from and type

               

              npm install ~/SAP/MobileSDK3/KapselSDK/cli

               

              I believe you will then be able to use the kapsel cli when you are in that directory.

              (0) 
    1. Daniel Van Leeuwen Post author

      Are you using the version that is described here?  It is also know as the SMP Server Cloud Version

       

      http://scn.sap.com/docs/DOC-54719

       

      Note, that it does not support the AppUpdate plugin.

       

      The newer SAP HANA Cloud Platform mobile services(HCPms) does.

       

      The management cockpit for it looks very different as it uses the SAP Fiori style of UI.

      (0) 
  2. billy shen

    Hi Daniel Van Leeuwen

        when deploy the app, i got a 403 message. however i am sure my username and password for smp is correct. because i can use it to logon the https://10.150.135.226:8083/Admin/

    in index.html i changed the  “serverHost”: “10.150.135.226”,

    my SMP server is version 3.0.7.0 SP Level:07.

    below is the screenshot for the 403 message.

    E5FD1C25-0426-4874-B5E3-357872061653.png

       what should i do to fix it ? and i used the same way to deploy another server which has a low level sp03, it works.

    thanks,

    Billy

    (0) 
    1. Daniel Van Leeuwen Post author

      What version is your SMP SDK?  I believe there were some security enhancements made to the SMP server in SP07.   I would recommend using the latest SP08 SDK with it.

       

      To see the version of you SDK open a plugin.xml file such as

      C:\SAP\MobileSDK3\KapselSDK\plugins\apppreferences\plugin.xml

       

      It should say

       

      <?xml version=”1.0″ encoding=”UTF-8″?>

      <plugin xmlns=”http://apache.org/cordova/ns/plugins/1.0

          id=”com.sap.mp.cordova.plugins.apppreferences”

          version=”3.8.1″>

       

      Hope that helps,

       

      Dan van Leeuwen

      (0) 
        1. Daniel Van Leeuwen Post author

          Perhaps the kapsel cli was not updated?

           

          The version number can be checked by running kapsel -v

           

          That should return 3.8.1.

           

          If it returns an older version, it can be updated by

           

          ~/SAP/MobileSDK3/KapselSDK/cliRun

          npm install -g

          On a Mac it may be necessary to run

          sudo npm -g install

           

          Hope that helps,

           

          Dan van Leeuwen

          (0) 
  3. Tim Sheppard

    I can create the packaged zip file okay, but when I try to deploy it to my SMP server it first acts like it’s going to work by displaying a status percentage value (the value increments from 0% to 100% in about five seconds), but then it throws the error:

     

    ERROR: Server returned status code 500

    Failed to upload Kapsel App for application

     

    SyntaxError: Unexpected token F

     

    My deploy command is:

    $ kapsel deploy my.app.name myserver:8085 smpAdmin smpAdmin

     

    I’ve checked my SMP server and it’s up and running with no apparent problems.  My SMP server is at version 3.0.8.3.  Any idea what the problem might be?  This is the first time I’ve tried doing a package/deploy.

    (0) 
    1. Daniel Van Leeuwen Post author

      I would confirm the version of Kapsel that you are using by typing kapsel -v

       

      Note, that you need to install the Kapsel CLI manually as mentioned in this doc.

       

      npm install -g 

       

      Does your network use a proxy?  If so, perhaps try setting the following environment variable.

       

      set no_proxy=myserver

       

      I assume that you have configured your SMP server to use port 8085 rather than 8083 as the management port?

       

      If the above does not help, try getting the latest PL for the I guess for SP07 since you are using an SP08 SMP server.

       

      Software Downloads | SAP Support Portal

       

      Hope that helps,

       

      Dan van Leeuwen

      (0) 
      1. Tim Sheppard

        Thanks for the quick response. 

        I’m on Kapsel version 3.9.3.

        The Kapsel CLI install went okay no problems there, I can do the package command with no problems.

        We don’t have a proxy server.

        I’m somewhat new to SMP, but I think the management port would be set in SMP Cockpit under Settings | Connectors | HTTPS Admin Connector, is that correct?  That is set to 8085.  I tried also using ports 8080 through 8084, but each of them either threw errors or simply hung and I had to cntrl-c out of the command.

        I’m not sure I understand your comment about getting the latest PL for SP07 since my SMP server is at SP08.  Wouldn’t I want to get the latest PL for SP08?

         

        Another point to note is that my SMP server OS is Win 2008 R2 Standard SP1.

         

        I also tried copying the zip file created by the package command to the SMP server and manually uploading it using Applications | App Specific Settings | New Upload.  When I try that it returns an alert box that says “File Upload Complete” with a green checkmark on it.  However I never see the revision information on the screen.  Am I doing something wrong?

         

        Thanks very much!

        Tim Sheppard

        (0) 
        1. Daniel Van Leeuwen Post author

          One other thing to check would be the id of app.  Is it my.app.name?


          <<I’m not sure I understand your comment about getting the latest PL for SP07 since my SMP server is at SP08.


          The SMP server and the SDK are not on the same release schedule.  SP07 of the server matches SP08 of the SDK. 


          For the current release SP09 of the server matches SP10 of the SDK.


          Generally a specific version of the SMP server is tested with a version of the SDK.


          I have also seen the management cockpit either take a long time with no visible busy notification before the screen refreshes after uploading a zip file.  You might need to click on another tab in the management cockpit and come back to see the result of the upload.


          Note, that the screenshots taken for this guide were against the SP09 server.  I believe the UI changed slightly.


          Regards,


          Dan van Leeuwen



          (0) 
          1. Tim Sheppard

            The app id in my deploy command is dom.energy.kapsel.proficyMobile.  This matches the app id in SMP cockpit.

             

            Can you tell me how to find the version of  the SDK?  Is there a published cross-reference between SMP version and compatible SDK version?

             

            To try to get the revision info to show up in App Specific Settings I’ve tried going to a different tab, and even restarting the server, but no luck.  I’ve tried uploading the zip file several times and each time it tells me “File upload complete”, but still no revision info is displayed.

             

            Just to see if the revision actually was uploaded successfully, after logging in, I tried running sap.AppUpdate.update() from my mobile app.  But the only thing it did was called my “checking” event handler once, and then I received no other call backs.

             

            Thanks very much I appreciate the help

            Tim Sheppard

            (0) 
            1. Daniel Van Leeuwen Post author

              You can get a sense of what versions go with what by looking at the release dates of the server version and SDK on this page.

              Getting Started with Kapsel – Appendix G — New Features

              and

              Getting Started with Kapsel – Appendix G — New Features (SP09+)

               

              Generally though the latest version of this guide mentions what version of the server and SDK should be used when following the examples in it.

               

              Getting Started with Kapsel – Part 1 (SP09+)

               

              The version of the SDK can be determined by examining the plugin.xml from any of the Kapsel plugins.

               

              kapsel -v should also tell you but you would have first had to install the kapsel cli.

               

              I am a bit stumped as to why when you upload the log to the SMP management cockpit using the management cockpit it does not appear as a new revision.

               

              Are there any errors in the SMP server log?

               

              If you examine your zip file, what does the file structure look like?

               

              Mine shows

               

              android

                 config.xml

                 www

              ios

                 config.xml

                 www

               

              Regards,

               

              Dan van Leeuwen

              (0) 
              1. Diego Valencia

                Hi guys,

                same error here.  Any update on this?

                I’m getting the same error as Tim in the command prompt and this in the SMP error log, of course, my app id exist.

                 

                #2.0#2015-10-21 08:50:44 AM#ERROR#Hybrid###Admin#1445381444625002#22f0e7b3-df70-4ac8-ac52-41c9541f26a7#com.xxx.appupdate#com.sap.mobile.platform.server.admin.kapsel.jaxrs.KapselAppSvc:uploadKapselApp#smpAdmin#######677#####Failed to upload Kapsel App for application id com.xxx.appupdate#

                #2.0#2015-10-21 08:50:44 AM#WARNING#Hybrid###Hybrid Application Management#1445381444625001#22f0e7b3-df70-4ac8-ac52-41c9541f26a7#com.xxx.appupdate#com.sap.mobile.platform.server.lcmservices.webapps.admin.service.impl.AppServiceImpl:create#smpAdmin#######677#####The specified application ID (com.xxx.appupdate) does not exist or is not for a valid application type.#



                SMP 3 SP 09

                Kapsel 3.10.1

                (0) 
                1. Tim Sheppard

                  I was able to get the app’s packaged zip file to deploy to the SMP server by copying the source code from my development Mac to my SMP server and doing the package/deploy directly there.  I changed the deploy command to:

                   

                  $ kapsel deploy my.app.name localhost:8085 smpAdmin smpAdmin

                   

                  So now when I call sap.AppUpdate.update() from my mobile code it recognizes that an update is available.  Thanks for your help on this Dan.

                  (0) 
                  1. Tim Sheppard

                    Dan,  Even though I was able to get the sap.AppUpdate.update() function to recognize that a new revision is available, when I try to run sap.AppUpdate.reloadApp() it does not bring down the revision properly but instead throws an error and seems to corrupt the installation.  The error that is thrown is:

                    TypeError: null is not an object (evaluating ‘parentElement.querySelector’)

                         receivedEvent index.js:40

                         onDeviceReady index.js:35

                         fire Cordova.js:770

                         (anonymous function) Cordova.js:223

                     

                    This error occurs when I specifically execute reloadApp() from my code, and also when I select the ‘Reload App Now’ button on the ‘Update Available’ prompt after login.  Do you know what the problem might be?  Thank you!

                     

                    Tim Sheppard

                    (0) 
  4. Srinivas Divakarla

    Hi,

     

    If I have to manually do the package, what are all the files under the corodva project i need to compress and upload for some internall issues I will not be able to use CLI for Kapsel

    to run

    kapsel package and kapsel deploy.

     

    Regards,

    Srinivas Divakarla

    (0) 
    1. Daniel Van Leeuwen Post author

      It would be similar to the structure mentioned above.  The www folder though is the platform specific version of the www folder.  So it would be the one under project_name/platforms/android/assets/www for example.

       

      Hope that helps,

       

      Dan van Leeuwen

      (0) 
  5. Tim Sheppard

    I’m able to deploy a revision of my application in SMP cockpit, and the sap.AppUpdate.update() function does recognize that a revision is available (it fires the ‘onupdateready’ function). However when I try to use sap.AppUpdate.reloadApp() to bring the revision down to the mobile device it does not work.  It throws the following error:

     

    TypeError: null is not an object (evaluating ‘parentElement.querySelector’)

         receivedEvent index.js:40

         onDeviceReady index.js:35

         fire Cordova.js:770

         (anonymous function) Cordova.js:223

     

    This is my code that fires when an update is available:

     

    sap.AppUpdate.onupdateready = function() {

         sap.AppUpdate.reloadApp();

    }

     

    Is there something I’m missing?  Thank you

    Tim Sheppard

    (0) 
    1. Daniel Van Leeuwen Post author

      I assume you have added the logger plugin and have the code to set the log level to debug to your html/JavaScript?

       

      sap.Logger.setLogLevel(sap.Logger.DEBUG);

       

      Does the android logcat or Xcode all output show anything that may indicate the problem?

       

      Have you increased the SMP server log level? 

      I assume the relavent component is named

      Hybrid Application Management

      and checked the SAP server log?

       

      Are you using Android or iOS?  What version?  What is the version of your SMP server and SDK?

       

      Regards,

       

      Dan van Leeuwen

      (0) 
        1. Tim Sheppard

          Dan, Do I need to upgrade to SMP SDK sp10 (and SMP server sp9) to be able to use the appupdate plugin on an iOS 9 device?

           

          Thanks

          Tim Sheppard

          (0) 
          1. Daniel Van Leeuwen Post author

            That is a good idea in general to move to the latest SP and PL.  That might explain the problem although I am not aware of any specific issues.

             

            Did the logs turn up anything useful?

            (0) 
            1. Tim Sheppard

              No I haven’t found anything in the logs yet that tell me what the problem is.  I’m upgrading to SDK sp10 and server sp9 and hoping that will resolve it.

              Thanks

              (0) 
              1. Tim Sheppard

                Dan,  After doing the SDK and SMP server upgrades I was still having the problem.  I eventually realized that my problem was that I wasn’t doing a ‘cordova prepare’ command before doing the ‘kapsel package’ command.  So my package command was packaging up a very old version of the application.  So reloadApp() was actually loading up the packaged version of the app, but the packaged version was so old I had thought my app was getting corrupted.

                 

                So after doing ‘prepare’ and ‘package’ I’m now getting an error when I try to do the ‘deploy’ command.  I wasn’t getting an error with the deploy command before the SDK and server upgrades so I’m assuming it has something to do with the upgrades.  The error I’m getting on the deploy is:

                 

                ERROR: Server returned status code: 400

                {“errorCode”:”KAPSEL_APP_ARCHIVE_APPLICATION_CONTENT_VALIDATION_FAIL”}

                Error message: undefined

                 

                I get a similar error when I try to do the deploy within SMP cockpit.

                 

                I’ve looked at the zip file generated from the package command and I don’t see anything obvious missing from it for the iOS platform.

                 

                I’m now on versions:

                Device: iOS 9.1

                SMP server: 3.0.9.3

                SMP SDK: 3.0.10.3

                 

                Just to see if it would help I removed all of my kapsel plugins and then readded them but I’m still getting the error.

                 

                Thank you,

                Tim Sheppard

                (0) 
                1. Tim Sheppard

                  Here’s some more information about my deploy error.  I found a packaged zip file that I’d created prior to my SDK and server upgrades.  I tried to deploy it and it worked.  Here’s a comparison of the folder structure of the zip files:

                   

                  Pre-upgrade zip file (deploy does work):

                  www

                       cordova-js-src

                       css

                       fonts

                       img

                       js

                   

                  Post-upgrade zip file (deploy doesn’t work):

                  www

                       css

                       fonts

                       img

                       js

                       plugins

                   

                  You can see there are some differences between the two which I’m assuming are due to differences in the SDK versions 3.0.9.2  and 3.0.10.3.

                   

                  Thanks

                  Tim Sheppard

                  (0) 
                  1. Midhun VP

                    Hi Tim,

                     

                    Is your SMP server upgraded from SP05 or SP06?

                    If yes, please follow these the below steps:

                     

                    Delete the app from SMP admin cockpit and reconfigure it.

                     

                    Use kapsel cli and upload the package as mentioned in the blog.

                    /wp-content/uploads/2015/11/2015_11_09_08_47_14_827233.png

                     

                    Regards, Midhun

                    SAP Technology RIG

                    (0) 
                    1. Tim Sheppard

                      Midhun,

                      I upgraded SMP server from 3.0.8.3 to 3.0.9.3.  But I went ahead and tried your suggestion anyway and deleted my app from SMP cockpit and then readded it.  I then did another prepare/package/deploy and I’m still getting the same error on the deploy.

                       

                      One thing to note:  when I did the SMP server upgrade, I upgraded to 3.0.9.0 and then upgraded straight to 3.0.9.3 (did not do the PL1 and PL2 upgrades).  On my SMP SDK upgrade I upgraded from 3.0.9.2 to 3.0.10.0 and then upgraded to 3.0.10.3 (again did not do the PL1 and PL2 upgrades).  Do you think not doing the intermediate upgrades would be causing any problems?

                      Thank you

                      Tim Sheppard

                      (0) 
  6. Tim Sheppard

    Dan or Midhun,

    Do you have any other suggestions on the problem I’m having with the deploy command after I upgraded to SMP server 3.0.9.3 and SDK 3.0.10.3?  Do you think this will require an SMP server patch?

    Thanks very much for your help as I am almost finished with my app and am required to roll it out soon.  Everything else with Kapsel has gone very well up to this point.

     

    Thank you,

    Tim Sheppard

    (0) 
    1. Daniel Van Leeuwen Post author

      Have you tried following the example in the guide?  Does that example work for you in your environment?  It might help to isolate your problem and if we both use the same example we could perhaps exchange zip files.

       

      After you upgraded the SDK did you update the Kapsel CLI?  Note this does not get updated by the install.

       

      To see what version you are currently using type

       

      kapsel -version

       

      Regards,

      Dan van Leeuwen

      (0) 
      1. Tim Sheppard

        Dan,

        No I did not do an update to the Kapsel CLI after the SDK upgrade, so I updated it now.  I was on Kapsel CLI ver 3.9.3.  Now after updating it I’m at 3.10.2.  I then tried a prepare/package/deploy and I received the same error on the deploy.

         

        Also after upgrading my Kapsel CLI to 3.10.2, I worked through the app update example in this guide and it worked.  The deploy command worked fine with the example app.

         

        Next I went back and removed the iOS platform for my app that’s getting the deploy error and then added it back hoping this would clear up the problem.  However after another prepare/package/deploy I’m still getting the error on the deploy.

         

        All of the other plugins are working fine with this app.  I can run on the iOS simulator or an attached device via Xcode with no problem.  I can build the ipa file and distribute it and it works fine.

         

        I’m now on versions:

        Device: iOS 9.1

        SMP server: 3.0.9.3

        SMP SDK: 3.0.10.3

        Kapsel CLI: 3.10.2

        Cordova CLI: 5.2.0

         

        Thanks,

        Tim Sheppard

        (0) 
        1. Daniel Van Leeuwen Post author

          Can you share the zip file?  Perhaps send me a private message with a link to where I can take a quick look at it.

           

          Another option would be to open a support case.

           

          Regards,

          Dan van Leeuwen

          (0) 
          1. Tim Sheppard

            Since the AppUpdateDemo example app from this guide worked for me, I decided to start copying my app’s code and config settings over to it to see if I could get it to throw the same deploy error.  I found that what is causing the problem is the <icon> element in config.xml.  When I copied my app’s <icon> element over to AppUpdateDemo’s config.xml then it also started giving the same error on the deploy command.  Below is the contents of config.xml with the icon element at the bottom.  The app icon specified does exist.

             

            If I remove the icon element then the deploy command works fine.  When I add it back in then deploy throws the error.  I’ve also tried referencing the stock Cordova icon in the <icon> element and that also throws the deploy error.  It seems anytime I include the <icon> element in config.xml is when the problem occurs.

             

            Can you see anything I’m doing wrong on my side?

            Thanks

            Tim Sheppard

             

             

            /wp-content/uploads/2015/11/config_xml_830359.png

            (0) 
            1. Daniel Van Leeuwen Post author

              As a workaround, perhaps you could update the default icons (the ones provided by the base Cordova template project) with your custom icons rather than specifying the icon tag in the config.xml file?

               

              I am glad you found the problem.

               

              Dan van Leeuwen

              (0) 
              1. Tim Sheppard

                Are the default icons located in /platforms/ios/appname/Resources/icons/ ?  This is where I find them when I create a new project and then add the ios platform to it.

                 

                Assuming that’s where the default icons are located I replaced them with my custom icons and it’s not throwing the deploy error now.

                 

                Hopefully that will work around the issue.  Do you think this is a bug in SDK 3.0.10.3?

                Thanks very much for your help I appreciate it!

                Tim Sheppard

                (0) 
                1. Daniel Van Leeuwen Post author

                  Yes, I believe it is a bug the SMP server in that it should not be checking for the existence of the icon in the location specified in the packagedKapselApp.zip file during the upload.  I have created a bug report for the development team to investigate this issue further.

                   

                  That file only contains the HTML/JavaScript type resources and not icon files for your application.  I don’t believe you would be able to update the apps icon file via the AppUpdate plugin.

                   

                  Regards,

                   

                  Dan van Leeuwen

                  (0) 
  7. Tim Sheppard

    Dan,

    Now that I’m able to deploy a revision to SMP (thanks again for your help on that!) I’m trying to code the process to bring down a new revision.  My app works in off-line mode most of the time and attempts to make a connection to the SMP server when the user performs a “transmit” to the backend.  It’s at the end of the transmit that I’d like to check to see if a new revision is available.  My thought was that I would just call AppUpdate.update() at the end of the transmit, and if a revision is available then the user would be prompted with the “Later/Relaunch App” dialog.  This seems to work the first time I call update() after the user logs in, however if the user stays logged in and I deploy another new revision then the next time the app calls update() the new revision is not recognized.  Do you have to make the user re-login each time you want to call update() to check for a revision?  It doesn’t say this in the AppUpdate API reference, however that seems to be the behavior I’m seeing.

     

    Also, what is the best way to retrieve the current app version number (the one specified in config.xml) so that it can be displayed to the user?

     

    Thanks again,

    Tim Sheppard

    (0) 
    1. Daniel Van Leeuwen Post author

      I would recommend adding the Kapsel Logger plugin to your app and adding the following code to the deviceready event.

       

      if (sap.Logger)

      {

                          sap.Logger.setLogLevel(sap.Logger.DEBUG);

                          sap.Logger.debug(“Log level set to DEBUG”);

      }

       

      On Android you can then open up the monitor.bat tool and create a log filter for SMP_APP_UPDATE (or examine the all output tab in Xcode.

       

      That should provide you many more details including the revision on the client and the revision on the server.

       

      If you come across a scenario that is not working as expected, let me know how to reproduce it and I can give it a try.

       

      Regards,

       

      Dan van Leeuwen

      (0) 
      1. Tim Sheppard

        I’ve tried using the logger, but I’m not seeing much information in the all output tab in Xcode.  I don’t see the revision numbers.

         

        I’ve found that when I want to check for a revision I can get the “Later/Relaunch Now” box to pop up if I first execute sap.Logon.init() and then right after that run sap.AppUpdate.upate().  Then when I tap ‘Relaunch Now’ it brings down the new revision except for one problem – it only brings down the changes for the page that’s currently displayed.  It doesn’t consistently bring down the changes to the other pages (on rare occasions it does bring them down, but not often). 

         

        I have a feeling I’m not using the plugin functions properly, however I saw in the demo app how this might work.

         

        Thanks

        Tim Sheppard

        (0) 
  8. Tim Sheppard

    Dan,

    I tried going back and just simply calling sap.AppUpdate.update() by itself to check for a new version.  It seems as though the first time I call this function it recognizes the new revision and brings up the “Later/Relaunch Now” prompt.  However, if I choose “Later” on this first prompt then subsequent calls to update() do not bring up the prompt again.  Shouldn’t each call to update() check for a new version and give the prompt?   Nothing comes up in the All Output pane to lead me to what the problem is. I’m thinking that this may be another bug in 3.0.9.3 SMP server.  Currently I’m at SMP server 3.0.9.3 and SDK 3.0.10.3.   I’m thinking about downgrading back to SMP server 3.0.8.x and SDK 3.0.9.x.  Is this feasible and if so, would be accomplished by simply re-installing those versions?

    Thank you

    Tim Sheppard

    (0) 
    1. Daniel Van Leeuwen Post author

      You should be able to downgrade as you mentioned above but I don’t imagine that will help.

      I tried the sample provided in this section of the guide on Android and iOS with the addition of a button that calls sap.AppUpdate.update().

       

      I was able to call it and see the Later/Relaunch Now prompt.  Clicking later and then calling sap.AppUpdate.update() worked the second time it was called.  I am using SP09 of the SMP server and SP10 PL04 of the SDK but I don’t imagine the version is the issue.

       

       

       

      Regarding the output in the All Output window, I was able to see relevant output to the appupdate plugin such as

      Checking for update

      Update ready

      Confirming application update

       

      Those message are being logged by the sample application included in this guide.

       

      Perhaps you could try the sample and see if you are getting a different behavior.

       

      One other suggestion would be to try it on Android.  Sometimes on a different platform the problem either doesn’t occur or presents a different error message that may help identify the problem.

       

      Regards,

       

      Dan van Leeuwen

      (0) 
      1. Tim Sheppard

        Dan,  I’ve narrowed the problems I was seeing down to the fact that when you perform a revision update the Javascript files in the /js folder are not all getting consistently updated.  The JS files that are referenced by the current page being displayed at the time of the update are getting updated, but not the other JS files in the app. 

         

        I duplicated this problem in the AppUpdate demo app by adding a second page to the app and also adding a JS file for each page.  When I perform an update while on page 1, the JS file being used by page 2 does not always get updated.  And when I perform an update while on page 2, the JS file being used by page 1 does not always get updated.

         

        The problem does not occur with the HTML files, those all get updated fine.  So I was able to work around the problem in the demo app by embedding the Javascript function that I was calling into the HTML page instead of referencing it from a file in the /js folder.  I can possibly work around the problem the same way in the app I’m developing, however the amount of Javascript I’d have to embed within HTML is rather large.

         

        Thanks

        Tim Sheppard

        (0) 
        1. Tim Sheppard

          I Was able to work around the problem for now by embedding all of my JavaScript with the HTML pages.  This appears to be a bug?  I’m using Sap server 3.0.9 3 and sdk 3.0.10.3.

           

          THanks

          TIm Sheppard

          (0) 
  9. Kousik Goon

    Dan, When I have done this activity using your example which is 1 page app then its working fine. When I applied it in my hybrid app , then I can see below …

     

    1. Applied appupdate coding and not uplaoded .zip file in HCPms , things are working fine and I can see all required console.log properly (like : no update etc) ..

     

    2. I uploaded .zip file to server , do to see it at all through getting message that file uploaded .

     

    3. When again run the app, its going to error now and saying

    “Error downloading update. statusCode: 200 statusMessage: Value <html><head><meta of type java.lang.String cannot be converted to JSONObject”

     

    Any idea about this error please.

    (0) 

Leave a Reply