commit 55dfef7e663e1936fdd5a43766cc6fd7fbbaca56
parent b4a41352efb67499417acd611aeb276bd2d7632c
Author: jatinchowdhury18 <[email protected]>
Date: Mon, 19 Apr 2021 07:49:52 -0700
Add IAP Tip Jar for iOS (#190)
* Attempt to add tip jar IAP
* Attempt to submit IAPs for App Store review
* IAP tests are working, clean up debug code
* Update iOS builds
* {Apply clang-format}
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat:
10 files changed, 95 insertions(+), 6 deletions(-)
diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.15)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment target")
set(CMAKE_CXX_STANDARD 17)
-project(CHOWTapeModel VERSION 2.7.7)
+project(CHOWTapeModel VERSION 2.7.9)
add_subdirectory(modules)
include_directories(modules/RTNeural)
@@ -21,6 +21,7 @@ if(IOS)
MICROPHONE_PERMISSION_ENABLED TRUE
IPHONE_SCREEN_ORIENTATIONS UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight
IPAD_SCREEN_ORIENTATIONS UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight
+ NEEDS_STORE_KIT TRUE
)
else()
juce_add_plugin(CHOWTapeModel
@@ -74,9 +75,11 @@ if(IOS)
set_target_properties(CHOWTapeModel_Standalone PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
- XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
+ XCODE_ATTRIBUTE_SKIP_INSTALL "NO"
+ XCODE_ATTRIBUTE_ENABLE_IN_APP_PURCHASE "YES")
set_target_properties(CHOWTapeModel_AUv3 PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)/CHOWTapeModel.app/PlugIns"
- XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
+ XCODE_ATTRIBUTE_SKIP_INSTALL "NO"
+ XCODE_ATTRIBUTE_ENABLE_IN_APP_PURCHASE "YES")
endif()
diff --git a/Plugin/Source/GUI/Assets/gui_ios.xml b/Plugin/Source/GUI/Assets/gui_ios.xml
@@ -287,6 +287,7 @@
margin="0" parameter="mix_group" combo-background="00000000"
tooltip="Adds this plugin to a mix group. When the plugin is added to a group, the group parameters will be copied to this plugin, and their parameters will remain in sync."/>
<MixGroupViz flex-grow="0.3" margin="5" padding="0" background-color="00000000"/>
+ <TipJar flex-grow="0.75" margin="0" padding="0" background-color="00000000" lookAndFeel="ComboBoxLNF"/>
</View>
</View>
</magic>
diff --git a/Plugin/Source/GUI/CMakeLists.txt b/Plugin/Source/GUI/CMakeLists.txt
@@ -1,8 +1,6 @@
target_sources(CHOWTapeModel PRIVATE
AutoUpdating.cpp
- DragToScrollListener.cpp
MyLNF.cpp
- ScrollView.cpp
TitleComp.cpp
TooltipComp.cpp
WowFlutterMenu.cpp
@@ -14,3 +12,10 @@ target_sources(CHOWTapeModel PRIVATE
Visualizers/MixGroupViz.cpp
Visualizers/TapeScope.cpp
)
+
+if(IOS)
+ target_sources(CHOWTapeModel PRIVATE
+ IOSOnly/DragToScrollListener.cpp
+ IOSOnly/ScrollView.cpp
+ )
+endif()
diff --git a/Plugin/Source/GUI/DragToScrollListener.cpp b/Plugin/Source/GUI/IOSOnly/DragToScrollListener.cpp
diff --git a/Plugin/Source/GUI/DragToScrollListener.h b/Plugin/Source/GUI/IOSOnly/DragToScrollListener.h
diff --git a/Plugin/Source/GUI/ScrollView.cpp b/Plugin/Source/GUI/IOSOnly/ScrollView.cpp
diff --git a/Plugin/Source/GUI/ScrollView.h b/Plugin/Source/GUI/IOSOnly/ScrollView.h
diff --git a/Plugin/Source/GUI/IOSOnly/TipJar.h b/Plugin/Source/GUI/IOSOnly/TipJar.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#include <JuceHeader.h>
+
+class TipJar : public ComboBox
+{
+public:
+ TipJar()
+ {
+ productInfos = {
+ { "Small Tip ($2)", "chowtape_small_tip_123" },
+ { "Medium Tip ($5)", "chowtape_medium_tip_456" },
+ { "Large Tip ($10)", "chowtape_large_tip_789" },
+ { "Huge Tip ($25)", "chowtape_huge_tip_808" },
+ };
+
+ if (! InAppPurchases::getInstance()->isInAppPurchasesSupported())
+ {
+ // this should never happen, since we only enable IAPs on iOS!
+ jassertfalse;
+ return;
+ }
+
+ setTextWhenNothingSelected ("Tip Jar");
+ setColour (backgroundColourId, Colours::transparentBlack);
+ setJustificationType (Justification::centred);
+
+ auto rootMenu = getRootMenu();
+ StringArray purchaseIDs;
+ for (auto& info : productInfos)
+ {
+ rootMenu->addItem (info.first, [=] { doTipPurchase (info.second); });
+ purchaseIDs.add (info.second);
+ }
+
+ InAppPurchases::getInstance()->getProductsInformation (purchaseIDs);
+ }
+
+ void doTipPurchase (const String& id)
+ {
+ InAppPurchases::getInstance()->purchaseProduct (id);
+ setText ("Tip Jar");
+ };
+
+private:
+ std::vector<std::pair<String, String>> productInfos;
+
+ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TipJar)
+};
+
+class TipJarItem : public foleys::GuiItem
+{
+public:
+ FOLEYS_DECLARE_GUI_FACTORY (TipJarItem)
+
+ TipJarItem (foleys::MagicGUIBuilder& builder, const ValueTree& node) : foleys::GuiItem (builder, node)
+ {
+ addAndMakeVisible (tipJar);
+ }
+
+ void update() override {}
+
+ Component* getWrappedComponent() override { return &tipJar; }
+
+private:
+ TipJar tipJar;
+
+ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TipJarItem)
+};
diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp
@@ -10,12 +10,16 @@
#include "PluginProcessor.h"
#include "GUI/OnOff/PowerButton.h"
-#include "GUI/ScrollView.h"
#include "GUI/TitleComp.h"
#include "GUI/TooltipComp.h"
#include "GUI/Visualizers/MixGroupViz.h"
#include "GUI/WowFlutterMenu.h"
+#if JUCE_IOS
+#include "GUI/IOSOnly/ScrollView.h"
+#include "GUI/IOSOnly/TipJar.h"
+#endif
+
namespace
{
constexpr int maxNumPresets = 999;
@@ -318,6 +322,7 @@ AudioProcessorEditor* ChowtapeModelAudioProcessor::createEditor()
#if JUCE_IOS
builder->registerFactory ("ScrollView", &ScrollView::factory);
+ builder->registerFactory ("TipJar", &TipJarItem::factory);
auto* editor = new foleys::MagicPluginEditor (magicState, BinaryData::gui_ios_xml, BinaryData::gui_ios_xmlSize, std::move (builder));
#else
auto* editor = new foleys::MagicPluginEditor (magicState, BinaryData::gui_xml, BinaryData::gui_xmlSize, std::move (builder));
diff --git a/Plugin/modules/CMakeLists.txt b/Plugin/modules/CMakeLists.txt
@@ -59,3 +59,9 @@ set_target_properties(juce_plugin_modules PROPERTIES
C_VISBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
+
+if(IOS)
+ target_link_libraries(juce_plugin_modules PRIVATE juce::juce_product_unlocking)
+ target_link_libraries(juce_plugin_modules PRIVATE "-framework StoreKit")
+ target_compile_definitions(juce_plugin_modules PUBLIC JUCE_IN_APP_PURCHASES=1)
+endif()