Inbox Authorization allows you to block the inbox from unauthorized users until they succsesfully log in to your app and become authorised to view the inbox.
1. User Authorization
With the usage of the setUserAuthorized(boolean) method you can easily inform the SDK if the given user is authorized or not. By default an user is always authorized.
Unauthorized users will not be able to enter the inbox in any way.
Example usage
authorizeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pulsateManager.setUserAuthorized(true);
}
});
unauthorizeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pulsateManager.setUserAuthorized(false);
}
});
2. Listening to unauthorized actions
With the usage of the setUserUnauthorizedListener method you can easily set an IPulsateUserUnauthorizedListener which will inform you whenever an unauthorized action happens.
Unauthorized action - trying to start the inbox in any way (via notification / in app message / showFeed method).
Example usage:
In your Application Class add the following code
@Override
public void onCreate() {
IPulsateManager manager = PulsateFactory.getInstance();
manager.setUserUnauthorizedListener(new IPulsateUserUnauthorizedListener() {
@Override
public void onUnauthorizedAction() {
//Your code goes here
}
});
}
Now every time an unauthorized user tries to enter the inbox the IPulsateUserUnauthorizedListener will receive a callback.
3. Showing Unauthorized messages
The showLastUnauthorizedMessage method allows you to show the last blocked inbox intent.
If the user clicked a notification with a new card, but was unauthorized the user will not see that card. After setting setUserAuthorized(true) call showLastUnauthorizedMessage and we will redirect the user to the card that was blocked.
If the user clicked a notification with a new message, but was unauthorized the user will not see that message. After setting setUserAuthorized(true) call showLastUnauthorizedMessage and we will redirect the user to the message that was blocked.
If the user tried to enter the inbox manually, but was unauthorized the inbox will not open. After setting setUserAuthorized(true) call showLastUnauthorizedMessage and we will redirect the user to the inbox.
authorizeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pulsateManager.setUserAuthorized(true);
pulsateManager.showLastUnauthorizedMessage();
}
});