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:

  1. Make sure the NeoDay SDK is configured and the user is authenticated with NeoDay.
  2. Call sdk.participate(with: ParticipationMethod.CodeSubmission(campaignId: campaignId, code: code), onCompletion: (Result<Boolean>) -> Unit), whereby the campaignId is the id of the Campaign it belongs to. And code is the full url that was passed into the app.
  3. If the code is successfully submitted, the NeoDayDeepLinkListener will be triggered and receive a factorymethod callback that returns a NeoDayViewController which you use to get a Composable view by calling NeoDayViewController.getView()?.invoke() within a Composable 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() }