LocalNotification自定义的声音是不是在玩iOS7

LocalNotification自定义的声音是不是在玩iOS7

本文介绍了UILocalNotification自定义的声音是不是在玩iOS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 UILocalNotification 在应用程序中。

在应用程序有哪些玩法conditionally-我已经申请适当的条件下它们两个声音。

In the application there are two sounds which are played conditionally- I have applied proper conditions for them.

但是,当我安装的应用程序和的iOS 7 设备上运行它,然后它触发本地通知,但声音没有在应用程序中播放。

But when I install the application and run it on an iOS 7 device, then it fires the local notification but a sound is not playing in the application.

code为如下设置通知:

Code is given below to set the notification:

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    if (localNotification == nil)
        return;
    localNotification.fireDate = [pickerView date];

    localNotification.timeZone = [NSTimeZone defaultTimeZone];

    if (alarm_number == 1) {
        localNotification.alertBody = [NSString stringWithFormat:@"First Alarm"];
    }
    else
    {
        localNotification.alertBody = [NSString stringWithFormat:@"Second Alarm"];
    }

    localNotification.alertAction =@"Ok";

    NSString *message = [[NSString alloc]initWithString:@""];

    if(alarm_number == 1)
    {
        localNotification.soundName=@"Alarm_1.mp3";
        message = @"First Alarm Scheduled";
    }
    else
    {
        localNotification.soundName=@"Alarm_2.mp3";
        message = @"Second Alarm Scheduled";
    }

    localNotification.applicationIconBadgeNumber = 1;

    // Specify custom data for the notification
    NSString *alarmString;
    if (alarm_number==1) {
        alarmString = [NSString stringWithFormat:@"First Alarm"];
    }
    else
    {
        alarmString = [NSString stringWithFormat:@"Second Alarm"];
    }

    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:alarmString forKey:@"AlarmFor"];

    localNotification.userInfo = infoDict;

    // Schedule the notification
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
    [localNotification release];

我已经检查是在设置/通知中心的应用程序为我的应用程序的声音设置。

What I have checked for is the Sound setting in the Settings/Notification Centre app for my app.

请经过1日至3图像,看看有什么我都检查过。

Please go through 1st to 3rd image to see what I have checked.

(1)通知中心

(2)应用

(3)声音是在这里下车。

(3) Sound is off here

因此​​,要启用这个我已经检查应用程序间的音频在应用程序的目标的功能的,它是关闭,如下图所示。

So, to enable this I have checked Inter App Audio at Capabilities in Targets of the application and it was Off as shown in the image below.

在跨应用的音频功能

然后我就改成了上,它看起来在下面的图片中显示等。

Then I have changed it to On and it looks like shown in the image below.

然而,它仍然无法在iOS的7设备上播放任何声音。

Yet, it still does not play any sound in iOS 7 devices.

有谁有关于它为什么不工作任何想法?这将是一个很大的帮助。

Does anybody have any idea about why is it not working? It would be a great help.

感谢。

推荐答案

你有没有尝试关闭请勿打扰模式了吗?
我有同样的问题,后来我发现请勿打扰的开启。
请关闭后,这一切工作的正确途径。

Did you try to turn off "Do not disturb" mode off?I have the same problem, then I found out "Do not Disturb" is on.After turn off that, it all works the right way.

这篇关于UILocalNotification自定义的声音是不是在玩iOS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 08:16