JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_PushNotifications.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26#pragma once
27
28namespace juce
29{
30
45class JUCE_API PushNotifications : private DeletedAtShutdown
46{
47public:
48 #ifndef DOXYGEN
50 #endif
51
52 //==============================================================================
55 {
56 Notification() = default;
57 Notification (const Notification& other);
58
60 bool isValid() const noexcept;
61
66 struct Action
67 {
69 enum Style
70 {
72 text
73 };
74
77 Style style = button;
88 bool triggerInBackground = false;
89 bool destructive = false;
107 };
108
109 //==============================================================================
127 int badgeNumber = 0;
151 //==============================================================================
157 double triggerIntervalSec = 0.;
158 bool repeat = false;
163 //==============================================================================
184 struct Progress
185 {
186 int max = 0;
188 int current = 0;
189 bool indeterminate = false;
191 };
192
215
218 {
219 veryLow = -2,
220 low = -1,
221 medium = 0,
222 high = 1,
223 veryHigh = 2
224 };
225
230 Type type = unspecified;
231 Priority priority = medium;
235 {
236 dontShow = -1,
237 showPartially = 0,
238 showCompletely = 1
239 };
240
241 LockScreenAppearance lockScreenAppearance = showPartially;
249 bool groupSummary = false;
259 {
260 int msToBeOn = 0;
261 int msToBeOff = 0;
262 };
263
273 bool shouldAutoCancel = true;
275 bool localOnly = true;
278 bool ongoing = false;
283 bool alertOnlyOnce = false;
288 {
292 countDownChronometer
293 };
294
295 TimestampVisibility timestampVisibility = normal;
299 {
300 none,
301 small,
302 large
303 };
304
305 BadgeIconType badgeIconType = large;
306
309 {
311 AlertSummary,
313 AlertChildren
315 };
316
317 GroupAlertBehaviour groupAlertBehaviour = alertAll;
318
319 int timeoutAfterMs = 0;
322 };
323
324
325 //==============================================================================
387 struct Settings
388 {
390
396 struct Category
397 {
400 bool sendDismissAction = false;
401 };
402
403 bool allowSound = false;
404 bool allowAlert = false;
405 bool allowBadge = false;
407 };
408
423 void requestPermissionsWithSettings (const Settings& settings);
424
438 void requestSettingsUsed();
439
440 //==============================================================================
446 struct Channel
447 {
453 {
454 none,
455 min,
456 low,
457 normal,
458 high,
459 max
460 };
461
462 Importance importance = normal;
463 Notification::LockScreenAppearance lockScreenAppearance = Notification::showPartially;
468 bool bypassDoNotDisturb = false;
469 bool canShowBadge = false;
470 bool enableLights = false;
471 bool enableVibration = false;
475 };
476
486
491 void setupChannels (const Array<ChannelGroup>& groups, const Array<Channel>& channels);
492
493 //==============================================================================
499 void getPendingLocalNotifications() const;
500
502 void removePendingLocalNotification (const String& identifier);
503
505 void removeAllPendingLocalNotifications();
506
507 //==============================================================================
511 bool areNotificationsEnabled() const;
512
518 void sendLocalNotification (const Notification& notification);
519
527 void getDeliveredNotifications() const;
528
532 void removeDeliveredNotification (const String& identifier);
533
535 void removeAllDeliveredNotifications();
536
537 //==============================================================================
542 String getDeviceToken() const;
543
549 void subscribeToTopic (const String& topic);
550
554 void unsubscribeFromTopic (const String& topic);
555
582 void sendUpstreamMessage (const String& serverSenderId,
583 const String& collapseKey,
584 const String& messageId,
585 const String& messageType,
586 int timeToLive,
587 const StringPairArray& additionalData);
588
589 //==============================================================================
593 struct Listener
594 {
595 virtual ~Listener() = default;
596
604 virtual void notificationSettingsReceived (const Settings& settings);
605
609 virtual void pendingLocalNotificationsListReceived (const Array<Notification>& notifications);
610
625 virtual void handleNotification (bool isLocalNotification, const Notification& notification);
626
641 virtual void handleNotificationAction (bool isLocalNotification,
642 const Notification& notification,
643 const String& actionIdentifier,
644 const String& optionalResponse);
645
649 virtual void localNotificationDismissedByUser (const Notification& notification);
650
658 virtual void deliveredNotificationsListReceived (const Array<Notification>& notifications);
659
663 virtual void deviceTokenRefreshed (const String& token);
664
670 virtual void remoteNotificationsDeleted();
671
676 virtual void upstreamMessageSent (const String& messageId);
677
682 virtual void upstreamMessageSendingError (const String& messageId, const String& error);
683 };
684
685 void addListener (Listener* l);
686 void removeListener (Listener* l);
687
688private:
690 ~PushNotifications() override;
691
693
694 #if JUCE_ANDROID
695 friend bool juce_handleNotificationIntent (void*);
696
697 friend struct JuceFirebaseInstanceIdService;
698 friend struct JuceFirebaseMessagingService;
699 #endif
700
701 #if JUCE_PUSH_NOTIFICATIONS
702 struct Pimpl;
703 friend struct Pimpl;
704
706 #endif
707};
708
709} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
Classes derived from this will be automatically deleted when the application exits.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
Holds a set of objects and can invoke a member function callback on each object in the set with a sin...
Singleton class responsible for push notifications functionality.
Array< Category > categories
list of categories the app wants to support
juce::Array< Action > actions
optional list of actions within this category
String identifier
Required: Unique channel group identifier.
String name
Required: User visible name of the channel group.
Android API level 26 or higher only: represents a channel group.
Describes settings we want to use for current device.
Describes a category of a notification.
A special array for holding a list of strings.
A container for holding a set of strings which are keyed by another string.
The JUCE String class!
Definition juce_String.h:53
Represents a URL and has a bunch of useful functions to manipulate it.
Definition juce_URL.h:38
A variant class, that can be used to hold a range of primitive values.
#define JUCE_DECLARE_SINGLETON(Classname, doNotRecreateAfterDeletion)
Macro to generate the appropriate methods and boilerplate for a singleton class.
JUCE Namespace.
Android API level 26 or higher only: Represents notification channel through which notifications will...
String groupId
Required: group this channel belongs to (see ChannelGroup).
String name
Required: User facing name of the channel.
Colour ledColour
Optional: sets the led colour for notifications in this channel.
Importance
Controls how interruptive the notification posted on this channel are.
URL soundToPlay
Optional: sound to play in this channel.
String description
Optional: user visible description of the channel.
Array< int > vibrationPattern
Optional: vibration pattern for this channel.
String identifier
Required: Unique channel identifier.
Register a listener (ideally on application startup) to receive information about notifications recei...
Represents an action on a notification that can be presented as a button or a text input.
StringArray allowedResponses
Optional: a list of possible answers if the answer set is limited.
String icon
Optional: name of an icon file (without an extension) to be used for this action.
String textInputPlaceholder
Optional: placeholder text for text input notification.
var parameters
Optional: additional parameters that can be passed.
Style
Controls the appearance of this action.
String identifier
Required: unique identifier.
String textInputButtonText
Optional: Text displayed on text input notification button (from iOS 10 only).
Represents a notification that can be sent or received.
Image largeIcon
Optional: an additional large icon displayed in the notification content view.
BadgeIconType
Controls badge icon type to use if a notification is shown as a badge.
GroupAlertBehaviour
Controls sound and vibration behaviour for group notifications.
@ alertAll
both child notifications and group notifications should produce sound and vibration.
Progress progress
Optional: set to default (0, 0, false), to disable progress display.
Colour accentColour
Optional: sets accent colour.
String body
Required: the content of the notification, usually displayed in the second row.
String icon
Required: name of an icon file (without an extension) to be used for this notification.
TimestampVisibility
Controls timestamp visibility and format.
@ chronometer
Show chronometer as a stopwatch.
Array< int > vibrationPattern
Optional: sets the vibration pattern in milliseconds.
String groupId
Optional: allows the OS to visually group, collapse, and expand a set of notifications,...
Array< Action > actions
Optional: actions associated with the notification.
String channelId
Required for Android API level 26 or above: specifies notification channel id.
String tickerText
Optional: ticker text used for accessibility services.
String title
Required: the title of the notification, usually displayed in the first row.
String subtitle
Optional: additional text, that may be displayed e.g.
String person
Optional: additional metadata used as a hint to OS that a notification is related to a specific perso...
String identifier
Required: unique id that can be used to later dismiss the notification (on iOS available from version...
var properties
Optional: collection of additional properties that may be passed as a dictionary.
Type
Metadata that can be used by the OS to better handle the notification, depending on its priority.
@ taskProgress
Progress for a long-running background operation.
@ error
Error in background operation or authentication status.
@ system
System or device status update.
@ social
Social network or sharing update.
@ message
Incoming message (sms, instant message etc.).
@ recommendation
Specific, single thing related recommendation.
@ status
Ongoing information about device or contextual status.
@ call
Incoming voice/video call or similar.
String category
Required: determines set of actions that will appear (as per setup done in requestPermissionsWithSett...
std::unique_ptr< Notification > publicVersion
Optional: if you set lockScreenAppearance to showPartially, then you can provide "public version" of ...
String groupSortKey
Optional: Used to order notifications within the same group.
URL soundToPlay
Optional: empty when the notification should be silent.
Colour ledColour
Optional: Sets the led colour.
Priority
Metadata used as a hint to the OS about the priority of the notification.
LockScreenAppearance
Describes how to show the notification when the screen is locked.
Allows to control the time the device's led is on and off.
Used to represent a progress of some operation.