Skip to content

Handle In-app Content

To handle NearIT content in your app, override the onNewIntent and the onPostCreate methods of your LAUNCHER ACTIVITY:

override fun onPostCreate(savedInstanceState: Bundle?) {
    super.onPostCreate(savedInstanceState)

    onNewIntent(intent)
}

override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)

    if (NearUtils.carriesNearItContent(intent)) {
        // Show content in a dialog, on notification tap
        NearITUIBindings.onNewIntent(this, intent)
    } else {
        // Intent was not carrying NearIT in-app content
    }
}
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    onNewIntent(getIntent());
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    if (NearUtils.carriesNearItContent(intent)) {
        // Show content in a dialog, on notification tap
        NearITUIBindings.onNewIntent(this, intent);
    } else {
        // Intent was not carrying NearIT in-app content
    }
}

If you must handle NearIT Custom Json "What", refer to this documentation.

Showing content in a specific activity

If your launcher is a splash activity, and you wish to handle this intent in another activity, you should pass the intent extras with the NearIT content to the next activity. For example:

override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    intent?.let {
        if(NearUtils.carriesNearItContent(intent)) {
            val nextActivityIntent = Intent(this, NextActivity::class.java)
            nextActivityIntent.putExtras(it.extras)
            // eventually you can add other extras and flags to the intent
            startActivity(nextActivityIntent) 
        }
    }
}
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (NearUtils.carriesNearItContent(intent)) {
            Intent nextActivityIntent = new Intent(this, NextActivity.class);
            nextActivityIntent.putExtras(intent.getExtras());
            // eventually you can add other extras and flags to the intent
            startActivity(nextActivityIntent);
    }
}

If you want to customize or handle background notifications yourself, refer to this page.

Notification history

To show the user notification history, you can use our activity:

startActivity(NearITUIBindings.getInstance(this@NotificationsActivity)
                .notificationHistoryIntentBuilder()
                .build())
startActivity(NearITUIBindings.getInstance(this)
                .notificationHistoryIntentBuilder()
                .build());

or our fragment:

val couponFragment = NearITUIBindings.getInstance(this@YourActivity)
                .couponFragmentBuilder(coupon)
                .build()
Fragment inboxFragment = NearITUIBindings.getInstance(YourActivity.this)
                .inboxFragmentBuilder()
                .build();

This is the result:

history list

If you wish to customize the behaviour and look of our UI or to manually handle the user notification history, head over the notification history section.

If you want to get notified when new content is available (useful if you want to display a badge), you can register for messages updates. See the section for more info.

Coupon history

To show the user coupon history, you can use our activity:

startActivity(NearITUIBindings.getInstance(this@YourActivity)
                .couponListIntentBuilder()
                .setTitle("My coupon list")
                .build())
startActivity(NearITUIBindings.getInstance(YourActivity.this)
                .couponListIntentBuilder()
                .setTitle("My coupon list")
                .build());

or our fragment:

val notificationsFragment = NearITUIBindings.getInstance(this@YourActivity)
                .notificationHistoryFragmentBuilder()
                .build()
Fragment notificationHistoryFragment = NearITUIBindings.getInstance(YourActivity.this)
                .notificationHistoryFragmentBuilder()
                .build();

This is the result:

coupon list

If you wish to customize the behaviour and look of our UI or to manually handle the user coupons, head over to the coupon section.