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.8KB

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