iOS 10: como mostrar a notificação de chamada VOIP recebida quando o aplicativo está em segundo plano?
Eu estou trabalhando emaudio/video call
e tentando receber chamadasnotification
loop por 1 minuto, como o WhatsApp mostraiOS
quando o aplicativo é em segundo plano,Notification banner
ocultar e mostrar com toque por 1 minuto.
Eu tentei esse código, ele dispara apenas uma vez:
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");
}
}];
Como posso conseguir isso? estou a usarUserNotifications.framework (iOS 10)
ePushKit
.