The user is prompted to deny/grant permission for notifications:
screenshot
The app has a settings view where the user can toggle notifications. If the permission is not granted I want to point the user to the iOS settings (like WhatsApp does).
How do I check if the permissions got granted? Particularly in the case when a user grants permission but then decides to disable them from the iOS settings, not inside the app.
There is a wildly popular permissions plugin which sadly does not support this particular permission.
You can use DependencyService to check if notifications is enabled for the app.
In iOS:
[assembly: Dependency(typeof(DeviceService))]
class DeviceService : IDeviceService
{
public bool GetApplicationNotificationSettings()
{
var settings = UIApplication.SharedApplication.CurrentUserNotificationSettings.Types;
return settings != UIUserNotificationType.None;
}
}
In Forms:
public interface IDeviceService
{
bool GetApplicationNotificationSettings();
}
And after these, you can call your DependencyService from your page or view model like this:
bool isNotificationEnabled = DependencyService.Get<IDeviceService>().GetApplicationNotificationSettings();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With