Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vipera-npm-registry / de-doc-generator   js

Repository URL to install this package:

Version: 1.0.0 

/ htdocs / de_plugins / deassetmanager_plugin.html

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
    <title>Asset Manager Plugin Configuration Parameters</title>
    <link type="text/css" rel="stylesheet" href="../assets/css/github-markdown.css">
    <link type="text/css" rel="stylesheet" href="../assets/css/pilcrow.css">
    <link type="text/css" rel="stylesheet" href="../assets/css/hljs-github.min.css"/>
  </head>
  <body>
    <article class="markdown-body"><h3 id="asset-manager-plugin-configuration-parameters"><a class="header-link" href="#asset-manager-plugin-configuration-parameters"></a>Asset Manager Plugin Configuration Parameters</h3>
<p>This plugin allow hybrid application content update (motif asset bundle update)</p>
<h1 id="configuration-preferences"><a class="header-link" href="#configuration-preferences"></a>Configuration preferences</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Default</th>
<th>Platform</th>
<th>Mandatory</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>assetManager.enabled</td>
<td>true</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable the asset manager</td>
</tr>
<tr>
<td>assetManager.remoteUpdate</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable the remote assets update</td>
</tr>
<tr>
<td>assetManager.serverUrl</td>
<td>null</td>
<td>Android/iOS</td>
<td>Y</td>
<td>Asset manager url</td>
</tr>
<tr>
<td>assetManager.requestPath</td>
<td><code>/json</code></td>
<td>iOS</td>
<td>No</td>
<td>The server request entry point (default:&#39;/json&#39;)</td>
</tr>
<tr>
<td>assetManager.httpTimeout</td>
<td>30000</td>
<td>Android/iOS</td>
<td>N</td>
<td>http connection timeout (ms)</td>
</tr>
<tr>
<td>assetManager.retryCount</td>
<td>1</td>
<td>Android/iOS</td>
<td>N</td>
<td>max num of retry</td>
</tr>
<tr>
<td>assetManager.end2EndEncryption</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable secure protocol encryption</td>
</tr>
<tr>
<td>assetManager.embeddedAssetsVersion</td>
<td>0.0.1</td>
<td>Android/iOS</td>
<td>N</td>
<td>Version of embedded assets (example:  &#39;1.0.0&#39;)</td>
</tr>
<tr>
<td>assetManager.assetName</td>
<td>null</td>
<td>Android/iOS</td>
<td>Y</td>
<td>assets name (see motif doc)</td>
</tr>
<tr>
<td>assetManager.engineName</td>
<td>null</td>
<td>Android/iOS</td>
<td>Y</td>
<td>engine name (see motif doc)</td>
</tr>
<tr>
<td>assetManager.multiAsset</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable multi assets (tablet support)</td>
</tr>
<tr>
<td>assetManager.showDefaultUI</td>
<td>true</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable or disable the default spinner and progress UI</td>
</tr>
<tr>
<td>assetManager.showProgress</td>
<td>true</td>
<td>Android/iOS</td>
<td>N</td>
<td>show a progress dialog in assets update</td>
</tr>
<tr>
<td>assetManager.showProgressMessage</td>
<td>Please wait</td>
<td>Android/iOS</td>
<td>N</td>
<td>dialog message</td>
</tr>
<tr>
<td>assetManager.showProgressTitle</td>
<td>Assets Update</td>
<td>Android/iOS</td>
<td>N</td>
<td>dialog title</td>
</tr>
<tr>
<td>assetManager.checkAssetIntegrity</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable assets integrity check</td>
</tr>
<tr>
<td>assetManager.debugAssetIntegrity</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable this flag in debug phase</td>
</tr>
<tr>
<td>assetManager.embeddedDigest</td>
<td>&quot;&quot;</td>
<td>Android/iOS</td>
<td>N</td>
<td>digest value of embedded assets</td>
</tr>
<tr>
<td>assetManager.assetsEncryption</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable assets encryption</td>
</tr>
<tr>
<td>assetManager.assetsEncryption.integrityCheck</td>
<td>false</td>
<td>Android/iOS</td>
<td>N</td>
<td>enable assets integrity check (requires Asset Encryption)</td>
</tr>
</tbody>
</table>
<h1 id="javascript-api"><a class="header-link" href="#javascript-api"></a>Javascript API</h1>
<p>clobber:  DynamicEngine.plugins.DEAssetsManager</p>
<p><strong><em>getAssetsInfo(successFn,errorFn)</em></strong>
return a JSON object with the following info:</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>assetsBasePath</td>
<td>the base assets path ( deployed or embedded)</td>
</tr>
<tr>
<td>assetsManagerAssetsName</td>
<td>the assets name value</td>
</tr>
<tr>
<td>assetsManagerEngineName</td>
<td>the engine name value</td>
</tr>
<tr>
<td>assetsManagerUrl</td>
<td>url of assets manager</td>
</tr>
<tr>
<td>currentAssetsVersion</td>
<td>the current assets version</td>
</tr>
<tr>
<td>embeddedAssetsVersion</td>
<td>the embedded assets version</td>
</tr>
<tr>
<td>engineVersion</td>
<td>the engine version (aka appVersion)</td>
</tr>
</tbody>
</table>
<h1 id="android"><a class="header-link" href="#android"></a>Android</h1>
<p>For support assets update, de-assetmanager-plugin provide an installer class that you could use in your <strong><em>MainActivity</em></strong>. For provide the default platform ui in asset update process you can use a DefaultAssetsInstallerListener:  </p>
<pre class="hljs"><code>public <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">CordovaActivity</span> </span>{
    <span class="hljs-meta">@Override</span>
    public void onCreate(<span class="hljs-type">Bundle</span> savedInstanceState)
    {
        <span class="hljs-keyword">super</span>.onCreate(savedInstanceState);
        ....
        <span class="hljs-comment">//init plugins</span>
        init();
        <span class="hljs-comment">// This class provide the default UI implementation</span>
        <span class="hljs-type">DefaultAssetsInstallerListener</span> listener=<span class="hljs-keyword">new</span> <span class="hljs-type">DefaultAssetsInstallerListener</span>(<span class="hljs-keyword">this</span>,<span class="hljs-keyword">this</span>.preferences) {
            <span class="hljs-meta">@Override</span>
            public void startApp() {
                launchUrl = <span class="hljs-type">DEEnvironment</span>.getAssetBasePath(getApplicationContext()) + <span class="hljs-string">"/index.html"</span>;
                <span class="hljs-type">Log</span>.i(<span class="hljs-string">"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"</span>, launchUrl);
                loadUrl(launchUrl);
            }
        };
        <span class="hljs-type">AssetsInstaller</span> installer=<span class="hljs-keyword">new</span> <span class="hljs-type">AssetsInstaller</span>();
        installer.installWithExecutor(listener,<span class="hljs-keyword">this</span>,preferences,cordovaInterface.getThreadPool());
    }
}</code></pre><p>if you want to customize single parts of the UI (for example provide a different progress indicator), you can extends DefaultAssetsInstallerListener and override one of the following methods:</p>
<pre class="hljs"><code><span class="hljs-function"><span class="hljs-keyword">protected</span> AssetsDownloadProgressHandler <span class="hljs-title">makeProgressHandler</span><span class="hljs-params">()</span> </span>{
    ...
}

<span class="hljs-function"><span class="hljs-keyword">protected</span> AppUpdateUIHandler <span class="hljs-title">makeMainProcessIndicator</span><span class="hljs-params">()</span></span>{
    ...
}


<span class="hljs-function"><span class="hljs-keyword">protected</span> AppUpdateUIHandler <span class="hljs-title">makeNeedsAppUpdateUIHandler</span><span class="hljs-params">(DEAppCheckResult deAppCheckResult, DEAssetManagerDelegate.AppUpdateHandler appUpdateHandler)</span> </span>{
    ...
}

<span class="hljs-function"><span class="hljs-keyword">protected</span> AppUpdateUIHandler <span class="hljs-title">makeForceAppUpdateUIHandler</span><span class="hljs-params">(DEAppCheckResult deAppCheckResult)</span> </span>{
    ...
}</code></pre><p>For more complex implementation/integration, you can provide a custom implementation of AssetsInstallerListener</p>
<pre class="hljs"><code><span class="hljs-keyword">interface</span> <span class="hljs-title">AssetsInstallerListener</span> {
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onStart</span>(<span class="hljs-params"></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onAssetsDownloadBegin</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> numOfFile</span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onAssetsDownloadProgress</span>(<span class="hljs-params">DownloadProgressInfo downloadProgressInfo</span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onAssetsDownlaodSuccess</span>(<span class="hljs-params"></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onAssetsDownlaodFail</span>(<span class="hljs-params"></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onForceAppUpdate</span>(<span class="hljs-params">DEAppCheckResult deAppCheckResult</span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">needsAppUpdate</span>(<span class="hljs-params">DEAppCheckResult deAppCheckResult, DEAssetManagerDelegate.AppUpdateHandler appUpdateHandler</span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">onCompleted</span>(<span class="hljs-params"></span>)</span>;
}</code></pre><p>in <strong><em>onCompleted</em></strong> call loadUrl(...) for starting hybrid assets loading</p>
<pre class="hljs"><code>launchUrl = DEEnvironment.getAssetBasePath(getApplicationContext()) + <span class="hljs-string">"/index.html"</span><span class="hljs-comment">;</span>
loadUrl(launchUrl)<span class="hljs-comment">;</span></code></pre><h1 id="ios"><a class="header-link" href="#ios"></a>iOS</h1>
<p>To use the default implementation of the Asset Update plugin in your iOS project you don&#39;t need to make any changes on your native sources due to the implementation of a CDVViewController category (&quot;<strong>CDVViewController+AssetManager.h</strong>&quot;).</p>
<p>But if you want to customize something you can use this guidelines below.</p>
<h3 id="customizing-ios-asset-update-process"><a class="header-link" href="#customizing-ios-asset-update-process"></a>Customizing iOS Asset Update process</h3>
<p>To use the Asset Update plugin in a iOS project you need to make some changes on your native sources.</p>
<p>The first step is to add these lines on top of Main view controller (usually MainViewController.m) source code:</p>
<pre class="hljs"><code><span class="hljs-class"><span class="hljs-keyword">@interface</span> <span class="hljs-title">CDVViewController</span>()</span>
- (<span class="hljs-built_in">NSURL</span>*)appUrl;
<span class="hljs-keyword">@end</span></code></pre><p>Then you need to override the <strong>viewDidLoad</strong> method into your main view controller (usually MainViewController) and call only the AssetManager startUpdateWithDelegate:</p>
<pre class="hljs"><code><span class="hljs-selector-tag">-</span> (void)<span class="hljs-selector-tag">viewDidLoad</span>
{
    <span class="hljs-selector-attr">[[AssetManager sharedInstance]</span> <span class="hljs-selector-tag">startUpdateWithDelegate</span><span class="hljs-selector-pseudo">:self</span>];
}</code></pre><p>You need to implements (or override if exists) into the main view controller the method appUrl in this way:</p>
<pre class="hljs"><code>- (NSURL*)appUrl
{
    <span class="hljs-keyword">if</span> ([[AssetManager sharedInstance]enabled]){
        <span class="hljs-keyword">return</span> [[AssetManager sharedInstance]appUrl];
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">return</span> [<span class="hljs-keyword">super</span> appUrl];
    }
}</code></pre><p>Then you need to implement the <strong>DEAssetsManagerDelegate</strong> protocol in your main view controller:</p>
<p>MainViewController.h :</p>
<pre class="hljs"><code>@<span class="hljs-keyword">interface</span> MainViewController : <span class="hljs-type">CDVViewController</span>&lt;DEAssetManagerDelegate&gt;</code></pre><p>MainViewController.m :</p>
<pre class="hljs"><code>- (<span class="hljs-keyword">void</span>)assetUpdateStarted
{
    <span class="hljs-built_in">NSLog</span>(<span class="hljs-string">@"assetUpdateStarted"</span>);
}

- (<span class="hljs-keyword">void</span>)assetUpdateCheckingAssets
{
    <span class="hljs-built_in">NSLog</span>(<span class="hljs-string">@"assetUpdateCheckingAssets"</span>);
}

- (<span class="hljs-keyword">void</span>)assetUpdateCompleted
{
    <span class="hljs-built_in">NSLog</span>(<span class="hljs-string">@"assetUpdateCompleted"</span>);
    [<span class="hljs-keyword">super</span> viewDidLoad];
}

- (<span class="hljs-keyword">void</span>)assetUpdateTerminatedWithError:(<span class="hljs-built_in">NSError</span>*)error appCanContinue:(<span class="hljs-built_in">BOOL</span>)canContinue
{
    <span class="hljs-built_in">NSLog</span>(<span class="hljs-string">@"assetUpdateTerminatedWithError %@ canContinue %d"</span>, error, canContinue);
    <span class="hljs-keyword">if</span> (canContinue){
        [<span class="hljs-keyword">super</span> viewDidLoad];
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-comment">//TODO!!! notify the error!</span>
        <span class="hljs-built_in">NSLog</span>(<span class="hljs-string">@"Can continue to load the app!"</span>);
    }
}

- (<span class="hljs-keyword">void</span>)assetUpdateProgress:(<span class="hljs-built_in">NSInteger</span>)updatedFiles ofExpectedNumberOfFiles:(<span class="hljs-built_in">NSInteger</span>)expectedNumberOfFiles
{
    <span class="hljs-built_in">NSLog</span>(<span class="hljs-string">@"assetUpdateProgress updatedFiles=%d ofExpectedNumberOfFiles=%d"</span>, updatedFiles, expectedNumberOfFiles);
}</code></pre><p>When the <strong>assetUpdateCompleted</strong> or <strong>assetUpdateTerminatedWithError</strong> (<em>only if <strong>canContinue</strong> parameter is true</em>) methods are called you can call the viewDidLoad on super class.</p>
<h2 id="ios-assets-update-progress"><a class="header-link" href="#ios-assets-update-progress"></a>iOS Assets Update Progress</h2>
<p class="img-container"><img src="https://gitlab.vipera.com/dynamic-engine/de-public-resources/raw/7bcd71af2801882b49eaf126ffe4e9469d6e9f63/plugins/de-asset-manager/assetUpdateProgress.png" alt="Assets Update Progress"></p>
<p>If you want to display a progress HUD or waiting spinner you can add these lines into the AssetUpdate start:</p>
<pre class="hljs"><code>#<span class="hljs-keyword">import</span> <span class="hljs-string">"HUDAssetManagerUpdateHandlerUI.h"</span></code></pre><pre class="hljs"><code>HUDAssetManagerUpdateHandlerUI *uiHandler = [[HUDAssetManagerUpdateHandlerUI alloc]<span class="hljs-string">initWith:</span>self <span class="hljs-string">andShowProgress:</span>YES <span class="hljs-string">andWithDelegate:</span>self];
[[AssetManager sharedInstance] <span class="hljs-string">startUpdate:</span>self <span class="hljs-string">andWithDelegate:</span>uiHandler];</code></pre><p> The <strong>HUDAssetManagerUpdateHandlerUI</strong> is a default implementation of this UI but you can implements a your own. See the HUDAssetManagerUpdateHandlerUI code as example.</p>
<h2 id="progress-ui-and-integrity-check-localization"><a class="header-link" href="#progress-ui-and-integrity-check-localization"></a>Progress UI and Integrity Check Localization</h2>
<p> To localize strings for HUDAssetManagerUpdateHandlerUI component during update phase, you need to add these keys into the <strong>Localizable.strings</strong>:</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Description</th>
<th>Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>DEAssetManager.checkAssets</td>
<td>The message displayed during the spinner rotation</td>
<td></td>
</tr>
<tr>
<td>DEAssetManager.assetsUpdate</td>
<td>The message displayed during the remote download progress</td>
<td></td>
</tr>
<tr>
<td>DEAssetManager.newAppVersionAvailable.message</td>
<td></td>
<td>&quot;There is an app update on the store. Do you want to open it?&quot;</td>
</tr>
<tr>
<td>DEAssetManager.newAppVersionAvailable.title</td>
<td></td>
<td>&quot;App update available&quot;</td>
</tr>
<tr>
<td>DEAssetManager.newAppVersionAvailable.yesButton</td>
<td></td>
<td>&quot;Yes&quot;</td>
</tr>
<tr>
<td>DEAssetManager.newAppVersionAvailable.cancelButton</td>
<td></td>
<td>&quot;No&quot;</td>
</tr>
<tr>
<td>DEAssetManager.appUpdateNeeded.message</td>
<td></td>
<td>&quot;You must upgrade the app in order to continue. Do you want to open the store?&quot;</td>
</tr>
<tr>
<td>DEAssetManager.appUpdateNeeded.title</td>
<td></td>
<td>&quot;App update required&quot;</td>
</tr>
<tr>
<td>DEAssetManager.appUpdateNeeded.yesButton</td>
<td></td>
<td>&quot;Yes&quot;</td>
</tr>
<tr>
<td>DEAssetManager.assetEncryption.checkIntegrityFailureTitle</td>
<td>Title message displayed when check integrity fails</td>
<td></td>
</tr>
<tr>
<td>DEAssetManager.assetEncryption.checkIntegrityFailureMessage</td>
<td>Message displayed when check integrity fails</td>
<td></td>
</tr>
</tbody>
</table>
<p>Localizable.strings Example:</p>
<pre class="hljs"><code><span class="hljs-comment">/*
  Localizable.strings
  HelloApp
*/</span>

<span class="hljs-string">"DEAssetManager.assetsUpdate"</span> = <span class="hljs-string">"Updating Application..."</span><span class="hljs-comment">;</span>
<span class="hljs-string">"DEAssetManager.checkAssets"</span> = <span class="hljs-string">"Checking assets"</span><span class="hljs-comment">;</span>
<span class="hljs-string">"DEAssetManager.assetEncryption.checkIntegrityFailureTitle"</span> = <span class="hljs-string">"Security Warning"</span><span class="hljs-comment">;</span>
<span class="hljs-string">"DEAssetManager.assetEncryption.checkIntegrityFailureMessage"</span> = <span class="hljs-string">"App Corrupted"</span><span class="hljs-comment">;</span></code></pre>    </article>
  </body>
</html>