使用WL.Client.reloadApp重新加载应用程序时是否会调用wlcommoninit

时间:2015-12-28 21:17:25

标签: cordova ibm-mobilefirst hybrid-mobile-app

使用WL.Client.reloadApp重新加载应用时是否会调用wlcommoninit?

我在混合应用程序中有一个用户注销功能。注销后,会调用WL.Client的reloadApp()方法。似乎在重新加载后没有调用wlcommoninit。如果我杀了应用程序并重新启动它,它会被调用。

我们正在使用的MobileFirst版本是7.1。 添加: 日志中存在Cordova.js错误,这可能会阻止在logout + reloadApp之后调用wlCommonInit():

  

12-28 16:52:18.354:I / chromium(9539):[INFO:CONSOLE(309)]"错误   成功callbackId:App414539960:错误:未知事件操作   undefined",来源:   file:///android_asset/www/default/worklight/cordova.js(309)

     

12-28 16:52:18.354:I / chromium(9539):[INFO:CONSOLE(1576)]" Uncaught   (承诺中)错误:未知事件操作未定义",来源:   file:///android_asset/www/default/worklight/cordova.js(1576)

2 个答案:

答案 0 :(得分:0)

您没有提到您正在使用的MobileFirst Platform Foundation(或Worklight)的版本,但我不确定在这种情况下它实际上是否重要。

我刚刚在7.1上测试过,并确认在使用WL.Client.reloadApp()重新加载应用程序时实际上调用了wlCommonInit()。

我是通过采样" Hello MobileFirst" app(创建新的MobileFirst Platform混合应用程序时自动创建的模板),将其添加到index.html文件中:

<a onClick="WL.Client.reloadApp();">Click Me</a>

然后在wlCommonInit()中添加这个:

alert("init");

当应用首次初始化时会显示提醒,当您单击&#34; Click Me&#34;时也会显示提醒。应用程序中的链接,确认在这种情况下正在调用wlCommonInit()。

我没有在任何实际设备上尝试这个,但是我在预览公共资源和Android环境时尝试过这个,并且在桌面浏览器环境中尝试过它,并且在所有三个地方都得到了相同的结果。

如果您可以编辑您的问题以提供更多信息(例如,可能是您实际的MFP项目的链接,和/或您观察到的内容会导致您认为wlCommonInit()未被调用),可以提供更有用的答案。但是,就您提出的具体问题而言 - 是的,当您调用WL.Client.reloadApp()时,肯定会调用wlCommonInit()。

答案 1 :(得分:0)

我有同样的问题,但我认为这是我的错。我的android / res / xml / config.xml文件已被迁移脚本成功迁移,以包含最新的必需MobileFirst插件,但我将其从源存储库中排除,因此我没有检查最新版本并仍在使用我的应用程序中的旧版本。手动复制正确迁移的config.xml后,一切正常。

您可以验证您的config.xml是否包含Android所需的所有MobileFirst插件。这是我的示例config.xml,对我有用。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--><widget xmlns="http://www.w3.org/ns/widgets" id="PluginDevelopment" version="1.0.0.0">
    <name>PluginDevelopment</name>

    <description>
        PluginDevelopment
    </description>

    <author email="application author's e-mail" href="http://mycompany.com">
        application's author
    </author>

    <access origin="*"/>
    <preference name="loglevel" value="DEBUG"/>
    <!--
      <preference name="splashscreen" value="resourceName" />
      <preference name="backgroundColor" value="0xFFF" />
      <preference name="loadUrlTimeoutValue" value="20000" />
      <preference name="InAppBrowserStorageEnabled" value="true" />
      <preference name="disallowOverscroll" value="true" />
    -->
    <!-- This is required for native Android hooks -->
    <feature name="App">
        <param name="android-package" value="org.apache.cordova.App"/>
    </feature>
    <feature name="Device">
        <param name="android-package" value="org.apache.cordova.device.Device"/>
    </feature>
    <feature name="Accelerometer">
        <param name="android-package" value="org.apache.cordova.devicemotion.AccelListener"/>
    </feature>
    <feature name="Compass">
        <param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener"/>
    </feature>
    <feature name="Media">
        <param name="android-package" value="org.apache.cordova.media.AudioHandler"/>
    </feature>         
    <feature name="Camera">
        <param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/>
    </feature>
    <feature name="Contacts">
        <param name="android-package" value="org.apache.cordova.contacts.ContactManager"/>
    </feature>
    <feature name="File">
        <param name="android-package" value="org.apache.cordova.file.FileUtils"/>
    </feature>
    <feature name="Notification">
        <param name="android-package" value="org.apache.cordova.dialogs.Notification"/>
    </feature>    
    <feature name="FileTransfer">
        <param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer"/>
    </feature>
    <feature name="Capture">
        <param name="android-package" value="org.apache.cordova.mediacapture.Capture"/>
    </feature>
    <feature name="Battery">
        <param name="android-package" value="org.apache.cordova.batterystatus.BatteryListener"/>
    </feature>
    <feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
    </feature> 
    <feature name="Globalization">
        <param name="android-package" value="org.apache.cordova.globalization.Globalization"/>
    </feature>
    <feature name="InAppBrowser">
        <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
    </feature>    
    <feature name="Vibration">
        <param name="android-package" value="org.apache.cordova.vibration.Vibration"/>
    </feature>

<feature name="WLInitializationPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLInitializationPlugin"/>
        <param name="onload" value="true"/>
    </feature>
    <feature name="UserAuth">
        <param name="android-package" value="com.worklight.androidgap.plugin.UserAuthPlugin"/>
        <param name="onload" value="false"/>
    </feature>
    <feature name="LoggerPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.LoggerPlugin"/>
    </feature>
    <feature name="WLApp">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLApp"/>
    </feature>
    <feature name="NativePage">
        <param name="android-package" value="com.worklight.androidgap.plugin.NativePage"/>
    </feature>
    <feature name="NativeBusyIndicator">
        <param name="android-package" value="com.worklight.androidgap.plugin.BusyIndicator"/>
    </feature>
    <feature name="SecurityPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.SecurityPlugin"/>
    </feature>
    <feature name="StoragePlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.StoragePlugin"/>
    </feature>
    <feature name="Push">
        <param name="android-package" value="com.worklight.androidgap.plugin.Push"/>
    </feature>
    <feature name="WebResourcesDownloader">
        <param name="android-package" value="com.worklight.androidgap.plugin.WebResourcesDownloaderPlugin"/>
    </feature>
    <feature name="WLDirectUpdatePlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLDirectUpdatePlugin"/>
    </feature>
    <feature name="NetworkDetector">
        <param name="android-package" value="com.worklight.androidgap.plugin.NetworkDetector"/>
    </feature>
    <feature name="DeviceAuth">
        <param name="android-package" value="com.worklight.androidgap.plugin.DeviceAuthPlugin"/>
    </feature>
    <feature name="WifiPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WifiPlugin"/>
    </feature>
    <feature name="WLGeolocationPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLGeolocationPlugin"/>
    </feature>
    <feature name="ForegroundBinderPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.ForegroundBinderPlugin"/>
    </feature>
    <feature name="FIPSHttpPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.FIPSHttpPlugin"/>
    </feature>
    <feature name="WLCustomDialog">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLCustomDialog"/>
    </feature>
    <feature name="NetworkStatus">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLNetworkManager"/>
    </feature>
    <feature name="WLSplashScreen">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLSplashScreenPlugin"/>
    </feature>
    <feature name="WLNativeXHRPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLNativeXHRPlugin"/>
    </feature>
    <feature name="WLActionSenderPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLActionSenderPlugin"/>
    </feature>
    <feature name="StatusBar">
        <param name="android-package" value="org.apache.cordova.statusbar.StatusBar"/>
    </feature>
    <feature name="WLAuthorizationManagerPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLAuthorizationManagerPlugin"/>
    </feature>
    <feature name="WLCertificatePinningPlugin">
        <param name="android-package" value="com.worklight.androidgap.plugin.WLCertificatePinningPlugin"/>
    </feature
</widget>