mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 12:36:25 +00:00
Repeat Call notifications if option is set + end of repeat when notif handeld or call ended
This commit is contained in:
parent
fe600f3f7b
commit
a81a229086
2 changed files with 86 additions and 8 deletions
|
|
@ -533,10 +533,17 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
||||||
LOGD(@"UN : response recieved");
|
LOGD(@"UN : response recieved");
|
||||||
LOGD(response.description);
|
LOGD(response.description);
|
||||||
|
|
||||||
|
LinphoneCall* call = linphone_core_get_current_call(LC);
|
||||||
|
if (call) {
|
||||||
|
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
|
||||||
|
if (data->timer) {
|
||||||
|
[data->timer invalidate];
|
||||||
|
data->timer = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ([response.actionIdentifier isEqual:@"Answer"]) {
|
if ([response.actionIdentifier isEqual:@"Answer"]) {
|
||||||
[LinphoneManager.instance acceptCallForCallId:[response.notification.request.content.userInfo objectForKey:@"callId"]];
|
[LinphoneManager.instance acceptCallForCallId:[response.notification.request.content.userInfo objectForKey:@"callId"]];
|
||||||
} else if ([response.actionIdentifier isEqual:@"Decline"]) {
|
} else if ([response.actionIdentifier isEqual:@"Decline"]) {
|
||||||
LinphoneCall* call = linphone_core_get_current_call(LC);
|
|
||||||
linphone_core_decline_call(LC, call, LinphoneReasonDeclined);
|
linphone_core_decline_call(LC, call, LinphoneReasonDeclined);
|
||||||
} else if ([response.actionIdentifier isEqual:@"Reply"]) {
|
} else if ([response.actionIdentifier isEqual:@"Reply"]) {
|
||||||
LinphoneCore *lc = [LinphoneManager getLc];
|
LinphoneCore *lc = [LinphoneManager getLc];
|
||||||
|
|
@ -564,7 +571,9 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
||||||
if ([response.notification.request.content.categoryIdentifier isEqual:@"call_cat"]) {
|
if ([response.notification.request.content.categoryIdentifier isEqual:@"call_cat"]) {
|
||||||
[LinphoneManager.instance acceptCallForCallId:[response.notification.request.content.userInfo objectForKey:@"callId"]];
|
[LinphoneManager.instance acceptCallForCallId:[response.notification.request.content.userInfo objectForKey:@"callId"]];
|
||||||
} else if ([response.notification.request.content.categoryIdentifier isEqual:@"msg_cat"]) {
|
} else if ([response.notification.request.content.categoryIdentifier isEqual:@"msg_cat"]) {
|
||||||
|
[PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription];
|
||||||
|
} else { //Missed call
|
||||||
|
[PhoneMainView.instance changeCurrentView:HistoryListView.compositeViewDescription];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -575,6 +584,15 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
||||||
handleActionWithIdentifier:(NSString *)identifier
|
handleActionWithIdentifier:(NSString *)identifier
|
||||||
forLocalNotification:(UILocalNotification *)notification
|
forLocalNotification:(UILocalNotification *)notification
|
||||||
completionHandler:(void (^)())completionHandler {
|
completionHandler:(void (^)())completionHandler {
|
||||||
|
|
||||||
|
LinphoneCall* call = linphone_core_get_current_call(LC);
|
||||||
|
if (call) {
|
||||||
|
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
|
||||||
|
if (data->timer) {
|
||||||
|
[data->timer invalidate];
|
||||||
|
data->timer = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
LOGI(@"%@", NSStringFromSelector(_cmd));
|
LOGI(@"%@", NSStringFromSelector(_cmd));
|
||||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) {
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) {
|
||||||
LOGI(@"%@", NSStringFromSelector(_cmd));
|
LOGI(@"%@", NSStringFromSelector(_cmd));
|
||||||
|
|
@ -613,6 +631,14 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
||||||
withResponseInfo:(NSDictionary *)responseInfo
|
withResponseInfo:(NSDictionary *)responseInfo
|
||||||
completionHandler:(void (^)())completionHandler {
|
completionHandler:(void (^)())completionHandler {
|
||||||
|
|
||||||
|
LinphoneCall* call = linphone_core_get_current_call(LC);
|
||||||
|
if (call) {
|
||||||
|
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
|
||||||
|
if (data->timer) {
|
||||||
|
[data->timer invalidate];
|
||||||
|
data->timer = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ([notification.category isEqualToString:@"incoming_call"]) {
|
if ([notification.category isEqualToString:@"incoming_call"]) {
|
||||||
if ([identifier isEqualToString:@"answer"]) {
|
if ([identifier isEqualToString:@"answer"]) {
|
||||||
// use the standard handler
|
// use the standard handler
|
||||||
|
|
|
||||||
|
|
@ -617,6 +617,22 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)userNotifContinue:(NSTimer *)timer {
|
||||||
|
UNNotificationContent *content = [timer userInfo];
|
||||||
|
if (content) {
|
||||||
|
LOGI(@"cancelling/presenting user notif");
|
||||||
|
UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL];
|
||||||
|
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:req withCompletionHandler:^(NSError * _Nullable error) {
|
||||||
|
// Enable or disable features based on authorization.
|
||||||
|
if (error) {
|
||||||
|
LOGD(@"Error while adding notification request :");
|
||||||
|
LOGD(error.description);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)onCall:(LinphoneCall *)call StateChanged:(LinphoneCallState)state withMessage:(const char *)message {
|
- (void)onCall:(LinphoneCall *)call StateChanged:(LinphoneCallState)state withMessage:(const char *)message {
|
||||||
// Handling wrapper
|
// Handling wrapper
|
||||||
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
|
LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call);
|
||||||
|
|
@ -690,6 +706,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
|
||||||
data->notification = [[UILocalNotification alloc] init];
|
data->notification = [[UILocalNotification alloc] init];
|
||||||
if (data->notification) {
|
if (data->notification) {
|
||||||
// iOS8 doesn't need the timer trick for the local notification.
|
// iOS8 doesn't need the timer trick for the local notification.
|
||||||
|
data->notification.category = @"incoming_call";
|
||||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8 &&
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8 &&
|
||||||
[self lpConfigBoolForKey:@"repeat_call_notification"] == NO) {
|
[self lpConfigBoolForKey:@"repeat_call_notification"] == NO) {
|
||||||
NSString *ring =
|
NSString *ring =
|
||||||
|
|
@ -697,7 +714,6 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
|
||||||
?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"])
|
?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"])
|
||||||
.lastPathComponent;
|
.lastPathComponent;
|
||||||
data->notification.soundName = ring;
|
data->notification.soundName = ring;
|
||||||
data->notification.category = @"incoming_call";
|
|
||||||
} else {
|
} else {
|
||||||
data->notification.soundName = @"shortring.caf";
|
data->notification.soundName = @"shortring.caf";
|
||||||
data->timer = [NSTimer scheduledTimerWithTimeInterval:5
|
data->timer = [NSTimer scheduledTimerWithTimeInterval:5
|
||||||
|
|
@ -734,10 +750,16 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
|
||||||
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
|
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
|
||||||
content.title = @"Incoming call";
|
content.title = @"Incoming call";
|
||||||
content.body = address;
|
content.body = address;
|
||||||
content.sound = [UNNotificationSound soundNamed:@"shortring.caf"];
|
content.sound = [UNNotificationSound soundNamed:@"notes_of_the_optimistic.caf"];
|
||||||
content.categoryIdentifier = @"call_cat";
|
content.categoryIdentifier = @"call_cat";
|
||||||
content.userInfo = @{@"callId" : callId};
|
content.userInfo = @{@"callId" : callId};
|
||||||
|
if ([self lpConfigBoolForKey:@"repeat_call_notification"] == YES) {
|
||||||
|
data->timer = [NSTimer scheduledTimerWithTimeInterval:5
|
||||||
|
target:self
|
||||||
|
selector:@selector(userNotifContinue:)
|
||||||
|
userInfo:content
|
||||||
|
repeats:TRUE];
|
||||||
|
}
|
||||||
UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL];
|
UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL];
|
||||||
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:req withCompletionHandler:^(NSError * _Nullable error) {
|
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:req withCompletionHandler:^(NSError * _Nullable error) {
|
||||||
// Enable or disable features based on authorization.
|
// Enable or disable features based on authorization.
|
||||||
|
|
@ -746,6 +768,18 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
|
||||||
LOGD(error.description);
|
LOGD(error.description);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
if (!incallBgTask) {
|
||||||
|
incallBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
|
||||||
|
LOGW(@"Call cannot ring any more, too late");
|
||||||
|
[[UIApplication sharedApplication] endBackgroundTask:incallBgTask];
|
||||||
|
incallBgTask = 0;
|
||||||
|
}];
|
||||||
|
|
||||||
|
if (data->timer) {
|
||||||
|
[[NSRunLoop currentRunLoop] addTimer:data->timer forMode:NSRunLoopCommonModes];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -768,6 +802,24 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char
|
||||||
/*IOS specific*/
|
/*IOS specific*/
|
||||||
linphone_core_start_dtmf_stream(theLinphoneCore);
|
linphone_core_start_dtmf_stream(theLinphoneCore);
|
||||||
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max && ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground)) {
|
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max && ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground)) {
|
||||||
|
if (data->timer) {
|
||||||
|
[data->timer invalidate];
|
||||||
|
data->timer = nil;
|
||||||
|
}
|
||||||
|
LinphoneCallLog *UNlog = linphone_call_get_call_log(call);
|
||||||
|
if (UNlog == NULL || linphone_call_log_get_status(UNlog) == LinphoneCallMissed) {
|
||||||
|
UNMutableNotificationContent* missed_content = [[UNMutableNotificationContent alloc] init];
|
||||||
|
missed_content.title = @"Missed call";
|
||||||
|
missed_content.body = address;
|
||||||
|
UNNotificationRequest *missed_req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:missed_content trigger:NULL];
|
||||||
|
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:missed_req withCompletionHandler:^(NSError * _Nullable error) {
|
||||||
|
// Enable or disable features based on authorization.
|
||||||
|
if (error) {
|
||||||
|
LOGD(@"Error while adding notification request :");
|
||||||
|
LOGD(error.description);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
linphone_core_set_network_reachable(LC, FALSE);
|
linphone_core_set_network_reachable(LC, FALSE);
|
||||||
LinphoneManager.instance.connectivity = none;
|
LinphoneManager.instance.connectivity = none;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue