I'm working on audio/video call
and trying to get incoming call notification
loop for 1 minute like WhatsApp shows in iOS
when app is background, Notification banner
hide and show with ringtone for 1 minute.
I have tried this code, it triggers only single time:
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");
}
}];
How can I achieve this? I'm using UserNotifications.framework (iOS 10)
and PushKit
.