大佬教程收集整理的这篇文章主要介绍了ios – 徽章计数没有增加推送通知.总计徽章计数仍为1?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSString *message = nil; id alert = [userInfo objectForKey:@"aps"]; if ([alert isKindOfClass:[NSString class]]) { message = alert; } else if ([alert isKindOfClass:[NSDictionary class]]) { message = [alert objectForKey:@"alert"]; } if (alert) { UIAlertView *alertView = [[UIAlertView alloc] initWithtitle:@"xyz" message:message delegate:self cancelButtontitle:@"OK" otherButtontitles:@"Cancel",nil]; alertView.tag=2525; [alertView show]; } } -(void)alertView:(UIAlertView *)alertView clickedButtonATindex:(NSInteger)buttonIndex { if(alertView.tag==2525) { [UIApplication sharedApplication].applicationIconBadgenumber = [UIApplication sharedApplication].applicationIconBadgenumber-1; } }
我已经添加了字段badgecount,并且每次使用此代码将推送发送到设备时我都会增加徽章计数
$query = "SELECT badgecount FROM pushnotifications WHERE device_token = '{$device_token}'"; $query = $this->db->query($query); $row = $query->row_array(); $updatequery = "update pushnotifications set badgecount=badgecount+1 WHERE device_token ='{$device_token}'"; $updatequery = $this->db->query($updatequery); $device = $device_token; $payload['aps'] = array('alert' => $pushmessage,'badge' =>$row["badgecount"]+1,'sound' => 'default'); $payload = json_encode($payload); ...
而且我还制作了另一个用于制作badgcount 0的api
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
以上是大佬教程为你收集整理的ios – 徽章计数没有增加推送通知.总计徽章计数仍为1?全部内容,希望文章能够帮你解决ios – 徽章计数没有增加推送通知.总计徽章计数仍为1?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。