LMMS
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
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
108
109 //==============================================================================
112
115
122
126
127 int badgeNumber = 0;
146
148
150
151 //==============================================================================
154
157 double triggerIntervalSec = 0.;
158 bool repeat = false;
160
162
163 //==============================================================================
166
171
174
176
178
182
184 struct Progress
185 {
186 int max = 0;
188 int current = 0;
189 bool indeterminate = false;
191 };
192
194
215
218 {
220 low = -1,
222 high = 1,
224 };
225
229
232
240
242
243 std::unique_ptr<Notification> publicVersion;
247
249 bool groupSummary = false;
251
256
259 {
260 int msToBeOn = 0;
261 int msToBeOff = 0;
262 };
263
265
272
273 bool shouldAutoCancel = true;
274
275 bool localOnly = true;
277
278 bool ongoing = false;
282
283 bool alertOnlyOnce = false;
285
294
296
304
306
316
318
322 };
323
324
325 //==============================================================================
387 struct Settings
388 {
390
396 struct Category
397 {
398 juce::String identifier;
399 juce::Array<Action> actions;
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 //==============================================================================
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
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
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) { ignoreUnused (settings); }
605
609 virtual void pendingLocalNotificationsListReceived (const Array<Notification>& notifications) { ignoreUnused (notifications); }
610
625 virtual void handleNotification (bool isLocalNotification, const Notification& notification) { ignoreUnused (isLocalNotification); ignoreUnused (notification); }
626
641 virtual void handleNotificationAction (bool isLocalNotification,
642 const Notification& notification,
643 const String& actionIdentifier,
644 const String& optionalResponse)
645 {
646 ignoreUnused (isLocalNotification);
647 ignoreUnused (notification);
648 ignoreUnused (actionIdentifier);
649 ignoreUnused (optionalResponse);
650 }
651
655 virtual void localNotificationDismissedByUser (const Notification& notification) { ignoreUnused (notification); }
656
664 virtual void deliveredNotificationsListReceived (const Array<Notification>& notifications) { ignoreUnused (notifications); }
665
669 virtual void deviceTokenRefreshed (const String& token) { ignoreUnused (token); }
670
677
682 virtual void upstreamMessageSent (const String& messageId) { ignoreUnused (messageId); }
683
688 virtual void upstreamMessageSendingError (const String& messageId, const String& error) { ignoreUnused (messageId); ignoreUnused (error); }
689 };
690
691 void addListener (Listener* l);
692 void removeListener (Listener* l);
693
694private:
696 ~PushNotifications() override;
697
699
700 #if JUCE_ANDROID
701 friend bool juce_handleNotificationIntent (void*);
702
703 friend struct JuceFirebaseInstanceIdService;
704 friend struct JuceFirebaseMessagingService;
705 #endif
706
707 #if JUCE_PUSH_NOTIFICATIONS
708 struct Pimpl;
709 friend struct Pimpl;
710
711 std::unique_ptr<Pimpl> pimpl;
712 #endif
713};
714
715} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Array.h:56
Definition juce_Colour.h:38
DeletedAtShutdown()
Definition juce_DeletedAtShutdown.cpp:34
Definition juce_Image.h:58
Definition juce_ListenerList.h:70
Definition juce_PushNotifications.h:46
void setupChannels(const Array< ChannelGroup > &groups, const Array< Channel > &channels)
Definition juce_PushNotifications.cpp:140
ListenerList< PushNotifications::Listener > listeners
Definition juce_PushNotifications.h:698
void removePendingLocalNotification(const String &identifier)
Definition juce_PushNotifications.cpp:200
void getPendingLocalNotifications() const
Definition juce_PushNotifications.cpp:149
void removeAllPendingLocalNotifications()
Definition juce_PushNotifications.cpp:156
void subscribeToTopic(const String &topic)
Definition juce_PushNotifications.cpp:163
void getDeliveredNotifications() const
Definition juce_PushNotifications.cpp:117
void removeAllDeliveredNotifications()
Definition juce_PushNotifications.cpp:124
void removeDeliveredNotification(const String &identifier)
Definition juce_PushNotifications.cpp:191
bool areNotificationsEnabled() const
Definition juce_PushNotifications.cpp:108
void sendUpstreamMessage(const String &serverSenderId, const String &collapseKey, const String &messageId, const String &messageType, int timeToLive, const StringPairArray &additionalData)
Definition juce_PushNotifications.cpp:209
PushNotifications()
Definition juce_PushNotifications.cpp:77
void sendLocalNotification(const Notification &notification)
Definition juce_PushNotifications.cpp:182
void unsubscribeFromTopic(const String &topic)
Definition juce_PushNotifications.cpp:172
void requestSettingsUsed()
Definition juce_PushNotifications.cpp:99
void requestPermissionsWithSettings(const Settings &settings)
Definition juce_PushNotifications.cpp:89
String getDeviceToken() const
Definition juce_PushNotifications.cpp:131
Definition juce_StringArray.h:35
Definition juce_String.h:53
Definition juce_StringPairArray.h:35
Definition juce_URL.h:38
Definition juce_Variant.h:42
int * l
Definition inflate.c:1579
#define JUCE_DECLARE_SINGLETON(Classname, doNotRecreateAfterDeletion)
Definition juce_Singleton.h:184
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
Definition juce_PushNotifications.h:482
String identifier
Definition juce_PushNotifications.h:483
String name
Definition juce_PushNotifications.h:484
Definition juce_PushNotifications.h:447
String groupId
Definition juce_PushNotifications.h:466
bool canShowBadge
Definition juce_PushNotifications.h:469
Importance importance
Definition juce_PushNotifications.h:462
bool enableVibration
Definition juce_PushNotifications.h:471
String name
Definition juce_PushNotifications.h:449
Colour ledColour
Definition juce_PushNotifications.h:467
Importance
Definition juce_PushNotifications.h:453
@ min
Definition juce_PushNotifications.h:455
@ none
Definition juce_PushNotifications.h:454
@ low
Definition juce_PushNotifications.h:456
@ normal
Definition juce_PushNotifications.h:457
@ max
Definition juce_PushNotifications.h:459
@ high
Definition juce_PushNotifications.h:458
URL soundToPlay
Definition juce_PushNotifications.h:473
String description
Definition juce_PushNotifications.h:465
bool enableLights
Definition juce_PushNotifications.h:470
bool bypassDoNotDisturb
Definition juce_PushNotifications.h:468
Array< int > vibrationPattern
Definition juce_PushNotifications.h:474
Notification::LockScreenAppearance lockScreenAppearance
Definition juce_PushNotifications.h:463
String identifier
Definition juce_PushNotifications.h:448
Definition juce_PushNotifications.h:594
virtual void deliveredNotificationsListReceived(const Array< Notification > &notifications)
Definition juce_PushNotifications.h:664
virtual void pendingLocalNotificationsListReceived(const Array< Notification > &notifications)
Definition juce_PushNotifications.h:609
virtual void notificationSettingsReceived(const Settings &settings)
Definition juce_PushNotifications.h:604
virtual void upstreamMessageSendingError(const String &messageId, const String &error)
Definition juce_PushNotifications.h:688
virtual void remoteNotificationsDeleted()
Definition juce_PushNotifications.h:676
virtual void localNotificationDismissedByUser(const Notification &notification)
Definition juce_PushNotifications.h:655
virtual void handleNotification(bool isLocalNotification, const Notification &notification)
Definition juce_PushNotifications.h:625
virtual void deviceTokenRefreshed(const String &token)
Definition juce_PushNotifications.h:669
virtual void upstreamMessageSent(const String &messageId)
Definition juce_PushNotifications.h:682
virtual void handleNotificationAction(bool isLocalNotification, const Notification &notification, const String &actionIdentifier, const String &optionalResponse)
Definition juce_PushNotifications.h:641
Definition juce_PushNotifications.h:67
StringArray allowedResponses
Definition juce_PushNotifications.h:104
bool triggerInBackground
Definition juce_PushNotifications.h:88
String icon
Definition juce_PushNotifications.h:97
String textInputPlaceholder
Definition juce_PushNotifications.h:79
var parameters
Definition juce_PushNotifications.h:81
Style
Definition juce_PushNotifications.h:70
@ button
Definition juce_PushNotifications.h:71
@ text
Definition juce_PushNotifications.h:72
String title
Definition juce_PushNotifications.h:78
String identifier
Definition juce_PushNotifications.h:86
Style style
Definition juce_PushNotifications.h:77
bool destructive
Definition juce_PushNotifications.h:89
String textInputButtonText
Definition juce_PushNotifications.h:90
Definition juce_PushNotifications.h:185
int current
Definition juce_PushNotifications.h:188
int max
Definition juce_PushNotifications.h:186
bool indeterminate
Definition juce_PushNotifications.h:189
Definition juce_PushNotifications.h:55
Image largeIcon
Definition juce_PushNotifications.h:175
BadgeIconType
Definition juce_PushNotifications.h:299
@ small
Definition juce_PushNotifications.h:301
@ none
Definition juce_PushNotifications.h:300
@ large
Definition juce_PushNotifications.h:302
BadgeIconType badgeIconType
Definition juce_PushNotifications.h:305
GroupAlertBehaviour
Definition juce_PushNotifications.h:309
@ alertAll
Definition juce_PushNotifications.h:310
@ AlertChildren
Definition juce_PushNotifications.h:313
@ AlertSummary
Definition juce_PushNotifications.h:311
Progress progress
Definition juce_PushNotifications.h:193
Colour accentColour
Definition juce_PushNotifications.h:252
String body
Definition juce_PushNotifications.h:117
String icon
Definition juce_PushNotifications.h:167
TimestampVisibility
Definition juce_PushNotifications.h:288
@ normal
Definition juce_PushNotifications.h:290
@ countDownChronometer
Definition juce_PushNotifications.h:292
@ chronometer
Definition juce_PushNotifications.h:291
@ off
Definition juce_PushNotifications.h:289
bool localOnly
Definition juce_PushNotifications.h:275
Array< int > vibrationPattern
Definition juce_PushNotifications.h:266
String groupId
Definition juce_PushNotifications.h:123
TimestampVisibility timestampVisibility
Definition juce_PushNotifications.h:295
Array< Action > actions
Definition juce_PushNotifications.h:179
String channelId
Definition juce_PushNotifications.h:172
bool repeat
Definition juce_PushNotifications.h:158
int timeoutAfterMs
Definition juce_PushNotifications.h:319
GroupAlertBehaviour groupAlertBehaviour
Definition juce_PushNotifications.h:317
double triggerIntervalSec
Definition juce_PushNotifications.h:157
bool alertOnlyOnce
Definition juce_PushNotifications.h:283
int badgeNumber
Definition juce_PushNotifications.h:127
String tickerText
Definition juce_PushNotifications.h:177
Type type
Definition juce_PushNotifications.h:230
String title
Definition juce_PushNotifications.h:116
String subtitle
Definition juce_PushNotifications.h:118
String person
Definition juce_PushNotifications.h:226
bool groupSummary
Definition juce_PushNotifications.h:249
String identifier
Definition juce_PushNotifications.h:113
bool shouldAutoCancel
Definition juce_PushNotifications.h:273
var properties
Definition juce_PushNotifications.h:147
bool ongoing
Definition juce_PushNotifications.h:278
Priority priority
Definition juce_PushNotifications.h:231
Type
Definition juce_PushNotifications.h:197
@ email
Definition juce_PushNotifications.h:201
@ unspecified
Definition juce_PushNotifications.h:198
@ transport
Definition juce_PushNotifications.h:213
@ taskProgress
Definition juce_PushNotifications.h:205
@ error
Definition juce_PushNotifications.h:202
@ system
Definition juce_PushNotifications.h:212
@ promo
Definition juce_PushNotifications.h:206
@ social
Definition juce_PushNotifications.h:210
@ alarm
Definition juce_PushNotifications.h:199
@ reminder
Definition juce_PushNotifications.h:208
@ event
Definition juce_PushNotifications.h:203
@ message
Definition juce_PushNotifications.h:204
@ recommendation
Definition juce_PushNotifications.h:207
@ status
Definition juce_PushNotifications.h:211
@ call
Definition juce_PushNotifications.h:200
@ service
Definition juce_PushNotifications.h:209
String category
Definition juce_PushNotifications.h:155
std::unique_ptr< Notification > publicVersion
Definition juce_PushNotifications.h:243
bool isValid() const noexcept
Definition juce_PushNotifications.cpp:31
LockScreenAppearance lockScreenAppearance
Definition juce_PushNotifications.h:241
String groupSortKey
Definition juce_PushNotifications.h:248
LedBlinkPattern ledBlinkPattern
Definition juce_PushNotifications.h:264
URL soundToPlay
Definition juce_PushNotifications.h:128
Colour ledColour
Definition juce_PushNotifications.h:254
Priority
Definition juce_PushNotifications.h:218
@ high
Definition juce_PushNotifications.h:222
@ veryHigh
Definition juce_PushNotifications.h:223
@ medium
Definition juce_PushNotifications.h:221
@ veryLow
Definition juce_PushNotifications.h:219
@ low
Definition juce_PushNotifications.h:220
LockScreenAppearance
Definition juce_PushNotifications.h:235
@ showCompletely
Definition juce_PushNotifications.h:238
@ dontShow
Definition juce_PushNotifications.h:236
@ showPartially
Definition juce_PushNotifications.h:237
Definition juce_mac_PushNotifications.cpp:357
Definition juce_PushNotifications.h:397
juce::Array< Action > actions
Definition juce_PushNotifications.h:399
bool sendDismissAction
Definition juce_PushNotifications.h:400
juce::String identifier
Definition juce_PushNotifications.h:398
Definition juce_PushNotifications.h:388
Array< Category > categories
Definition juce_PushNotifications.h:406
Notification::Action Action
Definition juce_PushNotifications.h:389
bool allowAlert
Definition juce_PushNotifications.h:404
bool allowBadge
Definition juce_PushNotifications.h:405
bool allowSound
Definition juce_PushNotifications.h:403
int error
Definition extract.c:1038
#define const
Definition zconf.h:137