我可以在用户拒绝时限制用户使用我的应用程序吗?比如推送通知

Can i restrict users from using my app when user has declined let say, like push notifications

我目前正在开发应用程序,在我看来需要推送通知,用户可以将其关闭,但应用程序需要它们,所以我只是向用户显示警报 "You need to allow push notifications to use this app",在 Android 和 IOS?有没有什么限制,比如"i have to let user use the app even when notifications turned off"

有一个名为 ContextCompat.checkSelfPermission() 的方法,您可以在 android 中使用它来在用户每次使用您的应用时自动检查。如下所示:

if (ContextCompat.checkSelfPermission(yourCurrentActivity, Manifest.permission.YOUR_PERMISSION)
    != PackageManager.PERMISSION_GRANTED) {
// Permission is not granted (You can perform whatever functionality you want to if permission is denied)
}

如果应用程序有权限,方法returns PERMISSION_GRANTED,应用程序可以继续操作。如果应用程序没有权限,方法 returns PERMISSION_DENIED,应用程序必须 明确地 请求用户权限。

您可以在 here.

中阅读更多内容

但是,IOS 应用程序并非如此。您 不能限制 应用程序使用特定权限,例如您的情况下的推送通知。您可以遵循一些 best practices. These are stringent guidelines from developers as well which you have to stick to. Read this 的 IOS 推送通知指南。

Apple 的应用审查指南:

4.5.4 Push Notifications must not be required for the app to function, and should not be used for advertising, promotions, or direct marketing purposes or to send sensitive personal or confidential information. Abuse of these services may result in revocation of your privileges.

https://developer.apple.com/app-store/review/guidelines/#design