NeoDay iOS SDK - How to
When to setup the NeoDay SDK
You can setup the NeoDay SDK as soon as the app starts. This means you don't have to authenticate your user until you have determined that they are logged in to your app.
If your app can be experienced whithout the user being logged in, you can authenticate with NeoDay, but keep in mind that in this state we do not know who your user is and not all functionality of the NeoDay SDK can be used, untill your user is authenticated with NeoDay.
Opening the app after QR code is scanned with camera app and going to a Gamification screen
The QR code contains the url and code that can be submitted to NeoDay for a certain Campaign. The ID of the Campaign must be known by your app.
Once your app has been configured to be opened by the Camera app and the url is extracted from this action. The following needs to be done:
- Make sure the NeoDay SDK is configured and the user is authenticated with NeoDay.
- Call sdk.partipate(with: .codeSubmission(campaignID: campaignID, code: code), whereby the campaignID is the id of the Campaign it belongs to. And code is the full url that was passed into the app.
- If the code is successfully submitted, the NeoDayDeepLinkDelegate will be triggered and receive a factorymethod for the gamificationCampaign (the game itself), which can be used to create the viewcontroller and then display it to the user.
Reference: Participating with a Campaign
Setting a Background Image on Campaigns Overview
To add a background image to a campaign, insert a UIImageView as the bottom-most subview of the view hierarchy. You can also adjust its content mode to fit your design.
let backgroundView = UIImageView(image: UIImage(named: "your_image"))
backgroundView.contentMode = .scaleAspectFill
viewController.view.insertSubview(backgroundView, at: 0)
Setting a Background Color on Campaigns Overview
viewController.view.backgroundColor = UIColor.blue
Full implementation sample:
sdk.makeCampaignsOverview(filter: .showOnly([.challenge, .gamification])) { [weak self] result in
guard let self = self else {
return
}
switch result {
case let .success(viewController):
// Set with background color
viewController.view.backgroundColor = UIColor.blue
// Or set with background image
let backgroundView = UIImageView(image: UIImage(named: "your_image"))
backgroundView.contentMode = .scaleAspectFill
viewController.view.insertSubview(backgroundView, at: 0)
// Display the viewController
case let .failure(error):
// Handle the error
}
}