内容简介:判断用户是否打开了推送然后如果用户没有打开推送按钮跳转到应用相关设置页面
判断用户是否打开了推送
#pragma mark - 是否开启APP推送
/**是否开启推送*/
+ (BOOL)isSwitchAppNotification {
if (IOS_VERSION >= 10.0) {
__block BOOL result = NO;
//异步线程中操作是否完成
__block BOOL inThreadOperationComplete = NO;
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
if (settings.authorizationStatus == UNAuthorizationStatusDenied) {
result = NO;
}else if (settings.authorizationStatus == UNAuthorizationStatusNotDetermined) {
result = NO;
}else if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
result = YES;
}else {
result = NO;
}
inThreadOperationComplete = YES;
}];
while (!inThreadOperationComplete) {
[NSThread sleepForTimeInterval:0];
}
return result;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
else if (IOS_VERSION >= 8.0)
{
UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (UIUserNotificationTypeNone != setting.types) {
return YES;
}else {
return NO;
}
}else
{
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if(UIRemoteNotificationTypeNone != type) {
return YES;
}else {
return NO;
}
}
#pragma clang diagnostic pop
}
然后如果用户没有打开推送按钮
跳转到应用相关设置页面
if (switch.on) {
if (IOS_VERSION >= 10.0) {
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:url options:@{} completionHandler:^(BOOL success) {
}];
}else{
//[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]] 应用标识
NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"prefs:root=%@",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]]];
[[UIApplication sharedApplication]openURL:url];
}
}
参考资料
作者:wwwwwwdi
链接:https://www.jianshu.com/p/16d2cdefb9cd
以上所述就是小编给大家介绍的《iOS应用内跳转系统推送设置页》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- iOS 推送通知及推送扩展
- 安卓统一推送联盟明日开启推送通道测试
- 《Web 推送通知》系列翻译 | 第五篇:使用 Web 推送库发送消息 && 第六篇:Web 推送协议
- 推送系统从0到1(七):推送用户画像建立
- 推送系统从0到1(八):个性化精准推送的实现
- 重构推送服务
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
无处安放的互联网隐私
【美】茱莉亚·霍维兹 【美】杰拉米·斯科 / 中国人民大学出版社有限公司 / 2017-7-1 / CNY 55.00
在当今互联网时代,我们的隐私权已经受到了威胁,政府或企业可以追踪我们的电话,搜索引擎可以记录我们的在线浏览记录以及恒温器的设置以及更多信息。在当代,保卫隐私权不只是简单地描述出存在的问题或者警告人们隐私权已经丧失,隐私权的护卫者们提出了解决策略。他们密切关注商业实践、公共政策和技术设计以及人物,应该继续下去吗?条件就是:有问题,让我们找到解决之道。一起来看看 《无处安放的互联网隐私》 这本书的介绍吧!