iOS 中的本地通知没有任何声音 [英] Local notification in iOS coming without any sound

查看:34
本文介绍了iOS 中的本地通知没有任何声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-(void)notifyMe
{
    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0.1];
    localNotification.timeZone = [NSTimeZone defaultTimeZone];
    localNotification.alertBody = @"Alert";
    localNotification.alertAction = @"Local notification";
    localNotification.soundName = UILocalNotificationDefaultSoundName;
    localNotification.alertLaunchImage = nil;
    localNotification.userInfo = nil;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

这是我调用本地通知的方法.这与其他应用程序一起工作正常.但是在我的工作中,通知即将到来但没有声音.

This is the method I am calling for local notification. This is working fine with other applications. But with my working one, notification is coming but with no sound.

我猜应用设置有问题,但我找不到.

I guess there is some problem with app setting, but I am unable to find it out.

推荐答案

我发现了你的问题,因为我遇到了同样的问题.原来这是我的一个简单修复,我的代码很好,我所要做的就是为我的应用程序启用推送通知(我已经完成但没有声音或徽章),然后切换 Badge App图标SoundON.

I found your question as I had run into the same problem. Turns out it was a simple fix on my part, my code was fine all I had to do was enable push notifications for my app (which I had already done but was getting no sound or badge), and then switch Badge App Icon and Sound to ON.

我很惊讶这个问题在 6 个月内没有其他答案.

I'm surprised there have been no other answers to this question in 6 months.

这篇关于iOS 中的本地通知没有任何声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆