Я хочу увеличить время воспроизведения пользовательского рингтона для local notification
, но
Apple говорит:
Звуковые файлы должны быть короче 30 секунд. Если звуковой файл длиннее 30 секунд, система вместо этого воспроизводит звук по умолчанию.
Но мой звуковой файл 5 минут
Я пробовал таким образом:
content.sound = [soundName:@"mycustomtone.aiff"];
content.time = [timeDuration: 300];
Я знаю, что 300 секунд — это больше, чем 30 секунд, и это неправильный способ определения времени, поскольку нет определения времени для времени звука уведомления.
Помогите мне увеличить продолжительность пользовательского звука более чем на 30 секунд, если это возможно!
Я знаю, что нет ничего невозможного Если разработчик хочет!
Вот что я делаю:
#import "ViewController.h"
@interface ViewController () {
NSUserDefaults *defaults;
}
@end
bool isGrantedNotificationAccess;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
isGrantedNotificationAccess = false;
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNAuthorizationOptions options = UNAuthorizationOptionAlert+UNAuthorizationOptionSound;
[center requestAuthorizationWithOptions:options completionHandler:^(BOOL granted, NSError * _Nullable error) {
isGrantedNotificationAccess = granted;
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)notifyButton:(id)sender {
if (isGrantedNotificationAccess) {
NSLog(@"clicked");
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = @"Notification Title";
content.subtitle = @"Notification Subtitle";
content.body = @"Notification body";
content.sound = [UNNotificationSound soundNamed:@"alarm_clock_2015.aiff"];
content.timeDuration = 300;
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:YES];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"UYLocalNotification" content:content trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:nil];
}
}
@end