iOS 10:如何在应用程序处于后台时显示传入的VOIP呼叫通知?

Abh*_*yal 5 notifications voip objective-c ios usernotifications

我正在努力audio/video call并尝试将来电呼叫notification循环播放1分钟,就像WhatsApp在iOS应用程序是背景时显示,Notification banner隐藏并显示铃声1分钟.

我试过这段代码,它只触发一次:

 UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
    content.title = [NSString stringWithFormat:@"Video Call from %@",userId];
    content.body = @"";
    content.userInfo = [userInfo mutableCopy];
    content.sound = [UNNotificationSound soundNamed:@""];

    NSDate *now = [NSDate date];
    now = [now dateByAddingTimeInterval:3];
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    [calendar setTimeZone:[NSTimeZone localTimeZone]];

    NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute|NSCalendarUnitSecond|NSCalendarUnitTimeZone fromDate:now];

    UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:NO];
    UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"INCOMING_VOIP_APN" content:content trigger:trigger];

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
    [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
        if (!error) {
            NSLog(@"PUSHKIT : INCOMING_VOIP_APN");
        }
    }];
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?我正在使用UserNotifications.framework (iOS 10)PushKit.