【发布时间】:2019-08-02 01:31:15
【问题描述】:
几年前,通过 Windows Bridges 项目,我创建了一个只加载我的网站的 UWP。
碰巧在我的网站上有一个 setInterval(5 分钟)向 URL 发送 POST,表明用户已登录。 事实证明,UWP 的默认行为是在应用最小化时暂停应用,因此我的应用在一段时间后不会发送 POST。
我在几个网站上阅读过,我应该使用 ExtendedExecutionSession Class 以使其工作最小化,但是,所有示例都是用 C# 编写的,我不知道我真正应该创建什么以及如何使用它。
这些是我的项目包含的所有文件:
- 图片(文件夹)
- msapp-error.css
- msapp-error.html
- msapp-error.js
- Package.appxmanifest
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">
<Identity Name="APP-NAME" Publisher="PUBLISHER" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="PhoneProductId" PhonePublisherId="PhonePublisherId"/>
<Properties>
<DisplayName>AppName</DisplayName>
<PublisherDisplayName>AppName</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App" StartPage="https://dashboard.example.com/">
<uap:VisualElements DisplayName="AppName"
Description="My App Description."
BackgroundColor="#ffffff"
Square150x150Logo="images\Square150x150Logo.png"
Square44x44Logo="images\Square44x44Logo.png">
<uap:SplashScreen Image="images\SplashScreen.png" BackgroundColor="#ffffff" />
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square310x310Logo="images\Square310x310Logo.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="wide310x150Logo"/>
<uap:ShowOn Tile="square310x310Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
<uap:InitialRotationPreference>
<uap:Rotation Preference="landscape"/>
</uap:InitialRotationPreference>
</uap:VisualElements>
<uap:ApplicationContentUriRules>
<uap:Rule Type="include" Match="https://dashboard.example.com/" WindowsRuntimeAccess="all"/>
</uap:ApplicationContentUriRules>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
我真的应该怎么做?
【问题讨论】:
-
那么,你的项目是javascript UWP,对,你想用javascript实现
ExtendedExecutionSession对吗? -
@NicoZhu-MSFT 我想用 JavaScript 实现 ExtendedExecutionSession。事实上,我什至不知道该怎么做,我只是想添加一些代码,使应用程序在最小化时永远不会挂起。因为我自己的站点在后台执行任务,而我刚刚加载该远程站点的 UWP。我阅读的所有示例都很复杂并执行一些任务,这不是我的情况,我不能让它暂停,因为我的 Web 应用程序需要每 5 分钟执行一次发布并在套接字服务器(Socket. IO)。
-
嗨@Tom,我发现您在 MSDN 中发布了类似的问题,我们的团队已经回复了您的案例。请关注更新。
-
嗨@NicoZhu-MSFT MSDN 示例仅在 C# 中,不可能在 JavaScript 中找到一些示例。
标签: javascript uwp progressive-web-apps