NeoDay Android SDK - How to
When to setup the NeoDay SDK
You can setup the NeoDay SDK as soon as the app starts - preferably, in your Application class. 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, until 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.participate(with: ParticipationMethod.CodeSubmission(campaignId: campaignId, code: code), onCompletion: (Result<Boolean>) -> Unit)
, whereby thecampaignId
is the id of the Campaign it belongs to. Andcode
is the full url that was passed into the app. - If the code is successfully submitted, the
NeoDayDeepLinkListener
will be triggered and receive afactorymethod
callback that returns aNeoDayViewController
which you use to get aComposable
view by callingNeoDayViewController.getView()?.invoke()
within aComposable
method.
Reference: Participating with a Campaign
Setting a Background Image on NeoDayViewController
To add a background image to a NeoDayViewController, you need to use the NeoDayViewController.background
and inject a composable image.
@Composable
fun BackgroundImage() {
Image(
painter = painterResource(R.drawable.background_image),
contentDescription = "Background image"
)
}
viewController.background = { BackgroundImage() }
Setting a Background Color on NeoDayViewController
To set the background color of the NeoDayViewController, you need to use the NeoDayViewController.background
and inject a composable with Modifier.background(<Color>)
and Modifier.fillMaxSize
configured.
@Composable
fun BackgroundColor() {
Box(
modifier = Modifier
.fillMaxSize() // you need to use fillMaxSize to cover the whole view controller.
.background(Color.Red)
)
}
viewController.background = { BackgroundColor() }