The following example shows retrieving custom metadata using the Message.getMetadata() API. The example uses the canShow method of the PresentationDelegate, however you may retrieve the custom metadata anywhere within the delegate where the Message object is available.
Kotlin
Copied to your clipboardvar currentMessagePresentable: Presentable<InAppMessage>? = nulloverride fun canShow(presentable: Presentable<*>): Boolean {if (presentable.getPresentation() !is InAppMessage) {return}currentMessagePresentable = presentable as Presentable<InAppMessage>// Get the Message objectval message = MessagingUtils.getMessageForPresentable(currentMessagePresentable)// Retrieve the custom metadata as type Map<String, Any>val metadata = message?.metadata}
Java
Copied to your clipboardPresentable<InAppMessage> currentMessagePresentable = null;@Overridepublic void canShow(Presentable<?> presentable) {if (!(presentable.getPresentation() instanceof InAppMessage)) {return;}currentMessagePresentable = (Presentable<InAppMessage>) presentable;// Get the Message objectMessage message = MessagingUtils.getMessageForPresentable(currentMessagePresentable);// Retrieve the custom metadataif (message != null) {Map<String, Object> metadata = message.getMetadata();}}
The following example shows retrieving custom metadata using the Message.metadata API. The example uses the shouldShowMessage method of the MessagingDelegate, however you may retrieve the custom metadata anywhere within the delegate where the Message object is available.
Swift
Copied to your clipboardfunc shouldShowMessage(message: Showable) -> Bool {let fullscreenMessage = message as? FullscreenMessagelet message = fullscreenMessage?.parent// Retrieve the custom metadatalet metadata = message?.metadatareturn true}
