remotenotificationtype的iOS8上检查许可 [英] iOS8 check permission of remotenotificationtype
本文介绍了remotenotificationtype的iOS8上检查许可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以检查用户是否授权通知(警告)许可或不喜欢iOS8上之前:
I can check if user granted notification (alert) permission or not before iOS8 like that:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
//user granted
}
这是不是在iOS8上工作,它说:
it is not working on iOS8, it says:
iOS (3.0 and later) Deprecated:Register for user notification settings using the registerUserNotificationSettings: method instead.
控制台说:
enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.
让我怎么能检查它在iOS 8?
so how can I check it on iOS 8?
推荐答案
好吧,我解决我的问题是这样的:
Ok I solved my problem like this:
BOOL isgranted = false;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
isgranted = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
}
#else
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
isgranted = true;
}
#endif
这篇关于remotenotificationtype的iOS8上检查许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文