How To Integrate - prizeout/swift-builds GitHub Wiki
SDK Integration
The steps below assume you already have access to your Prizeout dashboard. If you’ve yet to receive dashboard access, please contact partner sales contact your partner support team directly.
There are various ways to integrate our widget into your application, your implementation team should help you choose the best method of integration based on your desired experience. Various aspects of the available integration options will be discussed here to help you make the best decision possible. Please consider the pros and cons of each implementation before making a choice, and if you have any questions please feel free to open a ticket and ask or reach out to [email protected] directly for more info.
Environments
Prizeout will provide you with two sets of credentials, your initial testing credentials will be for the sandbox
environment and once all your integration and testing work is completed you will be provided production
credentials. Environments for all Prizeout native resources can be set with the Environment
enum;
Environment.sandbox
Environment.production
PrizeoutViewController
Subclassing We provide a view controller that contains everything needed to load the widget into an empty view as long as you provide your credentials. The simplest implementation for sub-classing the PrizeoutViewController
would look as follows
import Prizeout
class ViewController: PrizeoutViewController {
override func viewDidLoad() {
do{
try super.setCredentials(sessionId: "XXXXXXXXXXX",
partnerId: "XXXXXXXXXXX",
partnerName:"XXXXXXXX",
apiKey: "XXXXXXXXXXX",
userId: "123",
email: "[email protected]",
balance: 2000,
environment:Environment.sandbox)
} catch {
print("Error Setting Credentials")
}
super.viewDidLoad()
}
}
Using Balance Bins
If you would prefer to pass across a range for your users balance you can do so with balance bins or by directly passing blanceMin
and balanceMax
working off the previous example you would switch it to one of the following:
directly passing balanceMin
and balanceMax
:
try super.setCredentials(sessionId: "1",
partnerId: "298dad54-4d58-4aba-a374-636ec1c8c991",
partnerName: "testPartner"
apiKey: "9c561f2285c1e4142ab41fa4de67b3f1",
userId: "123",
email: "[email protected]",
balanceMin: 1000,
balanceMax: 100000,
environment: Environment.sandbox)
using our pre-configured balance bins
try super.setCredentials(sessionId: "1",
partnerId: "298dad54-4d58-4aba-a374-636ec1c8c991",
partnerName: "testPartner"
apiKey: "9c561f2285c1e4142ab41fa4de67b3f1",
userId: "123",
email: "[email protected]",
balanceBin: BalanceBin.min1000000_max2500000,
environment: Environment.sandbox)
For reference our pre-configured balance bin options are
BalanceBin.min000_max10000
BalanceBin.min10000_max25000
BalanceBin.min25000_max50000
BalanceBin.min50000_max100000
BalanceBin.min100000_max250000
BalanceBin.min250000_max500000
BalanceBin.min500000_max1000000
BalanceBin.min1000000_max2500000
BalanceBin.min2500000_max5000000
BalanceBin.min5000000_maxUnlimited
Display options
When subclassing the view controller you should consider the various options for setting presentation style if you are presenting this modally to a user. As of iOS 13 Apple has a new default card style presentation for modals when left in the automatic
mode. This has the advantage of displaying our widget and allowing a top-down swipe exit leveraging the native functionality within iOS along with your override of the Prizeout onClose
function. You can also chose fullscreen
which will present the modal on the whole screen. You can leverage the onClose
override to then do any exit navigation you need to do.
Events
There are two events you can override in your subclass implementation of the view controller, one for each of our callbacks. You will need to override the onClose
method to control navigation out of the widget. Overriding of the onInit
method is optional.
func onClose
Your view controller should provide an override of the onClose
method where your code will navigate back to the appropriate place in your app. For example, if you are using a navigation controller and have pushed the PrizeoutViewController
onto the view stack you can dismiss it as follows:
override func onClose(){
self.dismiss(animated: true, completion: nil)
}
func onInit
This is the native override for our web onInit
callback, you can use this to deal with anything you might want to deal with in the background after the widget has initialized. There is no requirement to override this, it's provided for you if you need it.