public final class AppboyInAppMessageManager extends AppboyInAppMessageManagerBase
IInAppMessageManagerListener.onInAppMessageReceived(com.appboy.models.IInAppMessage)
method is called (if set). If this method returns true, that signals to the AppboyInAppMessageManager that
the in-app message will be handled by the host app and that it should not be displayed by the
AppboyInAppMessageManager. This method should be used if you choose to display the in-app message in a custom
way. If false is returned, the AppboyInAppMessageManager attempts to display the in-app message.
If there is already an in-app message being displayed, the new in-app message will be put onto the top of the
stack and can be displayed at a later time. If there is no in-app message being displayed, then the
IInAppMessageManagerListener.beforeInAppMessageDisplayed(com.appboy.models.IInAppMessage)
will be called. The InAppMessageOperation
return value can be used to
control when the in-app message should be displayed. A suggested usage of this method would be to delay
in-app message messages in certain parts of the app by returning InAppMessageOperation.DISPLAY_LATER
when in-app message would be distracting to the users app experience. If the method returns
InAppMessageOperation.DISPLAY_NOW
then the in-app message will be displayed
immediately.
The IInAppMessageManagerListener.onInAppMessageClicked(com.appboy.models.IInAppMessage, InAppMessageCloser)
and IInAppMessageManagerListener.onInAppMessageDismissed(com.appboy.models.IInAppMessage)
methods can be used to override the default click and dismiss behavior.
By default, in-app messages fade in and out from view. The slideup type of in-app message slides in and out of view
can be dismissed by swiping the view horizontally. If the in-app message's DismissType is set to AUTO_DISMISS,
then the in-app message will animate out of view once the set duration time has elapsed.
The default view used to display slideup, modal, and full in-app messages
is defined by res/layout/com_appboy_inappmessage_*.xml, where * is the message type. In
order to use a custom view, you must create a custom view factory using the
AppboyInAppMessageManagerBase.setCustomInAppMessageViewFactory(IInAppMessageViewFactory inAppMessageViewFactory)
method.
A new in-app message View
object is created when a in-app message is displayed and also
when the user navigates away to another Activity
. This happens so that the
Activity can be garbage collected and does not create a memory leak. For that reason, the
registerInAppMessageManager(android.app.Activity)
and unregisterInAppMessageManager(android.app.Activity)
must be called in the Activity.onResume()
and Activity.onPause()
methods of every Activity.Constructor and Description |
---|
AppboyInAppMessageManager() |
Modifier and Type | Method and Description |
---|---|
void |
addInAppMessage(IInAppMessage inAppMessage)
Provides a in-app message that will then be handled by the in-app message manager.
|
void |
ensureSubscribedToInAppMessageEvents(android.content.Context context)
Ensures the InAppMessageManager is subscribed in-app message events if not already subscribed.
|
static AppboyInAppMessageManager |
getInstance() |
boolean |
getIsCurrentlyDisplayingInAppMessage()
Gets whether an in-app message is currently displaying on the device.
|
void |
hideCurrentlyDisplayingInAppMessage(boolean dismissed)
Hides any currently displaying in-app message.
|
void |
registerInAppMessageManager(android.app.Activity activity)
Registers the in-app message manager, which will listen to and display incoming in-app messages.
|
boolean |
requestDisplayInAppMessage()
Asks the InAppMessageManager to display the next in-app message if one is not currently being displayed.
|
void |
resetAfterInAppMessageClose()
Resets the
AppboyInAppMessageManager to its original state before the last in-app message
was displayed. |
void |
unregisterInAppMessageManager(android.app.Activity activity)
Unregisters the in-app message manager.
|
getActivity, getApplicationContext, getControlInAppMessageManagerListener, getDefaultInAppMessageViewFactory, getDoesBackButtonDismissInAppMessageView, getDoesClickOutsideModalViewDismissInAppMessageView, getHtmlInAppMessageActionListener, getInAppMessageAnimationFactory, getInAppMessageManagerListener, getInAppMessageViewFactory, getInAppMessageViewWrapperFactory, setBackButtonDismissesInAppMessageView, setClickOutsideModalViewDismissInAppMessageView, setCustomControlInAppMessageManagerListener, setCustomHtmlInAppMessageActionListener, setCustomInAppMessageAnimationFactory, setCustomInAppMessageManagerListener, setCustomInAppMessageViewFactory, setCustomInAppMessageViewWrapperFactory
public static AppboyInAppMessageManager getInstance()
public void ensureSubscribedToInAppMessageEvents(android.content.Context context)
context
- The application contextpublic void registerInAppMessageManager(android.app.Activity activity)
ensureSubscribedToInAppMessageEvents(Context)
.
To be sure that no in-app messages are lost, you should call ensureSubscribedToInAppMessageEvents(Context)
as early
as possible in your app, preferably in your Application.onCreate()
.activity
- The current Activity.public void unregisterInAppMessageManager(android.app.Activity activity)
activity
- The current Activity.public void addInAppMessage(IInAppMessage inAppMessage)
inAppMessage
- The in-app message to add.public boolean requestDisplayInAppMessage()
public void hideCurrentlyDisplayingInAppMessage(boolean dismissed)
dismissed
- whether the message was dismissed by the user. If dismissed is true,
IInAppMessageViewLifecycleListener.onDismissed() will be called on the current
IInAppMessageViewLifecycleListener.public void resetAfterInAppMessageClose()
AppboyInAppMessageManager
to its original state before the last in-app message
was displayed. This allows for a new in-app message to be displayed after calling this method.
ViewUtils.setActivityRequestedOrientation(Activity, int)
is called with the original
orientation before the last in-app message was displayed.public boolean getIsCurrentlyDisplayingInAppMessage()