~PollableListener()
Public functions | |
---|---|
OnMessage(const Message & message) | virtual void An implementation of OnMessage which adds the incoming messages to a queue, which can be consumed by calling PollMessage . |
OnTokenReceived(const char *token) | virtual void An implementation of OnTokenReceived which stores the incoming token so that it can be consumed by calling PollRegistrationToken . |
PollMessage(Message *message) | bool Returns the first message queued up, if any. |
PollRegistrationToken(std::string *token) | bool Returns the registration key, if a new one has been received. |
virtualvoidOnMessage(constMessage&message)
An implementation of OnMessage
which adds the incoming messages to a queue, which can be consumed by calling PollMessage
.
virtualvoidOnTokenReceived(constchar*token)
An implementation of OnTokenReceived
which stores the incoming token so that it can be consumed by calling PollRegistrationToken
.
boolPollMessage(Message*message)
Returns the first message queued up, if any.
If one or more messages has been received, the first message in the queue will be popped and used to populate the message
argument and the function will return true
. If there are no pending messages, false
is returned. This function should be called in a loop until all messages have been consumed, like so:
::firebase::messaging::Messagemessage;while(listener.PollMessage(&message)){LogMessage("Received a new message");}
Details | |||
---|---|---|---|
Parameters |
| ||
Returns | Returns true if there was a pending message, false otherwise. |
boolPollRegistrationToken(std::string*token)
Returns the registration key, if a new one has been received.
When a new registration token is received, it is cached internally and can be retrieved by calling PollRegistrationToken
. The cached registration token will be used to populate the token
argument, then the cache will be cleared and the function will return true
. If there is no cached registration token this function retuns false
.
std::stringtoken;if(listener.PollRegistrationToken(&token)){LogMessage("Received a registration token");}
Details | |||
---|---|---|---|
Parameters |
| ||
Returns | Returns true if there was a new token, false otherwise. |
PollableListener()
The default constructor.
virtual~PollableListener()
The required virtual destructor.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-23 UTC.