The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

191 lines
5.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. #if ! JUCE_ANDROID && ! JUCE_IOS
  23. bool PushNotifications::Notification::isValid() const noexcept { return true; }
  24. #endif
  25. //==============================================================================
  26. juce_ImplementSingleton (PushNotifications)
  27. PushNotifications::PushNotifications()
  28. #if JUCE_PUSH_NOTIFICATIONS
  29. : pimpl (new Pimpl (*this))
  30. #endif
  31. {
  32. }
  33. PushNotifications::~PushNotifications() { clearSingletonInstance(); }
  34. void PushNotifications::addListener (Listener* l) { listeners.add (l); }
  35. void PushNotifications::removeListener (Listener* l) { listeners.remove (l); }
  36. void PushNotifications::requestPermissionsWithSettings (const PushNotifications::Settings& settings)
  37. {
  38. #if JUCE_PUSH_NOTIFICATIONS && JUCE_IOS
  39. pimpl->requestPermissionsWithSettings (settings);
  40. #else
  41. ignoreUnused (settings);
  42. listeners.call (&PushNotifications::Listener::notificationSettingsReceived, {});
  43. #endif
  44. }
  45. void PushNotifications::requestSettingsUsed()
  46. {
  47. #if JUCE_PUSH_NOTIFICATIONS && JUCE_IOS
  48. pimpl->requestSettingsUsed();
  49. #else
  50. listeners.call (&PushNotifications::Listener::notificationSettingsReceived, {});
  51. #endif
  52. }
  53. bool PushNotifications::areNotificationsEnabled() const
  54. {
  55. #if JUCE_PUSH_NOTIFICATIONS
  56. return pimpl->areNotificationsEnabled();
  57. #else
  58. return false;
  59. #endif
  60. }
  61. void PushNotifications::getDeliveredNotifications() const
  62. {
  63. #if JUCE_PUSH_NOTIFICATIONS
  64. pimpl->getDeliveredNotifications();
  65. #endif
  66. }
  67. void PushNotifications::removeAllDeliveredNotifications()
  68. {
  69. #if JUCE_PUSH_NOTIFICATIONS
  70. pimpl->removeAllDeliveredNotifications();
  71. #endif
  72. }
  73. String PushNotifications::getDeviceToken() const
  74. {
  75. #if JUCE_PUSH_NOTIFICATIONS
  76. return pimpl->getDeviceToken();
  77. #else
  78. return {};
  79. #endif
  80. }
  81. void PushNotifications::setupChannels (const Array<ChannelGroup>& groups, const Array<Channel>& channels)
  82. {
  83. #if JUCE_PUSH_NOTIFICATIONS
  84. pimpl->setupChannels (groups, channels);
  85. #else
  86. ignoreUnused (groups, channels);
  87. #endif
  88. }
  89. void PushNotifications::getPendingLocalNotifications() const
  90. {
  91. #if JUCE_PUSH_NOTIFICATIONS
  92. pimpl->getPendingLocalNotifications();
  93. #endif
  94. }
  95. void PushNotifications::removeAllPendingLocalNotifications()
  96. {
  97. #if JUCE_PUSH_NOTIFICATIONS
  98. pimpl->removeAllPendingLocalNotifications();
  99. #endif
  100. }
  101. void PushNotifications::subscribeToTopic (const String& topic)
  102. {
  103. #if JUCE_PUSH_NOTIFICATIONS
  104. pimpl->subscribeToTopic (topic);
  105. #else
  106. ignoreUnused (topic);
  107. #endif
  108. }
  109. void PushNotifications::unsubscribeFromTopic (const String& topic)
  110. {
  111. #if JUCE_PUSH_NOTIFICATIONS
  112. pimpl->unsubscribeFromTopic (topic);
  113. #else
  114. ignoreUnused (topic);
  115. #endif
  116. }
  117. void PushNotifications::sendLocalNotification (const Notification& n)
  118. {
  119. #if JUCE_PUSH_NOTIFICATIONS
  120. pimpl->sendLocalNotification (n);
  121. #else
  122. ignoreUnused (n);
  123. #endif
  124. }
  125. void PushNotifications::removeDeliveredNotification (const String& identifier)
  126. {
  127. #if JUCE_PUSH_NOTIFICATIONS
  128. pimpl->removeDeliveredNotification (identifier);
  129. #else
  130. ignoreUnused (identifier);
  131. #endif
  132. }
  133. void PushNotifications::removePendingLocalNotification (const String& identifier)
  134. {
  135. #if JUCE_PUSH_NOTIFICATIONS
  136. pimpl->removePendingLocalNotification (identifier);
  137. #else
  138. ignoreUnused (identifier);
  139. #endif
  140. }
  141. void PushNotifications::sendUpstreamMessage (const String& serverSenderId,
  142. const String& collapseKey,
  143. const String& messageId,
  144. const String& messageType,
  145. int timeToLive,
  146. const StringPairArray& additionalData)
  147. {
  148. #if JUCE_PUSH_NOTIFICATIONS
  149. pimpl->sendUpstreamMessage (serverSenderId,
  150. collapseKey,
  151. messageId,
  152. messageType,
  153. timeToLive,
  154. additionalData);
  155. #else
  156. ignoreUnused (serverSenderId, collapseKey, messageId, messageType);
  157. ignoreUnused (timeToLive, additionalData);
  158. #endif
  159. }
  160. } // namespace juce