30#if ! JUCE_ANDROID && ! JUCE_IOS && ! JUCE_MAC
34PushNotifications::Notification::Notification (
const Notification& other)
35 : identifier (other.identifier),
38 subtitle (other.subtitle),
39 groupId (other.groupId),
40 badgeNumber (other.badgeNumber),
41 soundToPlay (other.soundToPlay),
42 properties (other.properties),
43 category (other.category),
44 triggerIntervalSec (other.triggerIntervalSec),
45 repeat (other.repeat),
47 channelId (other.channelId),
48 largeIcon (other.largeIcon),
49 tickerText (other.tickerText),
50 actions (other.actions),
51 progress (other.progress),
52 person (other.person),
54 priority (other.priority),
55 lockScreenAppearance (other.lockScreenAppearance),
56 publicVersion (other.publicVersion.get() != nullptr ? new
Notification (*other.publicVersion) : nullptr),
57 groupSortKey (other.groupSortKey),
58 groupSummary (other.groupSummary),
59 accentColour (other.accentColour),
60 ledColour (other.ledColour),
61 ledBlinkPattern (other.ledBlinkPattern),
62 vibrationPattern (other.vibrationPattern),
63 shouldAutoCancel (other.shouldAutoCancel),
64 localOnly (other.localOnly),
65 ongoing (other.ongoing),
66 alertOnlyOnce (other.alertOnlyOnce),
67 timestampVisibility (other.timestampVisibility),
68 badgeIconType (other.badgeIconType),
69 groupAlertBehaviour (other.groupAlertBehaviour),
70 timeoutAfterMs (other.timeoutAfterMs)
77PushNotifications::PushNotifications()
78 #if JUCE_PUSH_NOTIFICATIONS
79 : pimpl (
new Pimpl (*
this))
84PushNotifications::~PushNotifications() { clearSingletonInstance(); }
86void PushNotifications::addListener (Listener* l) { listeners.add (l); }
87void PushNotifications::removeListener (Listener* l) { listeners.remove (l); }
91 #if JUCE_PUSH_NOTIFICATIONS && (JUCE_IOS || JUCE_MAC)
92 pimpl->requestPermissionsWithSettings (settings);
100 #if JUCE_PUSH_NOTIFICATIONS && (JUCE_IOS || JUCE_MAC)
101 pimpl->requestSettingsUsed();
109 #if JUCE_PUSH_NOTIFICATIONS
110 return pimpl->areNotificationsEnabled();
118 #if JUCE_PUSH_NOTIFICATIONS
119 pimpl->getDeliveredNotifications();
125 #if JUCE_PUSH_NOTIFICATIONS
126 pimpl->removeAllDeliveredNotifications();
132 #if JUCE_PUSH_NOTIFICATIONS
133 return pimpl->getDeviceToken();
141 #if JUCE_PUSH_NOTIFICATIONS
142 pimpl->setupChannels (groups, channels);
148 #if JUCE_PUSH_NOTIFICATIONS
149 pimpl->getPendingLocalNotifications();
155 #if JUCE_PUSH_NOTIFICATIONS
156 pimpl->removeAllPendingLocalNotifications();
162 #if JUCE_PUSH_NOTIFICATIONS
163 pimpl->subscribeToTopic (topic);
169 #if JUCE_PUSH_NOTIFICATIONS
170 pimpl->unsubscribeFromTopic (topic);
177 #if JUCE_PUSH_NOTIFICATIONS
178 pimpl->sendLocalNotification (n);
184 #if JUCE_PUSH_NOTIFICATIONS
185 pimpl->removeDeliveredNotification (identifier);
191 #if JUCE_PUSH_NOTIFICATIONS
192 pimpl->removePendingLocalNotification (identifier);
197 [[maybe_unused]]
const String& collapseKey,
198 [[maybe_unused]]
const String& messageId,
199 [[maybe_unused]]
const String& messageType,
200 [[maybe_unused]]
int timeToLive,
203 #if JUCE_PUSH_NOTIFICATIONS
204 pimpl->sendUpstreamMessage (serverSenderId,
220 [[maybe_unused]]
const String& actionIdentifier,
221 [[maybe_unused]]
const String& optionalResponse) {}
228 [[maybe_unused]]
const String& error) {}
Holds a resizable array of primitive or copy-by-value objects.
Singleton class responsible for push notifications functionality.
void setupChannels(const Array< ChannelGroup > &groups, const Array< Channel > &channels)
Android API level 26 or higher only: configures notification channel groups and channels to be used i...
void removePendingLocalNotification(const String &identifier)
Unschedules a pending local notification with a given identifier.
void getPendingLocalNotifications() const
iOS only: sends an asynchronous request to retrieve a list of notifications that were scheduled and n...
void removeAllPendingLocalNotifications()
Unschedules all pending local notifications.
void subscribeToTopic(const String &topic)
Android only: allows to subscribe to messages from a specific topic.
void getDeliveredNotifications() const
Sends a request for a list of notifications delivered.
void removeAllDeliveredNotifications()
Removes all notifications that were delivered.
void removeDeliveredNotification(const String &identifier)
Removes a previously delivered notification.
bool areNotificationsEnabled() const
Checks whether notifications are enabled for given application.
void sendUpstreamMessage(const String &serverSenderId, const String &collapseKey, const String &messageId, const String &messageType, int timeToLive, const StringPairArray &additionalData)
Android only: sends an upstream message to your app server.
void sendLocalNotification(const Notification ¬ification)
On iOS as well as on Android, sends a local notification.
void unsubscribeFromTopic(const String &topic)
Android only: allows to remove a topic subscription that was previously added with subscribeToTopic()...
void requestSettingsUsed()
Sends an asynchronous request to retrieve current settings that are currently in use.
void requestPermissionsWithSettings(const Settings &settings)
Initialises push notifications on current device with the settings provided.
String getDeviceToken() const
Retrieves current device token.
Describes settings we want to use for current device.
A container for holding a set of strings which are keyed by another string.
#define JUCE_IMPLEMENT_SINGLETON(Classname)
This is a counterpart to the JUCE_DECLARE_SINGLETON macros.
Register a listener (ideally on application startup) to receive information about notifications recei...
virtual void notificationSettingsReceived(const Settings &settings)
This callback will be called after you call requestSettingsUsed() or requestPermissionsWithSettings()...
virtual void handleNotification(bool isLocalNotification, const Notification ¬ification)
This can be called in multiple different situations, depending on the OS and the situation.
virtual void upstreamMessageSendingError(const String &messageId, const String &error)
Called when there was an error sending an upstream message with PushNotifications::sendUpstreamMessag...
virtual void deviceTokenRefreshed(const String &token)
Called whenever a token gets refreshed.
virtual void upstreamMessageSent(const String &messageId)
Called when an upstream message sent with PushNotifications::sendUpstreamMessage() has been sent succ...
virtual void remoteNotificationsDeleted()
Called when Firebase Cloud Messaging server deletes pending messages.
virtual void handleNotificationAction(bool isLocalNotification, const Notification ¬ification, const String &actionIdentifier, const String &optionalResponse)
This can be called when a user performs some action on the notification such as pressing on an action...
virtual void localNotificationDismissedByUser(const Notification ¬ification)
For iOS10 and Android, this can be also called when a user dismissed the notification before respondi...
virtual void deliveredNotificationsListReceived(const Array< Notification > ¬ifications)
Called after getDeliveredNotifications() request is fulfilled.
virtual void pendingLocalNotificationsListReceived(const Array< Notification > ¬ifications)
Called when the list of pending notifications, requested by calling getPendingLocalNotifications() is...
Represents a notification that can be sent or received.
bool isValid() const noexcept
Checks whether a given notification is correctly configured for a given OS.