From d83c869e6576f79db04007221d5ef83742f9a4e4 Mon Sep 17 00:00:00 2001 From: Benjamin Verdier Date: Wed, 13 Jun 2018 13:11:41 +0200 Subject: [PATCH] popup in progress --- Classes/DialerView.m | 1 + Classes/LinphoneAppDelegate.m | 20 +++++- Classes/LinphoneManager.h | 2 + Classes/LinphoneManager.m | 75 ++++++++++++++++++++++ Classes/LinphoneUI/UIChatBubblePhotoCell.m | 2 - 5 files changed, 96 insertions(+), 4 deletions(-) diff --git a/Classes/DialerView.m b/Classes/DialerView.m index 8a0606a8b..ee762c976 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -193,6 +193,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)coreUpdateEvent:(NSNotification *)notif { @try { + [[LinphoneManager instance] checkNewVersion]; if (IPAD) { if (linphone_core_video_display_enabled(LC) && linphone_core_video_preview_enabled(LC)) { linphone_core_set_native_preview_window_id(LC, (__bridge void *)(_videoPreview)); diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index f88d1fbec..ff39eb49d 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -218,6 +218,17 @@ actions:[NSArray arrayWithObjects:act_confirm, act_deny, nil] intentIdentifiers:[[NSMutableArray alloc] init] options:UNNotificationCategoryOptionCustomDismissAction]; + + // App version verification + + UNNotificationAction *act_go_to_URL = [UNNotificationAction actionWithIdentifier:@"Download" + title:NSLocalizedString(@"Download", nil) + options:UNNotificationActionOptionNone]; + UNNotificationCategory *version_verif = + [UNNotificationCategory categoryWithIdentifier:@"version_verif" + actions:[NSArray arrayWithObjects:act_go_to_URL, nil] + intentIdentifiers:[[NSMutableArray alloc] init] + options:UNNotificationCategoryOptionCustomDismissAction]; [UNUserNotificationCenter currentNotificationCenter].delegate = self; [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge) @@ -226,7 +237,8 @@ if (error) LOGD(error.description); }]; - NSSet *categories = [NSSet setWithObjects:cat_call, cat_msg, video_call, cat_zrtp, nil]; + + NSSet *categories = [NSSet setWithObjects:cat_call, cat_msg, video_call, cat_zrtp, version_verif, nil]; [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories]; } @@ -662,7 +674,11 @@ didInvalidatePushTokenForType:(NSString *)type { }]; } else if ([response.notification.request.content.categoryIdentifier isEqual:@"lime"]) { return; - } else { // Missed call + } else if ([response.notification.request.content.categoryIdentifier isEqual:@"version_verif"]) { + NSString *url = [response.notification.request.content.userInfo objectForKey:@"url"]; + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; + return; + } else { // Missed call [PhoneMainView.instance changeCurrentView:HistoryListView.compositeViewDescription]; } } diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 76dc4fd23..498cd37ab 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -205,6 +205,8 @@ typedef struct _LinphoneManagerSounds { - (void) setContactsUpdated:(BOOL) updated; - (BOOL) getContactsUpdated; +- (void)checkNewVersion; + @property ProviderDelegate *providerDelegate; @property (readonly) BOOL isTesting; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 7e436dc68..93b8971e1 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1394,6 +1394,55 @@ void linphone_iphone_chatroom_state_changed(LinphoneCore *lc, LinphoneChatRoom * [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:nil]; } +void linphone_iphone_version_update_check_result_received (LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url) { + LOGD(@"MONCUL"); + if (result == LinphoneVersionUpdateCheckUpToDate || result == LinphoneVersionUpdateCheckError) { + return; + } + NSString *title = NSLocalizedString(@"Outdated Version", nil); + NSString *body = NSLocalizedString(@"A new version of your app is available, use the button below to download it.", nil); + + UIAlertController *versVerifView = [UIAlertController alertControllerWithTitle:title + message:body + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + NSString *ObjCurl = [NSString stringWithUTF8String:url]; + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:ObjCurl]]; + }]; + + [versVerifView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:versVerifView animated:YES completion:nil]; + /* + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && + floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { + UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + content.title = title; + content.body = body; + content.categoryIdentifier = @"version_verif"; + UNNotificationRequest *req = + [UNNotificationRequest requestWithIdentifier:@"version_verif" 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); + } + }]; + } else { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title + message:body + delegate:nil + cancelButtonTitle:nil + otherButtonTitles:nil]; + [alert show]; + } + */ +} + #pragma mark - Message composition start - (void)alertLIME:(LinphoneChatRoom *)room { NSString *title = NSLocalizedString(@"LIME warning", nil); @@ -1964,6 +2013,7 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat linphone_core_cbs_set_notify_received(cbs, linphone_iphone_notify_received); linphone_core_cbs_set_call_encryption_changed(cbs, linphone_iphone_call_encryption_changed); linphone_core_cbs_set_chat_room_state_changed(cbs, linphone_iphone_chatroom_state_changed); + linphone_core_cbs_set_version_update_check_result_received(cbs, linphone_iphone_version_update_check_result_received); linphone_core_cbs_set_user_data(cbs, (__bridge void *)(self)); theLinphoneCore = linphone_factory_create_core_with_config(factory, cbs, _configDb); @@ -3028,4 +3078,29 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (void)exportSymbolsForUITests { linphone_address_set_header(NULL, NULL, NULL); } + +- (void)checkNewVersion { + if (theLinphoneCore == nil) + return; + //NSString *curVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; + //const char *curVersionCString = [curVersion cStringUsingEncoding:NSUTF8StringEncoding]; + //linphone_core_check_for_update(theLinphoneCore, curVersionCString); + + NSString *title = NSLocalizedString(@"Outdated Version", nil); + NSString *body = NSLocalizedString(@"A new version of your app is available, use the button below to download it.", nil); + + UIAlertController *versVerifView = [UIAlertController alertControllerWithTitle:title + message:body + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + NSString *ObjCurl = @"https://www.google.com/"; + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:ObjCurl]]; + }]; + + [versVerifView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:versVerifView animated:YES completion:nil]; +} @end diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index 611b44f44..0e138836d 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -50,7 +50,6 @@ } [self setFrame:CGRectMake(0, 0, 5, 100)]; [self addSubview:sub]; - //LOGD(@"ZBOUB"); chatTableView = VIEW(ChatConversationView).tableController; actualAvailableWidth = chatTableView.tableView.frame.size.width; } @@ -110,7 +109,6 @@ _imageGestureRecognizer.enabled = YES; //_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES; _finalImage.hidden = NO; - LOGD(@"ZBOUB"); }); }