Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_PushNotifications.cpp 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. #if ! JUCE_ANDROID && ! JUCE_IOS && ! JUCE_MAC
  17. bool PushNotifications::Notification::isValid() const noexcept { return true; }
  18. #endif
  19. PushNotifications::Notification::Notification (const Notification& other)
  20. : identifier (other.identifier),
  21. title (other.title),
  22. body (other.body),
  23. subtitle (other.subtitle),
  24. groupId (other.groupId),
  25. badgeNumber (other.badgeNumber),
  26. soundToPlay (other.soundToPlay),
  27. properties (other.properties),
  28. category (other.category),
  29. triggerIntervalSec (other.triggerIntervalSec),
  30. repeat (other.repeat),
  31. icon (other.icon),
  32. channelId (other.channelId),
  33. largeIcon (other.largeIcon),
  34. tickerText (other.tickerText),
  35. actions (other.actions),
  36. progress (other.progress),
  37. person (other.person),
  38. type (other.type),
  39. priority (other.priority),
  40. lockScreenAppearance (other.lockScreenAppearance),
  41. publicVersion (other.publicVersion.get() != nullptr ? new Notification (*other.publicVersion) : nullptr),
  42. groupSortKey (other.groupSortKey),
  43. groupSummary (other.groupSummary),
  44. accentColour (other.accentColour),
  45. ledColour (other.ledColour),
  46. ledBlinkPattern (other.ledBlinkPattern),
  47. vibrationPattern (other.vibrationPattern),
  48. shouldAutoCancel (other.shouldAutoCancel),
  49. localOnly (other.localOnly),
  50. ongoing (other.ongoing),
  51. alertOnlyOnce (other.alertOnlyOnce),
  52. timestampVisibility (other.timestampVisibility),
  53. badgeIconType (other.badgeIconType),
  54. groupAlertBehaviour (other.groupAlertBehaviour),
  55. timeoutAfterMs (other.timeoutAfterMs)
  56. {
  57. }
  58. //==============================================================================
  59. JUCE_IMPLEMENT_SINGLETON (PushNotifications)
  60. PushNotifications::PushNotifications()
  61. #if JUCE_PUSH_NOTIFICATIONS
  62. : pimpl (new Pimpl (*this))
  63. #endif
  64. {
  65. }
  66. PushNotifications::~PushNotifications() { clearSingletonInstance(); }
  67. void PushNotifications::addListener (Listener* l) { listeners.add (l); }
  68. void PushNotifications::removeListener (Listener* l) { listeners.remove (l); }
  69. void PushNotifications::requestPermissionsWithSettings (const PushNotifications::Settings& settings)
  70. {
  71. #if JUCE_PUSH_NOTIFICATIONS && (JUCE_IOS || JUCE_MAC)
  72. pimpl->requestPermissionsWithSettings (settings);
  73. #else
  74. ignoreUnused (settings);
  75. listeners.call ([] (Listener& l) { l.notificationSettingsReceived ({}); });
  76. #endif
  77. }
  78. void PushNotifications::requestSettingsUsed()
  79. {
  80. #if JUCE_PUSH_NOTIFICATIONS && (JUCE_IOS || JUCE_MAC)
  81. pimpl->requestSettingsUsed();
  82. #else
  83. listeners.call ([] (Listener& l) { l.notificationSettingsReceived ({}); });
  84. #endif
  85. }
  86. bool PushNotifications::areNotificationsEnabled() const
  87. {
  88. #if JUCE_PUSH_NOTIFICATIONS
  89. return pimpl->areNotificationsEnabled();
  90. #else
  91. return false;
  92. #endif
  93. }
  94. void PushNotifications::getDeliveredNotifications() const
  95. {
  96. #if JUCE_PUSH_NOTIFICATIONS
  97. pimpl->getDeliveredNotifications();
  98. #endif
  99. }
  100. void PushNotifications::removeAllDeliveredNotifications()
  101. {
  102. #if JUCE_PUSH_NOTIFICATIONS
  103. pimpl->removeAllDeliveredNotifications();
  104. #endif
  105. }
  106. String PushNotifications::getDeviceToken() const
  107. {
  108. #if JUCE_PUSH_NOTIFICATIONS
  109. return pimpl->getDeviceToken();
  110. #else
  111. return {};
  112. #endif
  113. }
  114. void PushNotifications::setupChannels (const Array<ChannelGroup>& groups, const Array<Channel>& channels)
  115. {
  116. #if JUCE_PUSH_NOTIFICATIONS
  117. pimpl->setupChannels (groups, channels);
  118. #else
  119. ignoreUnused (groups, channels);
  120. #endif
  121. }
  122. void PushNotifications::getPendingLocalNotifications() const
  123. {
  124. #if JUCE_PUSH_NOTIFICATIONS
  125. pimpl->getPendingLocalNotifications();
  126. #endif
  127. }
  128. void PushNotifications::removeAllPendingLocalNotifications()
  129. {
  130. #if JUCE_PUSH_NOTIFICATIONS
  131. pimpl->removeAllPendingLocalNotifications();
  132. #endif
  133. }
  134. void PushNotifications::subscribeToTopic (const String& topic)
  135. {
  136. #if JUCE_PUSH_NOTIFICATIONS
  137. pimpl->subscribeToTopic (topic);
  138. #else
  139. ignoreUnused (topic);
  140. #endif
  141. }
  142. void PushNotifications::unsubscribeFromTopic (const String& topic)
  143. {
  144. #if JUCE_PUSH_NOTIFICATIONS
  145. pimpl->unsubscribeFromTopic (topic);
  146. #else
  147. ignoreUnused (topic);
  148. #endif
  149. }
  150. void PushNotifications::sendLocalNotification (const Notification& n)
  151. {
  152. #if JUCE_PUSH_NOTIFICATIONS
  153. pimpl->sendLocalNotification (n);
  154. #else
  155. ignoreUnused (n);
  156. #endif
  157. }
  158. void PushNotifications::removeDeliveredNotification (const String& identifier)
  159. {
  160. #if JUCE_PUSH_NOTIFICATIONS
  161. pimpl->removeDeliveredNotification (identifier);
  162. #else
  163. ignoreUnused (identifier);
  164. #endif
  165. }
  166. void PushNotifications::removePendingLocalNotification (const String& identifier)
  167. {
  168. #if JUCE_PUSH_NOTIFICATIONS
  169. pimpl->removePendingLocalNotification (identifier);
  170. #else
  171. ignoreUnused (identifier);
  172. #endif
  173. }
  174. void PushNotifications::sendUpstreamMessage (const String& serverSenderId,
  175. const String& collapseKey,
  176. const String& messageId,
  177. const String& messageType,
  178. int timeToLive,
  179. const StringPairArray& additionalData)
  180. {
  181. #if JUCE_PUSH_NOTIFICATIONS
  182. pimpl->sendUpstreamMessage (serverSenderId,
  183. collapseKey,
  184. messageId,
  185. messageType,
  186. timeToLive,
  187. additionalData);
  188. #else
  189. ignoreUnused (serverSenderId, collapseKey, messageId, messageType);
  190. ignoreUnused (timeToLive, additionalData);
  191. #endif
  192. }
  193. } // namespace juce