Title: Messaging: TypeError: this.onTokenRefreshInternal is not a function · Issue #1855 · angular/angularfire · GitHub
Open Graph Title: Messaging: TypeError: this.onTokenRefreshInternal is not a function · Issue #1855 · angular/angularfire
X Title: Messaging: TypeError: this.onTokenRefreshInternal is not a function · Issue #1855 · angular/angularfire
Description: Version info Angular: 6.0.9 Firebase: 5.4.1 AngularFire: 5.0.0-rc.12 How to reproduce these conditions const msg: AngularFireMessaging = this.msg; msg.tokenChanges.subscribe( (token) => console.log('@@@ tokenchange', token), (err) => con...
Open Graph Description: Version info Angular: 6.0.9 Firebase: 5.4.1 AngularFire: 5.0.0-rc.12 How to reproduce these conditions const msg: AngularFireMessaging = this.msg; msg.tokenChanges.subscribe( (token) => console.log...
X Description: Version info Angular: 6.0.9 Firebase: 5.4.1 AngularFire: 5.0.0-rc.12 How to reproduce these conditions const msg: AngularFireMessaging = this.msg; msg.tokenChanges.subscribe( (token) => console....
Opengraph URL: https://github.com/angular/angularfire/issues/1855
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Messaging: TypeError: this.onTokenRefreshInternal is not a function","articleBody":"### Version info\r\n\r\nAngular: 6.0.9\r\nFirebase: 5.4.1\r\nAngularFire: 5.0.0-rc.12\r\n\r\n### How to reproduce these conditions\r\n\r\n```\r\n const msg: AngularFireMessaging = this.msg;\r\n msg.tokenChanges.subscribe(\r\n (token) =\u003e console.log('@@@ tokenchange', token),\r\n (err) =\u003e console.log('@@@ tokenchange ERROR', err),\r\n );\r\n```\r\n\r\n### Debug output\r\n\r\n** Errors in the JavaScript console **\r\n```\r\n@@@ tokenchange ERROR TypeError: this.onTokenRefreshInternal is not a function\r\n at Observable.push../node_modules/@firebase/messaging/dist/index.esm.js.WindowController.onTokenRefresh [as _subscribe] (index.esm.js:1883)\r\n at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42)\r\n at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28)\r\n at subscribeTo.js:21\r\n at subscribeToResult (subscribeToResult.js:6)\r\n at SwitchMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/switchMap.js.SwitchMapSubscriber._innerSub (switchMap.js:47)\r\n at SwitchMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/switchMap.js.SwitchMapSubscriber._next (switchMap.js:40)\r\n at SwitchMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)\r\n at angularfire2.js:59\r\n at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)\r\n```\r\n\r\n### Expected behavior\r\n\r\nNo error. Problem seems to be in messaging.ts: https://github.com/angular/angularfire2/blob/185943f60012d8c3dcf7cc26413e3278f9e426be/src/messaging/messaging.ts#L56\r\n```\r\n const tokenChanges = this.messaging.pipe(\r\n switchMap(messaging =\u003e new Observable(messaging.onTokenRefresh)),\r\n runOutsideAngular(zone)\r\n );\r\n```\r\n\r\nmessaging.onTokenRefresh is not bound. As a workaround I've done this myself and this fixes the issue:\r\n```\r\n const _messaging = app.messaging();\r\n _messaging.onTokenRefresh = _messaging.onTokenRefresh.bind(_messaging);\r\n\r\n```\r\n\r\nPS. other observables in messaging.ts seem to follow the same pattern and do not bind to this","author":{"url":"https://github.com/wvanderdeijl","@type":"Person","name":"wvanderdeijl"},"datePublished":"2018-09-05T10:34:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/1855/angularfire/issues/1855"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:87486ec5-0f33-81fa-386d-b3c1faa82475 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F08:11ACF6:605BC3:82C557:6A5A7B0E |
| html-safe-nonce | 79cdedeb5e4f423347726439dfac9bcb36a08e8c2ff15e9906f0b1f2763cf1a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjA4OjExQUNGNjo2MDVCQzM6ODJDNTU3OjZBNUE3QjBFIiwidmlzaXRvcl9pZCI6IjgyODM2MDA4MTg4MTA4MTMxOTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d8dfec1a78a8d699bfe20a0aa365865200b5c6ca9df4c093ae683dcad48e30a3 |
| hovercard-subject-tag | issue:357166890 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angularfire/1855/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de90062f3147ae38d439a75e97e0783de21ba8c2765739240f3d2d40c716c695/angular/angularfire/issues/1855 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de90062f3147ae38d439a75e97e0783de21ba8c2765739240f3d2d40c716c695/angular/angularfire/issues/1855 |
| og:image:alt | Version info Angular: 6.0.9 Firebase: 5.4.1 AngularFire: 5.0.0-rc.12 How to reproduce these conditions const msg: AngularFireMessaging = this.msg; msg.tokenChanges.subscribe( (token) => console.log... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wvanderdeijl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 922bdba685ea48400234d557977f0e32d9adbae6f5125725b4f48cacc6801106 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angularfire git https://github.com/angular/angularfire.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 49453413 |
| octolytics-dimension-repository_nwo | angular/angularfire |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49453413 |
| octolytics-dimension-repository_network_root_nwo | angular/angularfire |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0437efb828a4041956ce45d1f7fe69fff38926c7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width