Skip to content

Content Notification

Content is the object for the notification with content, with the following getters and fields:

  • title returns the content title
  • contentString returns the text content
  • cta returns a ContentLink with a label and url fields.
  • getImageLink() returns an ImageSet object containing the links for the image

Basic example

If you want your app to display a NearIT content in a pop-up dialog, use this simple code:

startActivity(
        NearITUIBindings.getInstance(YourActivity.this)
            .contentIntentBuilder(content, trackingInfo)
            .build());
startActivity(
        NearITUIBindings.getInstance(this@YourActivity)
            .contentIntentBuilder(content, trackingInfo)
            .build())

where, content is an instance of NearIT SDK Content class and trackingInfo is an instance of TrackingInfo. The Content detail window will automatically track user tap on the content CTA Button.

Both instances get usually delivered together. If you don't have access to the trackingInfo instance you can call the builder with a null trackingInfo.

NearIT-UI content dialog

When the user taps on the button, the link will be opened: some types of link will be managed by a specific app, if that app is installed (e.g. a Facebook link).

Advanced examples

If you want to enable the tap-outside-to-close functionality, add .enableTapOutsideToClose() call on the builder, like the following example:

startActivity(
        NearITUIBindings.getInstance(YourActivity.this)
            .contentIntentBuilder(content, trackingInfo)
            .enableTapOutsideToClose()
            .build());
startActivity(
        NearITUIBindings.getInstance(this@YourActivity)
            .contentIntentBuilder(content, trackingInfo)
            .enableTapOutsideToClose()
            .build())

Links in contentString and CTA URL can be opened in web views without leaving the app (if the browser supports them):

startActivity(
        NearITUIBindings.getInstance(YourActivity.this)
            .contentIntentBuilder(content, trackingInfo)
            .openLinksInWebView()
            .build());
startActivity(
        NearITUIBindings.getInstance(this@YourActivity)
            .contentIntentBuilder(content, trackingInfo)
            .openLinksInWebView()
            .build())

Fragment mode

Optionally, you can display the content in your custom Activity by adding a Fragment to it. You can get a Fragment via another builder:

Fragment contentFragment = NearITUIBindings.getInstance(YourActivity.this)
    .contentFragmentBuilder(content, trackingInfo)
    .build();
val contentFragment: Fragment = NearITUIBindings.getInstance(this@YourActivity)
    .contentFragmentBuilder(content, trackingInfo)
    .build()



UI Customization

If you need to tweak the way your dialog looks, you can override some resources by name in your application. Here the complete list:

Content resources