我在我的应用程序中使用 UILocalNotification 来安排通知。通知工作正常,并在我需要时显示。我对此没有意见。我没有做任何远程/推送通知。
让我感到疑惑的是,我从未见过您通常在多个应用程序中看到的用于推送通知的著名权限对话框。我什至重置了我的设备并运行了我的应用程序。这仍然没有导致权限对话框出现。
如果您的应用仅使用本地通知,是否不会显示此权限对话框,或者我是否未实现某种实际导致应用请求此权限的方法?
我知道我可以在应用程序启动后实现我自己的对话框,询问用户此权限,但我希望 Apple 会处理这个问题,尤其是因为它在“设置”应用程序中对远程和本地通知的处理方式相同。
最佳答案
是的,在 iOS8 中,本地通知确实需要权限。
The documentation对于registerUserNotificationSettings:规定
If your app displays alerts, play sounds, or badges its icon while in the background, you must call this method during your launch cycle to request permission to alert the user in those ways. Typically, you make this request if your app uses local or push notifications to alert the user to new information involving your app.
It is recommended that you call this method before you schedule any local notifications or register with the push notification service.
关于swift - 本地通知是否需要 iOS 上的用户权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16048837/