Notification Runtime Permission
Android 13 (API level 33) and higher supports runtime permission for sending non-exempt (including Foreground Services (FGS)) notifications from an app. We recommend targeting Android 13 or higher as soon as possible to benefit from this feature's additional control and flexibility. Click here to learn more about push prompt notification permission.
Note
This feature will be available from the SDK Version: 5.3.10
How to configure the prompt in your app
Step 1 - Add the undermentioned import statements
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApi;
import com.notifyvisitors.notifyvisitors.interfaces.OnPushRuntimePermission;
import com.notifyvisitors.notifyvisitors.permission.NVPopupDesign;
Step 2 - Add the undermentioned code to your activity
NVPopupDesign design = new NVPopupDesign();
design.setTitle(“text”);
design.setTitleTextColor(“color_in_hexcode_format”);
design.setDescription(“text”);
design.setDescriptionTextColor(“color_in_hexcode_format”);
design.setBackgroundColor(“color_in_hexcode_format”);
design.setNumberOfSessions(count_as_integer);
design.setResumeInDays(days_as_integer);
design.setButtonOneBorderColor(“color_in_hexcode_format”);
design.setButtonOneBorderRadius(radius_as_integer);
design.setButtonOneText(“text”);
design.setButtonOneTextColor(“color_in_hexcode_format”);
design.setButtonOneBackgroundColor(“color_in_hexcode_format”);
design.setButtonTwoText(“text”);
design.setButtonTwoTextColor(“color_in_hexcode_format”);
design.setButtonTwoBackgroundColor(“color_in_hexcode_format”);
design.setButtonTwoBorderColor(“color_in_hexcode_format”);
design.setButtonTwoBorderRadius(radius_as_integer);
NotifyVisitorsApi.getInstance(context).activatePushPermissionPopup(design, new OnPushRuntimePermission() {
@Override
public void getPopupInfo(JSONObject result) {
//do your task here
}
});
Notice that there are two parameters in the function above namely numberOfSessions and resumeInDays. These two parameters will handle the flow of SDK’s push prompt permission (not system’s permission dialog).
numberOfSessions → This parameter takes integer as input. In NV SDK, new or next session is created either on first app launch or after 30 minutes of user’s inactivity. So, if you set 3, then prompt will be displayed for next 3 sessions including current session in case user denies the prompt in every attempt.
resumeInDays → This parameter takes integer as input. When numberOfSessions set by you is completed then resumeInDays parameter will work. This is used to control the time period in days after which you intend to show the prompt again to the user. So, if you set 10 then prompt will remain hidden for 10 days and from the 11th day onwards it will get displayed according to the condition set in numberOfSessions parameter.
Step 3 - Callback responses
STATUS
|
MESSAGE
|
Success |
Popup launched. User granted permission. |
Success |
Push permission is already active on this device. |
Fail |
According to the resumeInDays set by the user, next popup will be shown after <day> day(s). |
Fail |
Session count for popup set by the user has been exceeded. Next popup will resume after resumeInDays condition falls false. |
Fail
|
Session count for popup set by the user has been exceeded. Next popup will resume after resumeInDays condition falls false.
|
Fail
|
Popup launched. User denied SDK's custom popup permission.
|
Fail
|
Popup launched. User denied permission.
|
Fail
|
Something went wrong with error --> <error>
|
Error
|
Failed with error :: <error>
|
Error
|
Something went wrong while launching popup with error :: <error>
|
Error
|
Something went wrong with error -----> <error>
|
Step 4 - Example
NVPopupDesign design = new NVPopupDesign();
design.setTitle("Get Notified \uD83D\uDD14");
design.setTitleTextColor("#000000");
design.setDescription("Please Enable Push Notifications on Your Device For Latest Updates !!");
design.setDescriptionTextColor("#000000");
design.setBackgroundColor("#EBEDEF");
design.setButtonOneBorderColor("#6db76c");
design.setButtonOneBackgroundColor("#26a524");
design.setButtonOneBorderRadius(25);
design.setButtonOneText("Allow");
design.setButtonOneTextColor("#FFFFFF");
design.setButtonTwoText("Deny");
design.setButtonTwoTextColor("#FFFFFF");
design.setButtonTwoBackgroundColor(“#FF0000”);
design.setButtonTwoBorderColor(“#6db76c”);
design.setButtonTwoBorderRadius(25);
design.setNumberOfSessions(2);
design.setResumeInDays(1);
NotifyVisitorsApi.getInstance(context).activatePushPermissionPopup(design, new OnPushRuntimePermission() {
@Override
public void getPopupInfo(JSONObject result) {
Log.d("App", "Popup Result => " + result);
}
});
Step 5 - Output with callback

{
"status":"success",
"message":"Popup launched. User granted permission."
}
Updated about 2 months ago