提醒用户启用ios设置中的通知

提醒用户启用ios设置中的通知,ios,objective-c,push-notification,uialertview,Ios,Objective C,Push Notification,Uialertview,您好,在我的应用程序中,我有通知部分,用户可以使用交换机启用通知。首次启动后,当交换机上的任何用户从ios获得“不允许”或“确定”警报视图时。如果用户选择“不允许”,则交换机将关闭,用户将不会收到通知。现在,如果用户尝试打开开关,我想向用户显示一个警告,并显示文本“请启用来自设置的通知”。请任何人建议执行此操作的方法。您可以使用方法检查权限 对于UILocalNotification权限检查,如果用户不允许,types参数值将为none [[UIApplication sharedApplica

您好,在我的应用程序中,我有通知部分,用户可以使用交换机启用通知。首次启动后,当交换机上的任何用户从ios获得“不允许”或“确定”警报视图时。如果用户选择“不允许”,则交换机将关闭,用户将不会收到通知。现在,如果用户尝试打开开关,我想向用户显示一个警告,并显示文本“请启用来自设置的通知”。请任何人建议执行此操作的方法。

您可以使用方法检查权限


对于
UILocalNotification
权限检查,如果用户不允许,
types
参数值将为none

[[UIApplication sharedApplication] currentUserNotificationSettings]
应用程序共享应用程序]注册表通知设置:设置]

//[[UIApplicationsharedApplication]注册表项删除通知]

        if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]) {


            UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];

            if (types == UIUserNotificationTypeNone) {



            [_TransparentView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.8]];


              lblDescription.text=@"Please enable notifications from settings.";
            }

        }
    }

试试这个代码。它将适用于iOS 8.0更高版本和更早版本

 if (([[[UIDevice currentDevice] systemVersion] compare:8.0 options:NSNumericSearch] != NSOrderedAscending)) {
    if (![[UIApplication sharedApplication] isRegisteredForRemoteNotifications])
    {
        DisplayAlert(@"Please enable Permission from Settings->App Name->Notifications->Allow Notifications");
        return;
    }
}
else{
    UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    if (status == UIRemoteNotificationTypeNone)
    {
        DisplayAlert(@"Please enable Permission from Settings->App Name->Notifications->Allow Notifications");
        return;
    }
}
        UIUserNotificationType allNotificationTypes =
        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);

        UIUserNotificationSettings *settings =
        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIAp
        if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]) {


            UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];

            if (types == UIUserNotificationTypeNone) {



            [_TransparentView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.8]];


              lblDescription.text=@"Please enable notifications from settings.";
            }

        }
    }
 if (([[[UIDevice currentDevice] systemVersion] compare:8.0 options:NSNumericSearch] != NSOrderedAscending)) {
    if (![[UIApplication sharedApplication] isRegisteredForRemoteNotifications])
    {
        DisplayAlert(@"Please enable Permission from Settings->App Name->Notifications->Allow Notifications");
        return;
    }
}
else{
    UIRemoteNotificationType status = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    if (status == UIRemoteNotificationTypeNone)
    {
        DisplayAlert(@"Please enable Permission from Settings->App Name->Notifications->Allow Notifications");
        return;
    }
}