{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","results":{"codes":[]},"params":[],"apiSetting":null},"next":{"description":"","pages":[]},"title":"Customizing Full Screen Messages","type":"basic","slug":"customizing-full-screen-messages","excerpt":"","body":"## Customizing the user interface\n\nSometimes, 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.\n\nOverride the following callback method, and return `false`, which ensures that Sailthru 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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"//On iOS, using Objective-C\\n\\n- (BOOL)shouldPresentMessageDetailForMessage:(STMMessage *)message {\\t\\n  // Do something with the message\\n  return NO;\\t\\n}\\n\\n//Be sure to assign your delegate to STMMessageStream\\n[[STMMessageStream new] setDelegate:self]\\n\\n\\n// This delegate is called anytime  presentMessageDetailForMessage: is called. Alternatively, just present your view controller manually.\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS (Objective-C)\"\n    },\n    {\n      \"code\": \"//On iOS, using Swift\\n\\nfunc shouldPresentMessageDetailForMessage(message: STMMessage) -> Bool {\\n\\treturn false\\n}\\n\\n//Be sure to assign your delegate to STMMessageStream\\nSTMMessageStream().setDelegate(self)\\n\\n// This delegate is called anytime presentMessageDetailForMessage: is called. Alternatively, just present your view controller manually.\",\n      \"language\": \"swift\",\n      \"name\": \"iOS (Swift)\"\n    },\n    {\n      \"code\": \"//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.\\n\\nIntent intent = new Intent(getApplicationContext(), MyMessageDetail.class);\\nint requestCode = 123;\\n\\nNotificationConfig config = new NotificationConfig();\\nconfig.setDefaultContentIntent(intent, requestCode, PendingIntent.FLAG_UPDATE_CURRENT);\\nnew SailthruMobile().setNotificationConfig(config);\\n\\n//If a push has a Message attached, the message will be added to the Intent's extras under SailthruMobile.EXTRA_PARCELABLE_MESSAGE.\\n\\nprotected void onResume() {\\n    super.onResume();\\n\\n    String messageId = getIntent().getStringExtra(MessageStream.EXTRA_MESSAGE_ID);\\n\\n    new MessageStream().getMessage(messageId, new MessageStream.MessageStreamHandler<Message>() {\\n        :::at:::Override\\n        public void onSuccess(Message value) {\\n            message = value;\\n            // Do stuff with the message\\n        }\\n\\n        @Override\\n        public void onFailure(Error error) {\\n            Log.e(TAG, \\\"Failed to load message: \\\" + error);\\n        }\\n    });\\n}\\n\\n\\n// For setting the Intent fired when a message in a message stream is tapped, intialise this as you normally would any other.\",\n      \"language\": \"java\",\n      \"name\": \"Android (Java)\"\n    },\n    {\n      \"code\": \"//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.\\nval intent = Intent(applicationContext, MyMessageDetail::class.java)\\nval requestCode = 123\\n\\nval config = NotificationConfig()\\nconfig.setDefaultContentIntent(intent, requestCode, PendingIntent.FLAG_UPDATE_CURRENT)\\nSailthruMobile().setNotificationConfig(config)\\n\\n//If a push has a Message attached, the message will be added to the Intent's extras under SailthruMobile.EXTRA_PARCELABLE_MESSAGE.\\n\\noverride fun onResume() {\\n    super.onResume()\\n    val messageId = intent.getStringExtra(MessageStream.EXTRA_MESSAGE_ID)\\n    MessageStream().getMessage(messageId, object : MessageStreamHandler<Message?> {\\n      fun onSuccess(value: Message) {\\n        message = value\\n        // Do stuff with the message\\n      }\\n\\n      override fun onFailure(error: Error?) {\\n        Log.e(TAG, \\\"Failed to load message: $error\\\")\\n      }\\n    })\\n}\\n\\n\\n// For setting the Intent fired when a message in a message stream is tapped, intialise this as you normally would any other.\",\n      \"language\": \"kotlin\",\n      \"name\": \"Android (Kotlin)\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Not available in React Native\",\n  \"body\": \"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.\"\n}\n[/block]\n## Registering an impression event\n\nIn 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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"//On iOS, using Objective-C\\n \\n[[STMMessageStream new] registerImpressionWithType:STMImpressionTypeDetailView forMessage:message];\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS (Objective-C)\"\n    },\n    {\n      \"code\": \"//On iOS, using Swift\\n\\nSTMMessageStream().registerImpressionWithType(STMImpressionType.DetailView, forMessage: message)\\n\",\n      \"language\": \"swift\",\n      \"name\": \"iOS (Swift)\"\n    },\n    {\n      \"code\": \"//On Android, using Java\\n\\nnew MessageStream().registerMessageImpression(ImpressionType.IMPRESSION_TYPE_DETAIL_VIEW, message);\\n\",\n      \"language\": \"java\",\n      \"name\": \"Android (Java)\"\n    },\n    {\n      \"code\": \"//On Android, using Kotlin\\n        MessageStream().registerMessageImpression(ImpressionType.IMPRESSION_TYPE_DETAIL_VIEW, message)\",\n      \"language\": \"kotlin\",\n      \"name\": \"Android (Kotlin)\"\n    },\n    {\n      \"code\": \"//On React Native, using JavaScript\\n\\nSailthruMobile.registerImpression(SailthruMobile.MessageImpressionType.DetailView, message);\",\n      \"language\": \"javascript\",\n      \"name\": \"React Native (JavaScript)\"\n    }\n  ]\n}\n[/block]","updates":["590fb8e335cf270f008e961d","5aa89154b7d085000fdb51e7"],"order":7,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5e6156bf5e4a51006dcd8161","project":"55e67aaa9cc7c62b00c4a1ea","user":"55d29988486de50d00327118","version":{"version":"1.5","version_clean":"1.5.0","codename":"ST Rebrand","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5e6156bf5e4a51006dcd8120","5e6156bf5e4a51006dcd8121","5e6156bf5e4a51006dcd8122","5e6156bf5e4a51006dcd8123","5e6156bf5e4a51006dcd8124","561c61b4ad272c0d00a892df","586c014c0abf1d0f000d04d4","58991d2ad207df0f0002186b","5e6156bf5e4a51006dcd8125","5e6156bf5e4a51006dcd8126","5af0fe494ca2730003cbc98a","5af0fe55ec80af0003804ca2","5e69868cbd5dcb006b35867b","5e6986ca2c6652006791b6e8"],"_id":"5e6156bf5e4a51006dcd818c","project":"55e67aaa9cc7c62b00c4a1ea","__v":2,"forked_from":"5b720760c44b7600034b7a08","createdAt":"2015-09-02T04:27:23.612Z","releaseDate":"2015-09-02T04:27:23.612Z"},"githubsync":"","parentDoc":null,"createdAt":"2016-08-14T22:32:26.795Z","__v":3,"category":{"sync":{"isSync":false,"url":""},"pages":["5e6156bf5e4a51006dcd812a","5e6156bf5e4a51006dcd812c","5e6156bf5e4a51006dcd812d","5e6156bf5e4a51006dcd812e","55e682b7de6fef23009480dc","5e6156bf5e4a51006dcd812f","5e6156bf5e4a51006dcd8130","5e6156bf5e4a51006dcd8131","5e6156bf5e4a51006dcd8132","5e6156bf5e4a51006dcd8133","5e6156bf5e4a51006dcd8134","5b720760c44b7600034b79bc","5e6156bf5e4a51006dcd8135","5e6156bf5e4a51006dcd8148","5e6156bf5e4a51006dcd8149","5e6156bf5e4a51006dcd814a","5e6156bf5e4a51006dcd814b","5e6156bf5e4a51006dcd814c","5e6156bf5e4a51006dcd814f","5e6156bf5e4a51006dcd8150","5e6156bf5e4a51006dcd8152","561c6ca0be5fb20d00077754","5e6156bf5e4a51006dcd8157","5e6156bf5e4a51006dcd8158","5b720760c44b7600034b79e2","5e6156bf5e4a51006dcd8159","5e6156bf5e4a51006dcd815a","5e6156bf5e4a51006dcd815b","5e6156bf5e4a51006dcd815c","56cfa5386c5d7a13005eec0f","56e73d86555c030e00a52a73","56e7460c9000b120000ffe2e","56e8c19e99c6400e003820cf","56e8c53fc88bf80e00f8bed8","56f06ff4d386ce0e008e9b21"],"title":"Install in your app","slug":"install-in-your-app","order":1,"from_sync":false,"reference":false,"_id":"5e6156bf5e4a51006dcd8121","__v":35,"createdAt":"2015-09-02T04:30:13.305Z","project":"55e67aaa9cc7c62b00c4a1ea","version":"5e6156bf5e4a51006dcd818c"}}

Customizing Full Screen Messages


## Customizing 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 Sailthru 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. [block:code] { "codes": [ { "code": "//On iOS, using Objective-C\n\n- (BOOL)shouldPresentMessageDetailForMessage:(STMMessage *)message {\t\n // Do something with the message\n return NO;\t\n}\n\n//Be sure to assign your delegate to STMMessageStream\n[[STMMessageStream new] setDelegate:self]\n\n\n// This delegate is called anytime presentMessageDetailForMessage: is called. Alternatively, just present your view controller manually.", "language": "objectivec", "name": "iOS (Objective-C)" }, { "code": "//On iOS, using Swift\n\nfunc shouldPresentMessageDetailForMessage(message: STMMessage) -> Bool {\n\treturn false\n}\n\n//Be sure to assign your delegate to STMMessageStream\nSTMMessageStream().setDelegate(self)\n\n// This delegate is called anytime presentMessageDetailForMessage: is called. Alternatively, just present your view controller manually.", "language": "swift", "name": "iOS (Swift)" }, { "code": "//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.\n\nIntent intent = new Intent(getApplicationContext(), MyMessageDetail.class);\nint requestCode = 123;\n\nNotificationConfig config = new NotificationConfig();\nconfig.setDefaultContentIntent(intent, requestCode, PendingIntent.FLAG_UPDATE_CURRENT);\nnew SailthruMobile().setNotificationConfig(config);\n\n//If a push has a Message attached, the message will be added to the Intent's extras under SailthruMobile.EXTRA_PARCELABLE_MESSAGE.\n\nprotected void onResume() {\n super.onResume();\n\n String messageId = getIntent().getStringExtra(MessageStream.EXTRA_MESSAGE_ID);\n\n new MessageStream().getMessage(messageId, new MessageStream.MessageStreamHandler<Message>() {\n @Override\n public void onSuccess(Message value) {\n message = value;\n // Do stuff with the message\n }\n\n @Override\n public void onFailure(Error error) {\n Log.e(TAG, \"Failed to load message: \" + error);\n }\n });\n}\n\n\n// For setting the Intent fired when a message in a message stream is tapped, intialise this as you normally would any other.", "language": "java", "name": "Android (Java)" }, { "code": "//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.\nval intent = Intent(applicationContext, MyMessageDetail::class.java)\nval requestCode = 123\n\nval config = NotificationConfig()\nconfig.setDefaultContentIntent(intent, requestCode, PendingIntent.FLAG_UPDATE_CURRENT)\nSailthruMobile().setNotificationConfig(config)\n\n//If a push has a Message attached, the message will be added to the Intent's extras under SailthruMobile.EXTRA_PARCELABLE_MESSAGE.\n\noverride fun onResume() {\n super.onResume()\n val messageId = intent.getStringExtra(MessageStream.EXTRA_MESSAGE_ID)\n MessageStream().getMessage(messageId, object : MessageStreamHandler<Message?> {\n fun onSuccess(value: Message) {\n message = value\n // Do stuff with the message\n }\n\n override fun onFailure(error: Error?) {\n Log.e(TAG, \"Failed to load message: $error\")\n }\n })\n}\n\n\n// For setting the Intent fired when a message in a message stream is tapped, intialise this as you normally would any other.", "language": "kotlin", "name": "Android (Kotlin)" } ] } [/block] [block:callout] { "type": "warning", "title": "Not available in React Native", "body": "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." } [/block] ## Registering 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. [block:code] { "codes": [ { "code": "//On iOS, using Objective-C\n \n[[STMMessageStream new] registerImpressionWithType:STMImpressionTypeDetailView forMessage:message];", "language": "objectivec", "name": "iOS (Objective-C)" }, { "code": "//On iOS, using Swift\n\nSTMMessageStream().registerImpressionWithType(STMImpressionType.DetailView, forMessage: message)\n", "language": "swift", "name": "iOS (Swift)" }, { "code": "//On Android, using Java\n\nnew MessageStream().registerMessageImpression(ImpressionType.IMPRESSION_TYPE_DETAIL_VIEW, message);\n", "language": "java", "name": "Android (Java)" }, { "code": "//On Android, using Kotlin\n MessageStream().registerMessageImpression(ImpressionType.IMPRESSION_TYPE_DETAIL_VIEW, message)", "language": "kotlin", "name": "Android (Kotlin)" }, { "code": "//On React Native, using JavaScript\n\nSailthruMobile.registerImpression(SailthruMobile.MessageImpressionType.DetailView, message);", "language": "javascript", "name": "React Native (JavaScript)" } ] } [/block]