大佬教程收集整理的这篇文章主要介绍了推送通知开启或关闭在iOS中检查,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-(void)PushNotificationServiceChecking { UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types == UIRemoteNotificationTypeNone) { NSString *msg = @"Please press ON to enable Push Notification"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Push Notification Service Disable" message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ON",nil]; alert.tag = 2; [alert show]; } }
然后,我使用以下代码进入“设置”选项卡>>通知中心“,以便用户可以手动上:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 2) { if (buttonIndex == 0) { // this is the cancel button } else if (buttonIndex == 1) { [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert)]; } } }
但是,现在我面临的问题是,只有在第一次发布应用程序之后才会出现。它像我想要的那样工作。但之后,如果我从“设置”关闭“推送通知”选项,则不会显示“提示信息”。我该如何实现?如果有任何想法,请与我分享。
– 先谢谢了。
Technical Note TN2265: Troubleshooting Push Notifications
编辑:用于检查与警报启用 –
使用
if (types & UIRemoteNotificationTypeAlert){}
代替
if (types == UIRemoteNotificationTypeNone){}
编辑:
从doc for iOS 8 or later的最新更新,您可以查看:
- (BOOL)isRegisteredForRemoteNotifications
以上是大佬教程为你收集整理的推送通知开启或关闭在iOS中检查全部内容,希望文章能够帮你解决推送通知开启或关闭在iOS中检查所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。