Stopping ios 7 remote notification sound

佐手、 提交于 2019-11-30 15:51:49
Mohamed Hafez

I'm pretty sure this is a bug on Apple's end, see devforums.apple.com/message/888091 (thanks Gui13). File a duplicate bug report to get Apple to pay attention to it, as that is how Apple assigns priority to bugs. In the meantime, the following will work but will also clear all of your notifications in the notification center, which of course is a shoddy workaround, but in my case is worth it until this gets fixed:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];    
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];

it doesn't help by using

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];    
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];

after entering the app by clicking the notification.

I have solved this problem by sending another empty notification when dealing with the notification with sound:

if (notification.soundName != nil) {
    if (IS_IOS7) {
        UILocalNotification *emptyNotification = [[UILocalNotification alloc] init];
        emptyNotification.timeZone = [NSTimeZone defaultTimeZone];
        emptyNotification.fireDate = [NSDate date];
        emptyNotification.alertBody = @"";
        [[UIApplication sharedApplication] scheduleLocalNotification:emptyNotification];
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!