简体   繁体   中英

Push Notification for web app giving Manifest empty or missing error

Push Notifications on localhost is unable to access manifest.json.

Followed the steps from https://developers.google.com/web/fundamentals/getting-started/push-notifications/

My manifest.json contents (hidden project number)

"name": "xyz",  
  "short_name": "x",  
  "icons": [{  
        "src": "images/icon_add.gif",  
        "sizes": "192x192",
        "type": "image/gif"
      }],  
  "start_url": "my_link",  
  "display": "standalone",  
  "gcm_sender_id": "my_app_id",
  "gcm_user_visible_only": true

NOTE

  • manifest.json is at root.
  • Link to manifest.jason is at start of the <head> .
  • <head> is at start/first element of index.jsp

index.jsp

<head>
 <link rel="manifest"  href="/manifest.json"/> 
 <script src="javascript/main.js"></script>
 .....

web.xml

<web-app id="XYZ">
 <display-name>XYZ</display-name>
.....   
<welcome-file-list>
<welcome-file>index.htm</welcome-file>
</welcome-file-list> 

Opened localhost:8080/XYZ/index.htm and popup notification doesn't work with below error from console.

错误

Tried below:

  • Changed type attribute of link tag.
  • Moved link and script tags to top of head tag of index.jsp.

Any kind of help is highly appreciated.

I guess you already resolved it. But if you didn't, try <link rel="manifest" href="manifest.json"/> instead of /manifest.json .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM