使用WL.Client.reloadApp重新加载应用程序时是否会调用wlcommoninit [英] Does wlcommoninit get called when the app is reloaded using WL.Client.reloadApp

查看:231
本文介绍了使用WL.Client.reloadApp重新加载应用程序时是否会调用wlcommoninit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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)]未捕获
(承诺中)错误:未知事件操作未定义,来源:
file:/// android_asset /www/default/worklight/cordova.js(1576)



解决方案

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



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

 <?xml version =1.0encoding =UTF-8 standalone =no?> 
<! -
根据一个
或更多的贡献者许可协议许可给Apache Software Foundation(ASF)。请参阅随此工作分发的NOTICE文件
,以获取有关版权所有权的其他信息
。 ASF根据Apache许可证2.0版(
许可证)向您授予此文件
;您不得使用此文件,除非符合许可证
。您可以以

获得许可证副本http://www.apache.org/licenses/LICENSE-2.0

除非适用法律要求或书面同意,根据许可证分发的
软件按原样基础分配在
基础上,不附带任何明示或暗示的任何
种类的保证或条件。请参阅许可证,了解管理许可证下的权限和限制

特定语言。
- >< widget xmlns =http://www.w3.org/ns/widgetsid =PluginDevelopmentversion =1.0.0.0>
< name> PluginDevelopment< / name>

< description>
PluginDevelopment
< / description>

< author email =申请作者的电子邮件href =http://mycompany.com>
申请作者
< / author>

< access origin =*/>
< preference name =loglevelvalue =DEBUG/>
<! -
< preference name =splashscreenvalue =resourceName/>
< preference name =backgroundColorvalue =0xFFF/>
< preference name =loadUrlTimeoutValuevalue =20000/>
< preference name =InAppBrowserStorageEnabledvalue =true/>
< preference name =disallowOverscrollvalue =true/>
- >
<! - 这是本机Android挂钩所必需的 - >
< feature name =App>
< param name =android-packagevalue =org.apache.cordova.App/>
< / feature>
< feature name =Device>
< param name =android-packagevalue =org.apache.cordova.device.Device/>
< / feature>
< feature name =Accelerometer>
< param name =android-packagevalue =org.apache.cordova.devicemotion.AccelListener/>
< / feature>
< feature name =Compass>
< param name =android-packagevalue =org.apache.cordova.deviceorientation.CompassListener/>
< / feature>
< feature name =Media>
< param name =android-packagevalue =org.apache.cordova.media.AudioHandler/>
< / feature>
< feature name =Camera>
< param name =android-packagevalue =org.apache.cordova.camera.CameraLauncher/>
< / feature>
< feature name =Contacts>
< param name =android-packagevalue =org.apache.cordova.contacts.ContactManager/>
< / feature>
< feature name =File>
< param name =android-packagevalue =org.apache.cordova.file.FileUtils/>
< / feature>
< feature name =Notification>
< param name =android-packagevalue =org.apache.cordova.dialogs.Notification/>
< / feature>
< feature name =FileTransfer>
< param name =android-packagevalue =org.apache.cordova.filetransfer.FileTransfer/>
< / feature>
< feature name =Capture>
< param name =android-packagevalue =org.apache.cordova.mediacapture.Capture/>
< / feature>
< feature name =Battery>
< param name =android-packagevalue =org.apache.cordova.batterystatus.BatteryListener/>
< / feature>
< feature name =SplashScreen>
< param name =android-packagevalue =org.apache.cordova.splashscreen.SplashScreen/>
< / feature>
< feature name =Globalization>
< param name =android-packagevalue =org.apache.cordova.globalization.Globalization/>
< / feature>
< feature name =InAppBrowser>
< param name =android-packagevalue =org.apache.cordova.inappbrowser.InAppBrowser/>
< / feature>
< feature name =Vibration>
< param name =android-packagevalue =org.apache.cordova.vibration.Vibration/>
< / feature>

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


Does wlcommoninit get called when the app is reloaded using WL.Client.reloadApp??

I have a user logout function in a hybrid app. After logout, there is a call to reloadApp() method for WL.Client. It seems after reloading the wlcommoninit is not being called. It does get called if I kill the app and re-start it.

The MobileFirst version we're working with is 7.1. Added: There is a Cordova.js error in the logs which may be preventing the wlCommonInit() from being called after logout + reloadApp:

12-28 16:52:18.354: I/chromium(9539): [INFO:CONSOLE(309)] "Error in Success callbackId: App414539960 : Error: Unknown event action undefined", source: file:///android_asset/www/default/worklight/cordova.js (309)

12-28 16:52:18.354: I/chromium(9539): [INFO:CONSOLE(1576)] "Uncaught (in promise) Error: Unknown event action undefined", source: file:///android_asset/www/default/worklight/cordova.js (1576)

解决方案

I had the same issue on my side, but I think this was my fault. My android/res/xml/config.xml file had been migrated successfully by the migration script to include the latest required MobileFirst plugins, but I had it excluded from my source repository so I hadn't checked in the latest version and was still using the old version in my app. Once I manually copied a correctly migrated config.xml everything worked correctly.

Can you verify that your config.xml contains all of the required MobileFirst plugins for Android. Here's my example config.xml that works for me.

<?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>

这篇关于使用WL.Client.reloadApp重新加载应用程序时是否会调用wlcommoninit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆