-
public class NotificationPermissionHelper extends BroadcastReceiver
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringPERMISSION_NOTIFICATION
-
Method Summary
Modifier and Type Method Description booleanisNotificationPermissionGranted(Context context)voidrequestPermission(@NonNull() Context context, boolean handleTargetLowerThan13, @Nullable() BroadcastReceiver receiver)Request the Android 13 notification runtime permissionTODO: Test this method. booleanisPermissionAlreadyAskedFromOlderSDK(@NonNull() Context context)voidrequestPermissionFromOlderSDK(@NonNull() Context context)Request the permission the google way: by creating the notification channel.If the App is running in background at this moment (eg: receiving a push for the first time),the user will be prompted when app goes back in foreground.Note: if the user has a channel id override, this will not work. voidonReceive(Context context, Intent intent)Broadcast receiver to handle the permission result -
Methods inherited from class android.content.BroadcastReceiver
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, onReceive, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
isNotificationPermissionGranted
boolean isNotificationPermissionGranted(Context context)
-
requestPermission
void requestPermission(@NonNull() Context context, boolean handleTargetLowerThan13, @Nullable() BroadcastReceiver receiver)
Request the Android 13 notification runtime permissionTODO: Test this method. Can't be done until Android T is supported in Robolectric
- Parameters:
context- contexthandleTargetLowerThan13- whether we should trigger the permission request for an app targeting lower than Android 13.
-
isPermissionAlreadyAskedFromOlderSDK
boolean isPermissionAlreadyAskedFromOlderSDK(@NonNull() Context context)
-
requestPermissionFromOlderSDK
void requestPermissionFromOlderSDK(@NonNull() Context context)
Request the permission the google way: by creating the notification channel.If the App is running in background at this moment (eg: receiving a push for the first time),the user will be prompted when app goes back in foreground.Note: if the user has a channel id override, this will not work.
- Parameters:
context- context
-
-
-
-