我的要求是 - 如果用户关闭应用程序的通知并且用户当时打开应用程序,它将发出打开应用程序通知的警报,并且当单击警报 View 应用程序的“确定”按钮时将重定向到通知屏幕,用户只需单击开关按钮即可打开通知。
ios8+ 可以吗?
我想重定向此屏幕
谢谢
最佳答案
此代码会将您重定向到通知设置。
if ([[UIApplication sharedApplication] currentUserNotificationSettings].types != UIUserNotificationTypeNone)
{
NSLog(@" Push Notification ON");
}
else
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Push Notification Service Disable ,please enable it." message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Okay!" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)
{
@try
{
NSLog(@"tapped ok");
BOOL canOpenSettings = (UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings)
{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
}
@catch (NSException *exception)
{
}
}]];
[self.view presentViewController:alertController animated:YES completion:^{}];
}
它将重定向到以下屏幕
关于ios - 直接从支持 iOS8+ 的 iOS 应用程序重定向到通知设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33413745/