[英]iOS PWA suppress Toolbar
I've written a simple Angular PWA, that I have added on my iPhone to the Homescreen.我写了一个简单的 Angular PWA,我已经在我的 iPhone 上添加到主屏幕。 To remove the Safari Toolbar, I have already included in my index.html:要删除 Safari 工具栏,我已经包含在我的 index.html 中:
<meta name="apple-mobile-web-app-capable" content="yes">
See Image "1", the Toolbar is gone.参见图片“1”,工具栏不见了。 The Problem is: when I hit the "Start"-Button on Image 1, the Angular App routes to a new Component (the URL changes from https://example.com/foo to https://example.com/foo/bar ), and some other Toolbar pops up (see Image "2"). The Problem is: when I hit the "Start"-Button on Image 1, the Angular App routes to a new Component (the URL changes from https://example.com/foo to https://example.com/foo/ bar ),并弹出一些其他工具栏(见图“2”)。
Is there any way to prevent iOS from showing this Toolbar at Image 2?有什么办法可以防止 iOS 在图 2 中显示此工具栏? Thank you!谢谢!
Image 1:图 1:
Image 2:图 2:
I did find a solution myself:我自己确实找到了解决方案:
It seems like iOS shows this Toolbar if the Host or Path of a URL changes, so I checked if it also takes the URL Fragment ( https://en.wikipedia.org/wiki/URL#Syntax ) into account, and it does not! It seems like iOS shows this Toolbar if the Host or Path of a URL changes, so I checked if it also takes the URL Fragment ( https://en.wikipedia.org/wiki/URL#Syntax ) into account, and it does不是! Yay!耶!
So my solution for an Angular-based Webapp is to configure Hash-based LocationStrategy like this in your AppModule:所以我对基于 Angular 的 Webapp 的解决方案是在你的 AppModule 中像这样配置基于哈希的 LocationStrategy:
import {HashLocationStrategy, LocationStrategy} from "@angular/common";
@NgModule({
declarations: [
...
],
imports: [
...
],
providers: [
{ provide: LocationStrategy, useClass: HashLocationStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule { }
This way no Toolbar pops up, if I change the Route in Angular.这样,如果我更改 Angular 中的路由,则不会弹出工具栏。
I ran into this as well when creating a PWA in Angular 8. The solution was在 Angular 8 中创建 PWA 时,我也遇到了这个问题。解决方案是
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })]
})
in my app-routing.module.ts
在我的app-routing.module.ts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.