在ios8中,直接设置application badge value会出错

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];

曝出”Attempting to badge the application icon but haven't received permission from the user to badge the application“的错误。

  原因是因为在ios8中,设置应用的application badge value需要得到用户的许可。使用如下方法咨询用户是否许可应用设置application badge value

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

程序运行时,会弹出提示框给用户

之后再通过

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];

设置application badge value

ios8设置application badge value的更多相关文章

  1. iOS8设置应用图标红点的权限问题

    在ios8中,直接设置application badge value会出错 1 [[UIApplication sharedApplication] setApplicationIconBadgeNu ...

  2. IOS8 设置TableView Separatorinset 分割线从边框顶端开始

    IOS8 设置TableView Separatorinset 分割线从边框顶端开始   在ios8上 [TableViewsetSeparatorInset:UIEdgeInsetsMake(0,0 ...

  3. IOS - Ask for Application Badge permission ios8

    UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUs ...

  4. axios设置application/x-www-form-urlencoded

    this.$axios({ method: 'post', url: 'http://www.17huo.com/tusou/deeplorSearch.html', headers: { 'Cont ...

  5. How to correctly set application badge value in iOS 8?

    o modify the badge under ios8 you have to ask for permissions let settings = UIUserNotificationSetti ...

  6. Dubbo配置注册中心设置application的name使用驼峰命名法存在的隐藏项目启动异常问题

    原创/朱季谦 首先,先提一个建议,在SpringBoot+Dubbo项目中,Dubbo配置注册中心设置的application命名name的值,最好使用xxx-xxx-xxx这样格式的,避免随便使用驼 ...

  7. ios8 设置单元格分割线无效

    原来: [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];//分隔线紧贴左右边框 || [self.tableView s ...

  8. Android程序的入口点和全局变量设置--application

    首先看看 application的官方文档 我之前一直以为Android程序的入口点就是带MAIN和LAUNCHER的Activity的onCreate方法,看来我是错了~  原来真正的入口点是 Ap ...

  9. Attempting to badge the application icon but haven't received permission from the user to badge the application错误解决办法

    今天刚刚学习UIApplication对象,当我希望利用这个对象在我们的应用图标上显示个数字的时候,xcode报了这个错误:  解决办法 : - (IBAction)applicationClicke ...

随机推荐

  1. hdu 5755(Gauss 消元) &poj 2947

    Gambler Bo Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tota ...

  2. 【贪心】AtCoder Regular Contest 079 E - Decrease (Judge ver.)

    每次将最大的数减到n以下,如此循环直到符合题意. 复杂度大概是n*n*log?(?). #include<cstdio> #include<iostream> #include ...

  3. ACM-ICPC 2016亚洲区域赛(沈阳站)游记(滚粗记)

    首发于QQ空间和知乎,我在这里也更一下.   前言 以前高中搞竞赛的时候,经常看到神犇出去比赛或者训练之后写游记什么的,感觉萌萌哒.但是由于太弱,就没什么心情好写.现在虽然还是很弱,但是抱着享受的心情 ...

  4. Problem D: 零起点学算法94——输出矩阵

    #include<stdio.h> int main() { ][]; while(scanf("%d %d",&n,&m)!=EOF) { ; ;i& ...

  5. Don't know how to define struct flock on this system, set --enable-opcach=no

    解决方法一: 最后查看php官方文档解决. 在configure 里面加上   --with-libdir=lib64 解决方法二: 编辑/etc/ld.so.conf 根据系统,加入include ...

  6. KNN算法实现手写数字

    from numpy import * import operator from os import listdir def classify0(inX, dataSet, labels, k): d ...

  7. iptables复习记忆

    inner_net="10.0.0.0/8,192.168.0.0/16" int_if="eth0" ext_if="eth1" 一.基本 ...

  8. Visual Studio中 sln 和 suo 文件

    我们通过双击.sln加载出我们的工程,Visual Studio采用两种文件类型(.sln和.suo)来存储解决方案的设置,它们总称为解决方案文件. .sln文件 solution,即解决方案.它引用 ...

  9. activiti源码笔记对标的博客

    http://blog.csdn.net/bluejoe2000/article/category/2812511/2 白乔专栏 http://blog.csdn.net/bluejoe2000/ar ...

  10. shell 脚本中执行mysql语句

    通过hash建表之后,表的数据量巨大2048,那怎么去验证表是否建成功呢? 逻辑生成表名这部分就不写了.只要能建表成功,这部分的脚本肯定是有的.那么怎么在shell中执行selec查询并返回呢 只要在 ...