Geçerli kullanıcı ayarlarının belirli bildirim türlerinden oluştuğunu kontrol etmek için bir yöntem yazıyorum.Kullanıcı izni verildiğinde, neden UIUserNotificationType.None geçerli ayarlarda doğrudur?
Geçerli ayarların UIUserNotificationsType.None içerip içermediğini denetlerken, hem izin verildiğinde hem de reddedildiğinde, doğru olarak döner. Bunun neden olduğunu bilen var mı?
func registerForAllNotificationTypes()
{
registerNotificationsForTypes([.Badge, .Alert, .Sound])
}
func registerNotificationsForTypes(types:UIUserNotificationType)
{
let settings = UIUserNotificationSettings.init(forTypes:types, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
}
func isRegisteredForAnyNotifications() -> Bool
{
let currentSettings = UIApplication.sharedApplication().currentUserNotificationSettings()
print(currentSettings)
print((currentSettings?.types.contains(.Alert))!)
print((currentSettings?.types.contains(.Badge))!)
print((currentSettings?.types.contains(.Sound))!)
print((currentSettings?.types.contains(.None))!)
return (currentSettings?.types.contains(.Alert))! //Just testing .Alert for now
}
izni üzerindedir: izni kapalı olduğunda
Optional(<UIUserNotificationSettings: 0x7fabdb719360; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>) true true true true
:
Optional(<UIUserNotificationSettings: 0x7f96d9f52140; types: (none);>) false false false true
Ben normalde davranıyor gibi (nasıl uygulandığı verilen) fakat yanıltıcı '.None' bir böcek gibi hissediyor hissediyorum. Eğer '.None' HER ZAMAN doğruysa, neden başlıyoruz? –