-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(messaging): AngularFireMessaing #1749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/messaging/messaging.ts
Outdated
|
||
this.requestPermission = requestPermission(this.messaging); | ||
|
||
this.getToken = from(this.messaging.getToken()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this a single IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err, that's a Promise hance a single... nevermind.
src/messaging/messaging.ts
Outdated
|
||
this.getToken = from(this.messaging.getToken()); | ||
|
||
this.tokenChanges = new Observable(subscriber => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now that I'm playing with this I'm not sure I like this API. I think I'd prefer:
this.tokenChanges => from(this.messaging.onTokenRefresh);
this.token => this.getToken.pipe(concat(this.tokenChanges))
Thoughts?
src/messaging/messaging.ts
Outdated
|
||
} | ||
|
||
deleteToken(token: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... not sure about this API either, how about
this.deleteToken = this.getToken.pipe(
mergeMap(t => t ? this.messaging.deleteToken(t) : empty() )
)
src/messaging/messaging.ts
Outdated
constructor(public app: FirebaseApp) { | ||
this.messaging = app.messaging(); | ||
|
||
this.requestPermission = requestPermission(this.messaging); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not inline?
src/messaging/messaging.ts
Outdated
this.messaging.onMessage(subscriber); | ||
}); | ||
|
||
this.requestToken = this.requestPermission.pipe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should catch the requestPermission exception and complete with null
AngularFireMessaging
This is a WIP, but here is the current API surface.