Push Configuration

Follow the below steps to enable sending push notifications to your users

Consent for Push Notifications:

Starting from Android 13 and above, you need to explicitly ask users for their consent to receive push notifications.

  • Add this permission to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
  • If the device uses Android 12 or less, permission to send notifications is already granted. If the device uses Android 13 or above, you need to ask the user for permission.

Use the below code according to the user consent:

import com.contlo.androidsdk.permissions.ContloPermissions
val contloPermissions = ContloPermissions(applicationContext)

//If user grants permission, call this function

//If user denies or revokes the permission, call this function

  • Based upon the consent received, the function would subscribe or unsubscribe your Audience from Mobile Push on your Contlo Dashboard.

Add Contlo’s Push Notification Handler and Click Listener Service:

In your AndroidManifest.xml file, add the following code,

      <action android:name="com.google.firebase.MESSAGING_EVENT" />
  <service android:name="com.contlo.androidsdk.push.PushClicked" />

Setting up Mobile Push Credentials:

In your Firebase project, go to Project Settings and click on Service Account tabs, You would see a screen like this:

Clicking on Generate New Private Key will give you a json file with firebase admin SDK credentials. If you already generated one, use it for the next steps otherwise generate a new one.

Then in your Contlo Dashboard, go to settings and click on Mobile Push tab. You would see a screen like this:

Set the credentials according to your json file and save.