Swift framework to embed native Product Button button.
We love using Product Hunt since it’s a really performing way to introduce our new projects. That’s why we’ve developed this little framework to embed Product Hunt badge. It’s a UIButton
subclass that uses Product Hunt API to synchronize the given votes count every 5 minutes.
Here is the introducing tweet:
Product Hunt iOS framework is now on @ProductHunt 🙌🏼✈️https://t.co/RKBUmlYJA1
— François (@frboulais) September 18, 2020
UIApplicationDelegate
:
import ProductHunt
PHManager
shared instance in your app’s application:didFinishLaunchingWithOptions:
method with:
PHButton
(either defined by slug or id)PHManager.shared.configure(forPost: .slug("timizer"), token: "Ou0qvqpdX7dT1Y4h4CSK3aKMW6-BaxzE6MxDNeop1Zk")
viewDidLoad
method to set the presenting view controller of the PHManager
object.
PHManager.shared.presentingViewController = self
PHButton
to your storyboard, XIB file, or instantiate it programmatically. To add the button to your storyboard or XIB file, add a View and set its custom class to PHButton
.
You want to add pod 'ProductHunt', '~> 1.0'
similar to the following to your Podfile:
target 'MyApp' do
pod 'ProductHunt', '~> 1.0'
end
Then run a pod install
inside your terminal, or from CocoaPods.app.