推送通知等效于Angular 7 ngsw-config?

时间:2018-12-03 04:05:21

标签: angular angular7 web-push

我正在关注一个使用Angular创建简单PWA的教程。 在本教程中,教师使用的是Angular 4.3,而我使用的是Angular 7.1.1。

当前,我正在尝试添加推送通知。讲师在其ngsw-manifest.json中添加了一个名为“ push”的部分。我正在尝试为我的Angular 7 ngsw-config.json找到新的等效项,但到目前为止我还没有运气。任何帮助将不胜感激! json文件可以在下面找到。

ngsw-manifest.json(教师示例)

{
    "routing": {
        "index": "/index.html",
        "routes": {
            "/": {
                "match": "exact"
            },
            "/coffee": {
                "match": "prefix"
            }
        }
    },
    "static.ignore": [
        "^\/icons\/.*$"
    ],
    "external": {
        "urls": [
            {
                "url": "https://fonts.googleapis.com/icon?family=Material+Icons"
        },
        {
            "url": "https://fonts.gstatic.com/s/materialicons/v22/2fcrYFNaTjcS6g4U3t-Y5UEw0lE80llgEseQY3FEmqw.woff2"
        }
    ]
},
"dynamic": {
    "group": [
        {
            "name": "api",
            "urls": {
                "http://localhost:3000/coffees": {
                    "match": "prefix"
                }
            },
            "cache": {
                "optimizeFor": "performance",
                "networkTimeoutMs": 1000,
                "maxEntries": 30,
                "strategy": "lru",
                "maxAgeMs": 360000000
                }
            }
        ]
    },
    "push": {
        "showNotifications": true,
        "backgroundOnly": false
    }

}

ngsw-config(我的文件)

{
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/*.css",
          "/*.js"
        ],
        "urls": [
          "https://fonts.googleapis.com/icon?family=Material+Icons",
          "https://fonts.gstatic.com/s/materialicons/v41/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "prefetch",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**"
        ]
      }
    }, {
      "name": "icons",
      "installMode": "prefetch",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/icons/**"
        ]
      }
    }
  ],
  "dataGroups": [
    {
      "name": "posts",
      "urls": [
        "http://localhost:3000/coffees"
      ],
      "cacheConfig": {
        "maxSize": 20,
        "maxAge": "6h",
        "timeout": "15s",
        "strategy": "freshness"
      }
    }
  ]
}

0 个答案:

没有答案