Reteno.initWithConfig(
RetenoConfig.Builder()
.accessKey(...)
.defaultNotificationChannelConfig { builder ->
builder
.setName("Custom name")
.setDescription("Custom description")
.setImportance(NotificationManagerCompat.IMPORTANCE_HIGH)
.setLightColor(Color.RED)
.setLightsEnabled(true)
.setShowBadge(true)
.setVibrationEnabled(true)
.setVibrationPattern(longArrayOf())
.setSound(...)
}
.build()
Reteno.initWithConfig(
new RetenoConfig.Builder()
.accessKey(...)
.defaultNotificationChannelConfig((builder) -> {
builder
.setName("Custom name")
.setDescription("Custom description")
.setImportance(NotificationManagerCompat.IMPORTANCE_HIGH)
.setLightColor(Color.RED)
.setLightsEnabled(true)
.setShowBadge(true)
.setVibrationEnabled(true)
.setVibrationPattern(longArrayOf())
.setSound(...);
return Unit.INSTANCE;
})
.build()
To customize channel parameters for existing users, use:
RetenoNotifications.updateDefaultNotificationChannel(
name = "New name",
description = "New description"
)
RetenoNotifications.updateDefaultNotificationChannel(
"New name",
"New description"
);
For handling deeplinks on Android12+, keep in mind the recent changes as explained at developer.android.com
Also, make sure to set up the proper intent filter for your activity developer.android.com
You can pass your custom data in push notifications using the "Custom data" box at eSputnik admin panel. You can handle this custom data payload in the Launcher activity or the activity that handles deeplinks in the onCreate
or onNewIntent
methods. Custom data is delivered via intent extras.
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
val customDataValue = intent?.extras?.getString("customDataKey")
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String customDataValue = intent.getExtras().getString("customDataKey");
}
In Reteno admin dashboard you may select up to 10 images to be sent with push notification. On Android platform the notification will be shown as a DecoratedCustomViewStyle. Images will be scaled to 500x250px in order to satisfy the Android OS limits. The carousel will flip images automatically with 2500ms interval.
If you wish to handle the notification click events, you can create a BroadcastReceiver component object and declare it in your AndroidManifest.xml
file:
<!-- Add this Receiver to listen to PushReceived events -->
<receiver
android:name="com.example.CustomReceiverPushReceived"
android:enabled="true"
android:exported="true"/>
<meta-data
android:name="com.reteno.Receiver.PushReceived"
android:value="com.example.CustomReceiverPushReceived" />
<!-- Add this Receiver to listen to NotificationClicked events -->
<receiver
android:name="com.example.CustomReceiverNotificationClicked"
android:enabled="true"
android:exported="true"/>
<meta-data
android:name="com.reteno.Receiver.NotificationClicked"
android:value="com.example.CustomReceiverNotificationClicked" />
Where com.example.CustomReceiverPushReceived
and com.example.CustomReceiverNotificationClicked
are your receivers.
It is important to add a <meta-data>
tag containing the com.reteno.Receiver.PushReceived
and com.reteno.Receiver.NotificationClicked
names of your receivers so that the SDK will be able to trigger them.
Your receivers will receive a bundle containing the data payload that you send from the Reteno admin panel using the Custom data
box.
override fun onReceive(context: Context?, intent: Intent?) {
val customDataValue = intent?.extras?.getString("customDataKey");
}
@Override
public void onReceive(Context context, Intent intent) {
String customDataValue = intent.getExtras().getString("customDataKey");
}
The intent.getExtras()
is the method, with the help of which we get the Bundle
object. From the Bundle
object, we get the string from the {"data":{"custom_data":"text for test"}}
JSON payload by the data
key.
As an app developer you may want to send not only Reteno
-marketing push notifications to your user, but your own pushes. These may be push notifications related to your app-specific functionality, like chat, calendar events, incoming call notification, etc. In this case just create a custom Broadcast receiver and register it in the AndroidManifest.xml
with the following intent-filter:
<receiver
android:name="com.reteno.sample.CustomPushReceiver"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="com.reteno.custom-push" />
</intent-filter>
</receiver>
Then just receive the notification's data payload in the Bundle under onReceive method of your BroadcastReceiver.
Important
- Don't send custom push notifications with
notification
block in JSON body. Usedata
only. This will guarantee that the BroadcastReceiver receives your data payload consistently.WRONG
{ "to": "FCM_token", "notification":{ "title":"Title_here", "body":"Body_here" } }
RIGHT
{ "to": "FCM_token", "data":{ "Name" : "John", "Room" : 4, "Building" : 3 } }
- Don't send the following key in your
data
payloades_interaction_id
.WRONG
{ "to": "FCM_token", "data":{ "Name" : "John", "es_interaction_id" : 123 } }