开发者

UILocalNotification repeat sound

开发者 https://www.devze.com 2023-01-14 16:23 出处:网络
I have used the code from apples example from this page: Link, bu开发者_开发技巧t I can\'t seem to get the sound to repeat. I have checked other applications, such as skype (for VOIP) and Alarm Clock

I have used the code from apples example from this page: Link, bu开发者_开发技巧t 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.

This is my code:

- (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.

Regards,

Paul Peelen


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.


Yes this is possible, as the documentation states:

Your own applications can schedule up to 128 simultaneous notifications, any of which can be configured to repeat at a specified interval

You just need to configure the repeatInterval property:

The calendar interval at which to reschedule the notification.

0

精彩评论

暂无评论...
验证码 换一张
取 消