Question: I have integrated Pushwoosh SDK and I am able to receive pushes. However when I open a push with Rich Media from a closed app, it first opens my SplashScreenActivity, shows a Rich Media, then a second Activity is opened and hides Rich Media. My goal is to show our Rich media message also in my second activity. How can I achieve it?
Answer: You can achive this behavior by using a custom RichMediaPresentingDelegate. The general idea is to intercept received Rich Media messages when a push is opened, save it inside your application and present it when your MainActivity is shown.
- Implement a
RichMediaPresentingDelegate
and override itsshouldPresent
method - it should save received rich media to the singleton and return false - In your MainActivity check if the RichMedia in Application singleton is not null, and, if it is not, pass this value to
RichMediaManager.present(RichMedia richMedia)
method. - Set Rich Media in singleton back to null
Here are few code snippets:
MyApplication.java:
public class TestingApp extends Application {
private static TestingApp testingApp;
private RichMedia _richMedia;
public static TestingApp getTestingApp() {
return testingApp;
}
public RichMedia get_richMedia() {
return _richMedia;
}
@Override
public void onCreate() {
super.onCreate();
testingApp = this;
RichMediaManager.setDelegate(new RichMediaPresentingDelegate() {
@Override
public boolean shouldPresent(RichMedia richMedia) {
_richMedia = richMedia;
return false;
}
@Override
public void onPresent(RichMedia richMedia) {
}
@Override
public void onError(RichMedia richMedia, PushwooshException pushwooshException) {
}
@Override
public void onClose(RichMedia richMedia) {
}
});
}
}
Then, your MainActivity.java you can show a Rich Media:
RichMedia richMedia = TestingApp.getTestingApp().get_richMedia(); if(richMedia!=null){
RichMediaManager.present(richMedia);
}
Comments
0 comments
Please sign in to leave a comment.