Releases: sailthru/sailthru-mobile-android-sdk
v3.3.4
Message Activity Debugging
The WebView content in the MessageActivity will now be debuggable via Chrome's remote debugging tools when built in debug mode (On by default when building the application from Android Studio, and disabled automatically upon release).
See Remote Debugging WebViews for more information on how this works.
Bugfixes
- Fixed an unlikely
NullPointerException
in the Message Activity when loading on slow connections.
v3.3.3
v3.3.2
v3.3.1
Dependencies Update
Updated the following dependencies:
com.google.android.gms:play-services-gcm
-> 9.2.0com.android.support:support-v4
-> 24.1.1
If your application has trouble using the v24 support libraries, you can force gradle to use a previous version with the following snippet added to your application module's gradle file:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:23.4.0'
}
}
v3.3.0
NotificationConfig
For setting the Intent fired when a notification is interacted with, NotificationConfig#setDefaultContentIntent(PendingIntent)
has been deprecated in favor of NotificationConfig#setDefaultContentIntent(Intent, int, int)
so that push payload data can be added to the PendingIntent when the Notification is built.
Intent intent = new Intent(getApplicationContext(), MyMessageDetail.class);
int requestCode = 123;
NotificationConfig config = new NotificationConfig();
config.setDefaultContentIntent(intent, requestCode, PendingIntent.FLAG_UPDATE_CURRENT);
If a push has a Message attached, the message will be added to the Intent's extras under Carnival.EXTRA_PARCELABLE_MESSAGE
.
protected void onResume() {
super.onResume();
Message message = getIntent().getParcelableExtra(Carnival.EXTRA_PARCELABLE_MESSAGE);
}
Warning: Using the deprecated
#setDefaultContentIntent(PendingIntent)
will not pass through the push payload to your content intent.
CarnivalNotificationExtender
The now public CarnivalNotificationExtender
can be used to format a NotificationCompat.Builder
using the details of a given Message from Carnival along with respecting the settings set using NotificationConfig
. This can be used if you want more control over your notifications using CarnivalMessageListener
but don't want to build the notification from scratch.
public boolean onMessageReceived(Context context, Bundle bundle, Message message) {
int notificationId = 123;
CarnivalNotificationExtender extender = new CarnivalNotificationExtender(context);
extender.setMessage(message);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.addExtras(bundle);
builder.extend(extender);
//Customize your notification...
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(notificationId, builder.build());
//return true to prevent Carnival from publishing its own notification.
return true;
}
v3.2.1 GO!
v3.2.0
Action Support on NotificationConfig
Actions can now be pre-defined for push notifications using the new addAction()
method. Actions are grouped by a "category" attribute that is sent as a part of the push bundle. When a notification arrives that contains a matching category attribute, the push data is injected into the action's intent and attached to the notification.
//This Intent must explicitly define an Activity, Service, or BroadcastReceiver class.
Intent actionIntent = new Intent(this, MyBroadcastReceiver.class);
NotificationConfig config = new NotificationConfig();
config.addAction(
"category", // Action Category
R.drawable.ic_action_reply, // Action Icon
"Reply", // Action Text
actionIntent, // Intent that is fired upon tap.
PendingIntent.FLAG_UPDATE_CURRENT // PendingIntent Flags
);
Carnival.setNotificationConfig(config);
To add more Actions to a category, call addAction()
for each action and set them all with the same category.
RemoteInput
NotificationConfig#addAction(String, int, CharSequence, Intent, RemoteInput, int)
AddAction()
has an optional RemoteInput
parameter that allows for user input to be included in the data that is sent. See RemoteInput in the Android Documentation for more information, and see Direct Reply For how to handle inline replies.
Responding to Actions
Inside the bundle that is sent to the intent defined in addAction()
is a valued called "_nid"
. The hashcode of _nid
is the identifier for the notification in the system tray.
public void onReceive(Context context, Intent intent) {
String notificationId = intent.getStringExtra("_nid");
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(notificationId.hashCode());
}
Another option is to use getActiveNotifications()
to get a reference to update the notification.
Formatted Message Text
Messages now contain a new method getHtmlText()
to return HTML formatted text for a Message that contained markdown. This can be set directly into a TextField using Html.fromHtml()
.
TextView textView = ...;
textView.setText(Html.fromHtml(message.getHtmlText()));
Bug Fixes
- Fixed an issue with notification sounds not loading when the file extension was included.
- Fixed an issue that caused deep links from In-App Notifications to not work in some cases.
- Improved Event batching.
v3.1.2
v3.1.1
v3.1.0
New Custom Attributes API
All singular Carnival.setAttribute()
methods have been deprecated in favour of AttributeMap
and Carnival.setAttributes(AttributeMap, AttributesHandler)
AttributeMap map = new AttributeMap();
map.putString("myKey", "myString");
map.putInt("myInt", 123);
map.setMergeRules(AttributeMap.RULE_REPLACE);
Carnival.setAttributes(map, handler);
Attribute Merge Rules
By default setAttributes
will merge the attributes you are setting with the existing attributes on the device. Updating existing attributes and creating new ones as needed. If the merge rules are set to AttributeMap.RULE_REPLACE
then the contents of this map will totally replace all attributes on the device.
Setting a value to null
will remove that attribute from the device, while setting attributes with an empty AttributeMap
and merge rule RULE_REPLACE
will delete all attributes from the device.
JSON Constructor
AttributeMap(JSONObject)
will populate a map with the contents of the JSONObject
. String, Boolean, Integer, and Float types are supported along with their array counterparts when they are represented by a JSONArray
. Any values that do not conform to this are simply ignored.
Notification Config
More notification options are now available via the NotificationConfig
class. These setting are used for building every notification handled by Carnival.
Carnival.setNotificationIcon()
for setting a notification icon has been deprecated in favour ofNotificationConfig#setSmallIcon(int)
Carnival.setNotificationResponder()
for setting the intent fired by the notification has been deprecated in favour ofNotificationConfig#setDefaultContentIntent(PendingIntent)
NotificationConfig config = new NotificationConfig();
config.setColor(Color.MAGENTA);
config.setSmallIcon(R.drawable.ic_stat_notification);
Carnival.setNotificationConfig(config);