直接从支持iOS8 +的iOS应用重定向到通知设置 [英] Redirect to notification setting directly from iOS app that having support of iOS8+

查看:150
本文介绍了直接从支持iOS8 +的iOS应用重定向到通知设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是-如果用户关闭了该应用的通知,而用户当时打开了该应用,则它将为该应用的打开通知提供警报,当单击警报视图应用的确定"按钮时,它将重定向到通知屏幕,用户只需单击开关按钮即可打开通知.

My requirement is that - if notification for the app is turned off by user and user opens the app at that time it will give alert for turn on notification for the app and when click on okay button of alert view app will redirect to notification screen where user need to click on switch button only to turn on the notifications.

在ios8 +中可以吗?

Is it possible in ios8+ ?

我要重定向此屏幕

谢谢

推荐答案

此代码会将您重定向到通知设置.

This code will redirect you to setting of notifications.

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:^{}];
}

它将重定向到以下屏幕

这篇关于直接从支持iOS8 +的iOS应用重定向到通知设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆