While Push automatically requests permissions before displaying a notification, you may sometimes wish to either manually request permission or view whether or not Push already has received permission to show notifications. Push uses an array of constants to keep track of its current permission level. These constants are as follows:
Push.Permission.DEFAULT; // 'default' Push.Permission.GRANTED; // 'granted' Push.Permission.DENIED; // 'denied'
To manually request notification permission, simply call:
onGranted is a callback function for if permision is granted, and
onDenied is a callback function for if, you guessed it, the permission is denied. Note that if
Permission.DEFAULT is returned, no callback is executed.
To find out whether or not Push has permission to show notifications, just call:
which will return a boolean value denoting permission.
Native Permission Levels
You can also get the raw permission level from the native API itself using:
This returns a string value which may or may not coincidentally be represented by Push’s constants. Use this info as you please.