Customize Full Screen Messages

Customize the User Interface

Sometimes, you might want to implement your own user interface for a full screen message that more closely matches the look and feel of your UI. Override the following callback method, and return false, which ensures that Mobile's interface isn't displayed. At this point you can construct your own full screen message interface using the STMMessage object in iOS or 'Message' object in Android.

iOS (Objective-C)

//On iOS, using Objective-C

- (BOOL)shouldPresentMessageDetailForMessage:(STMMessage *)message {  
  // Do something with the message
  return NO;  
}

//Be sure to assign your delegate to STMMessageStream
[[STMMessageStream new] setDelegate:self]


// This delegate is called anytime  presentMessageDetailForMessage: is called. Alternatively, just present your view controller manually.

iOS (Swift)

//On iOS, using Swift

func shouldPresentMessageDetailForMessage(message: STMMessage) -> Bool {
  return false
}

//Be sure to assign your delegate to STMMessageStream
STMMessageStream().setDelegate(self)

// This delegate is called anytime presentMessageDetailForMessage: is called. Alternatively, just present your view controller manually.

Android (Java)

//For setting the Intent fired when a notification is interacted with, use 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);
new SailthruMobile().setNotificationConfig(config);

//If a push has a Message attached, the message will be added to the Intent's extras under SailthruMobile.EXTRA_PARCELABLE_MESSAGE.

protected void onResume() {
    super.onResume();

    String messageId = getIntent().getStringExtra(MessageStream.EXTRA_MESSAGE_ID);

    new MessageStream().getMessage(messageId, new MessageStream.MessageStreamHandler<message>() {
        @Override
        public void onSuccess(Message value) {
            message = value;
            // Do stuff with the message
        }

        @Override
        public void onFailure(Error error) {
            Log.e(TAG, "Failed to load message: " + error);
        }
    });
}


// For setting the Intent fired when a message in a message stream is tapped, intialise this as you normally would any other.</message>

Android (Kotlin)

//For setting the Intent fired when a notification is interacted with, use NotificationConfig#setDefaultContentIntent(Intent, int, int) so that push payload data can be added to the PendingIntent when the Notification is built.
val intent = Intent(applicationContext, MyMessageDetail::class.java)
val requestCode = 123

val config = NotificationConfig()
config.setDefaultContentIntent(intent, requestCode, PendingIntent.FLAG_UPDATE_CURRENT)
SailthruMobile().setNotificationConfig(config)

//If a push has a Message attached, the message will be added to the Intent's extras under SailthruMobile.EXTRA_PARCELABLE_MESSAGE.

override fun onResume() {
    super.onResume()
    val messageId = intent.getStringExtra(MessageStream.EXTRA_MESSAGE_ID)
    MessageStream().getMessage(messageId, object : MessageStreamHandler<Message?> {
      fun onSuccess(value: Message) {
        message = value
        // Do stuff with the message
      }

      override fun onFailure(error: Error?) {
        Log.e(TAG, "Failed to load message: $error")
      }
    })
}


// For setting the Intent fired when a message in a message stream is tapped, intialise this as you normally would any other.
Not available in React Native Due to limitations of current plugin architecture in React Native, it is not currently possible to override the stock experience for in-app notifications. Rest assured, you can still deliver these notifications, but you won't be able to customize their UX. We hope to bring customization to this platform in the near future.

Register an Impression Event

In order to support impression analytics in your custom in-app notification, you will need to ensure you register an impression event when it is shown.

iOS (Objective-C)

//On iOS, using Objective-C
 
[[STMMessageStream new] registerImpressionWithType:STMImpressionTypeDetailView forMessage:message];

iOS (Swift)

//On iOS, using Swift

STMMessageStream().registerImpressionWithType(STMImpressionType.DetailView, forMessage: message)

Android (Java)

//On Android, using Java

new MessageStream().registerMessageImpression(ImpressionType.IMPRESSION_TYPE_DETAIL_VIEW, message);

Android (Kotlin)

//On Android, using Kotlin
        MessageStream().registerMessageImpression(ImpressionType.IMPRESSION_TYPE_DETAIL_VIEW, message)

React Native (JavaScript)

//On React Native, using JavaScript

SailthruMobile.registerImpression(SailthruMobile.MessageImpressionType.DetailView, message);

Contact us

Top