简体   繁体   中英

firebase.messaging: Cannot read property 'getNotificationPermission_' of undefined

Im trying to add firebase for webpush in one old project.

There are require.js and also I cant use node. So I copy firebase app and firebase messaging from firebase cdn (www.gstatic.com) and import them in project.

But when I call messaging method requestPermission() it outputs in console Cannot read property 'getNotificationPermission_' of undefined .

Firebase losing context, but if I change all this for explicit context assignment, like let self = this , everything works fine.

How should I import firebase for its performance?

For anyone, who faced same problem - I find the with epmty: scheme in requirejs . This GitHub issue may help you https://github.com/firebase/firebase-js-sdk/issues/1569

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