UILocalNotification重复声音 [英] UILocalNotification repeat sound

查看:82
本文介绍了UILocalNotification重复声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了此页面中来自apple示例的代码:链接,但我似乎无法重复声音。我已经检查了其他应用程序,例如Skype(用于VOIP)和闹钟专业版(音频?)但我无法重复声音文件。

I have used the code from apples example from this page: Link, but I can't seem to get the sound to repeat. I have checked other applications, such as skype (for VOIP) and Alarm Clock Pro (audio?) but I cannot get the sound file to be repeated.

这是我的代码:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    AlarmHandler *AHinstance = getAlarmHandlerInstance();
    UIApplication* app = [UIApplication sharedApplication];

    NSArray *alarmList          = [AHinstance getAlarms];
    NSArray *oldNotifications   = [app scheduledLocalNotifications];

    if ([oldNotifications count] > 0)
    {
        [app cancelAllLocalNotifications];
    }

    for (Alarm *theAlarm in alarmList) {
        NSDate *alarmDate = [theAlarm getNearestActivationDate];
        Package *alarmPackage = [theAlarm getAlarmPackage];
        NSArray *fileList = [alarmPackage getVoiceFileListForBackgroundNotificationWithHour:theAlarm.larmHour];

        if( alarmDate == nil ) continue;

        UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];

        if (alarm)  
        {
            NSLog(@"File: %@", [fileList objectAtIndex:0]);

            alarm.fireDate = alarmDate;
            alarm.timeZone = [NSTimeZone defaultTimeZone];
            alarm.soundName = [fileList objectAtIndex:0];           
            alarm.alertBody = @"Time to wake up!";
            alarm.repeatInterval = 0;

            [app scheduleLocalNotification:alarm];
        }
    }
}

关于我如何能提供任何建议解决这个问题?

Any suggestions on how I can fix this?

我有建议将应用程序注册为音频播放器并在后台播放声音,但似乎苹果确实对这些应用程序表示友好,因为它们不是真正的音频播放器。因此,他们否认这些应用程序。

I have had suggestions to register app as audio player and play sounds in the background, but it seems that apple does take kindly to those applications because they aren't real audio players. Therefore they deny those apps.

关心,

Paul Peelen

Regards,
Paul Peelen

推荐答案

本地通知无法执行此操作。您可以注册为VOIP应用程序,也可以注册为具有单独API的背景音频应用程序。但是,如果您没有提供适合这些用途的适当功能,那么您很可能会被拒绝。

There is no way to do this for local notifications. You can either register as a VOIP app or as a "background audio" app, which have separate APIs. However, if you do not provide appropriate functionality to qualify for those kinds of uses, you'll most likely be rejected.

这篇关于UILocalNotification重复声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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