I am working on an audio/video call and trying to get an incoming call notification cycle for 1 minute. LIKE whatsapp shows in iOS , when the application is the background, Hide and show the Notification banner with the ringtone for 1 minute.
I tried this code, I only run one 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, please help?
I use UserNotifications.framework (iOS 10) and PushKit .
Thanks!
ios objective-c notifications usernotifications voip
Abhishek thapliyal
source share