系统将提示用户拒绝/授予通知权限:
screenshot
该应用程序有一个设置视图,用户可以在其中切换通知。如果权限未被授予,我希望将用户指向iOS设置(就像WhatsApp一样)。
如何检查是否已授予权限?特别是当用户赠款权限,但随后决定从iOS设置中禁用它们时,而不是在应用程序内。
有一个非常流行的permissions plugin,它不支持这个特定的权限。
系统将提示用户拒绝/授予通知权限:
screenshot
该应用程序有一个设置视图,用户可以在其中切换通知。如果权限未被授予,我希望将用户指向iOS设置(就像WhatsApp一样)。
如何检查是否已授予权限?特别是当用户赠款权限,但随后决定从iOS设置中禁用它们时,而不是在应用程序内。
有一个非常流行的permissions plugin,它不支持这个特定的权限。
4条答案
按热度按时间hc2pp10m1#
您可以使用DependencyService检查是否为应用启用了通知。
在iOS中:
形式:
在这些之后,您可以从您的页面或视图模型调用DependencyService,如下所示:
vddsk6oq2#
基本上,您需要在每个应用程序运行时请求授权。因此,如果你需要的话,你可以知道授权状态,并将用户导航到你的应用的ios设置。
如果该方法被赋予了权限,则该方法将在每次运行时返回true。如果它改变了,它将返回false。
hgtggwj03#
试试这个:
或者你可以这样做(对于Android和iOS):https://dotnetco.de/open-app-settings-in-xamarin-forms/
erhoui1w4#
更全面的通知设置检查: