Skip to content

Commit 74101d8

Browse files
committed
Merge branch 'release/3.5.1'
2 parents 457c767 + 1bba7b1 commit 74101d8

File tree

10 files changed

+74
-98
lines changed

10 files changed

+74
-98
lines changed

iMEGA/AppDelegate.m

+59-89
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#import <AVFoundation/AVFoundation.h>
44
#import <Photos/Photos.h>
5-
#import <PushKit/PushKit.h>
65
#import <UserNotifications/UserNotifications.h>
76

87
#import "LTHPasscodeViewController.h"
@@ -56,7 +55,7 @@ typedef NS_ENUM(NSUInteger, URLType) {
5655
URLTypeRecoverLink
5756
};
5857

59-
@interface AppDelegate () <UIAlertViewDelegate, PKPushRegistryDelegate, UNUserNotificationCenterDelegate, LTHPasscodeViewControllerDelegate> {
58+
@interface AppDelegate () <UIAlertViewDelegate, UNUserNotificationCenterDelegate, LTHPasscodeViewControllerDelegate> {
6059
BOOL isAccountFirstLogin;
6160
BOOL isFetchNodesDone;
6261

@@ -202,8 +201,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
202201
isFetchNodesDone = NO;
203202

204203
if (sessionV3) {
205-
[self registerForVoIPNotifications];
206-
[self registerForLocalNotifications];
204+
[self registerForNotifications];
207205
isAccountFirstLogin = NO;
208206
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"IsChatEnabled"] == nil) {
209207
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"IsChatEnabled"];
@@ -279,7 +277,12 @@ - (void)applicationWillResignActive:(UIApplication *)application {
279277
- (void)applicationDidEnterBackground:(UIApplication *)application {
280278
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
281279
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
282-
[self startBackgroundTask];
280+
[[MEGASdkManager sharedMEGAChatSdk] setBackgroundStatus:YES];
281+
282+
BOOL pendingTransfers = [[[[MEGASdkManager sharedMEGASdk] transfers] size] integerValue] > 0 || [[[[MEGASdkManager sharedMEGASdkFolder] transfers] size] integerValue] > 0;
283+
if (pendingTransfers) {
284+
[self startBackgroundTask];
285+
}
283286

284287
if (self.privacyView == nil) {
285288
UIViewController *privacyVC = [[UIStoryboard storyboardWithName:@"Launch" bundle:nil] instantiateViewControllerWithIdentifier:@"PrivacyViewControllerID"];
@@ -296,6 +299,8 @@ - (void)applicationDidEnterBackground:(UIApplication *)application {
296299
}
297300

298301
- (void)applicationWillEnterForeground:(UIApplication *)application {
302+
[[MEGASdkManager sharedMEGAChatSdk] setBackgroundStatus:NO];
303+
299304
if ([[MEGASdkManager sharedMEGASdk] isLoggedIn] && [[CameraUploads syncManager] isCameraUploadsEnabled]) {
300305
MEGALogInfo(@"Enable Camera Uploads");
301306
[[CameraUploads syncManager] setIsCameraUploadsEnabled:YES];
@@ -308,6 +313,8 @@ - (void)applicationWillEnterForeground:(UIApplication *)application {
308313
window.frame = [[UIScreen mainScreen] bounds];
309314
}
310315
}
316+
317+
[[MEGASdkManager sharedMEGAChatSdk] retryPendingConnections];
311318
}
312319

313320
- (void)applicationDidBecomeActive:(UIApplication *)application {
@@ -374,6 +381,34 @@ - (void)applicationProtectedDataWillBecomeUnavailable:(UIApplication *)applicati
374381
}
375382
}
376383

384+
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
385+
[application registerForRemoteNotifications];
386+
}
387+
388+
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
389+
if([deviceToken length] == 0) {
390+
MEGALogError(@"Token length is 0");
391+
return;
392+
}
393+
394+
const unsigned char *dataBuffer = (const unsigned char *)deviceToken.bytes;
395+
396+
NSUInteger dataLength = deviceToken.length;
397+
NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
398+
399+
for (int i = 0; i < dataLength; ++i) {
400+
[hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
401+
}
402+
403+
NSString *deviceTokenString = [NSString stringWithString:hexString];
404+
MEGALogDebug(@"Device token %@", deviceTokenString);
405+
[[MEGASdkManager sharedMEGASdk] registeriOSdeviceToken:deviceTokenString];
406+
}
407+
408+
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
409+
MEGALogError(@"Failed to register for remote notifications %@", error);
410+
}
411+
377412
#pragma mark - Private
378413

379414
- (void)setupAppearance {
@@ -938,28 +973,21 @@ - (void)showMainTabBar {
938973

939974
[[CameraUploads syncManager] setTabBarController:_mainTBC];
940975
if (isAccountFirstLogin) {
941-
[self registerForVoIPNotifications];
942-
[self registerForLocalNotifications];
976+
[self registerForNotifications];
943977
}
944978
}
945979

946-
- (void)registerForVoIPNotifications {
947-
dispatch_queue_t mainQueue = dispatch_get_main_queue();
948-
PKPushRegistry *voipRegistry = [[PKPushRegistry alloc] initWithQueue:mainQueue];
949-
voipRegistry.delegate = self;
950-
voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
951-
}
952-
953-
954-
955-
- (void)registerForLocalNotifications {
956-
if (NSClassFromString(@"UNUserNotificationCenter")) {
980+
- (void)registerForNotifications {
981+
if ([[UIDevice currentDevice] systemVersionGreaterThanOrEqualVersion:@"10.0"]) {
957982
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
958983
center.delegate = self;
959984
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert)
960985
completionHandler:^(BOOL granted, NSError * _Nullable error) {
961986
if (!error) {
962-
NSLog(@"request authorization succeeded!");
987+
MEGALogInfo(@"Request notifications authorization succeeded");
988+
}
989+
if (granted) {
990+
[self notificationsSettings];
963991
}
964992
}];
965993
} else {
@@ -969,6 +997,16 @@ - (void)registerForLocalNotifications {
969997
}
970998
}
971999

1000+
- (void)notificationsSettings {
1001+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
1002+
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *settings) {
1003+
MEGALogInfo(@"Notifications settings %@", settings);
1004+
if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
1005+
[[UIApplication sharedApplication] registerForRemoteNotifications];
1006+
}
1007+
}];
1008+
}
1009+
9721010
#pragma mark - Battery changed
9731011

9741012
- (void)batteryChanged:(NSNotification *)notification {
@@ -1165,79 +1203,11 @@ - (void)setSystemLanguage {
11651203
}
11661204
}
11671205

1168-
- (void)setDefaultLanguage {
1206+
- (void)setDefaultLanguage {
1207+
[[MEGASdkManager sharedMEGASdk] setLanguageCode:@"en"];
11691208
[[LocalizationSystem sharedLocalSystem] setLanguage:@"en"];
11701209
}
11711210

1172-
#pragma mark - PKPushRegistryDelegate
1173-
1174-
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
1175-
if([credentials.token length] == 0) {
1176-
MEGALogError(@"VoIP token length is 0");
1177-
return;
1178-
}
1179-
1180-
const unsigned char *dataBuffer = (const unsigned char *)credentials.token.bytes;
1181-
1182-
NSUInteger dataLength = credentials.token.length;
1183-
NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)];
1184-
1185-
for (int i = 0; i < dataLength; ++i) {
1186-
[hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
1187-
}
1188-
1189-
NSString *deviceTokenString = [NSString stringWithString:hexString];
1190-
MEGALogDebug(@"Device token %@", deviceTokenString);
1191-
[[MEGASdkManager sharedMEGASdk] registeriOSdeviceToken:deviceTokenString];
1192-
}
1193-
1194-
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
1195-
MEGALogDebug(@"didReceiveIncomingPushWithPayload: %@", [payload dictionaryPayload]);
1196-
1197-
NSInteger megatype = [[[payload dictionaryPayload] objectForKey:@"megatype"] integerValue];
1198-
NSString *body = nil;
1199-
1200-
switch (megatype) {
1201-
case 1:
1202-
body = AMLocalizedString(@"newSharedFolder", @"Notification text body shown when you have received a new shared folder");
1203-
break;
1204-
case 2:
1205-
body = AMLocalizedString(@"newMessage", @"Notification text body shown when you have received a new chat message");
1206-
break;
1207-
case 3:
1208-
body = AMLocalizedString(@"contactRequest", @"Notification text body shown when you have received a contact request");
1209-
break;
1210-
1211-
default:
1212-
break;
1213-
}
1214-
1215-
if (NSClassFromString(@"UNMutableNotificationContent")) {
1216-
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
1217-
1218-
content.body = body;
1219-
content.sound = [UNNotificationSound defaultSound];
1220-
1221-
NSString *identifier = [NSString stringWithFormat:@"%@", [payload dictionaryPayload]];
1222-
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
1223-
content:content
1224-
trigger:nil];
1225-
1226-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
1227-
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
1228-
if (error) {
1229-
MEGALogError(@"Add NotificationRequest failed with error: %@", error);
1230-
}
1231-
}];
1232-
} else if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
1233-
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
1234-
localNotification.alertBody = body;
1235-
localNotification.soundName = UILocalNotificationDefaultSoundName;
1236-
1237-
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
1238-
}
1239-
}
1240-
12411211
#pragma mark - MEGAGlobalDelegate
12421212

12431213
- (void)onUsersUpdate:(MEGASdk *)api userList:(MEGAUserList *)userList {

iMEGA/Chat/ChatRoomsViewController.m

+2
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ - (void)onChatListItemUpdate:(MEGAChatSdk *)api item:(MEGAChatListItem *)item {
658658
break;
659659

660660
case MEGAChatListItemChangeTypeTitle:
661+
[self.chatListItemArray replaceObjectAtIndex:indexPath.row withObject:item];
661662
cell.chatTitle.text = item.title;
662663
break;
663664

@@ -667,6 +668,7 @@ - (void)onChatListItemUpdate:(MEGAChatSdk *)api item:(MEGAChatListItem *)item {
667668

668669
case MEGAChatListItemChangeTypeLastMsg:
669670
case MEGAChatListItemChangeTypeLastTs:
671+
[self.chatListItemArray replaceObjectAtIndex:indexPath.row withObject:item];
670672
[self updateCell:cell forChatListItem:item];
671673
break;
672674

iMEGA/Info.plist

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<key>CFBundlePackageType</key>
3737
<string>APPL</string>
3838
<key>CFBundleShortVersionString</key>
39-
<string>3.5</string>
39+
<string>3.5.1</string>
4040
<key>CFBundleSignature</key>
4141
<string>????</string>
4242
<key>CFBundleURLTypes</key>
@@ -51,7 +51,7 @@
5151
</dict>
5252
</array>
5353
<key>CFBundleVersion</key>
54-
<string>57</string>
54+
<string>59</string>
5555
<key>ITSAppUsesNonExemptEncryption</key>
5656
<false/>
5757
<key>LSRequiresIPhoneOS</key>
@@ -82,7 +82,6 @@
8282
<string>audio</string>
8383
<string>fetch</string>
8484
<string>remote-notification</string>
85-
<string>voip</string>
8685
</array>
8786
<key>UIFileSharingEnabled</key>
8887
<true/>

iMEGA/Languages/ja.lproj/Localizable.strings

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@
601601
/* Footer text that explain what happen if the options 'Save videos in gallery’ and 'Save images in gallery’ are enabled */
602602
"imageAndVideoDownloadsFooter"="Save iOS compatible images and videos in your device's gallery (Note: images and videos won't be saved in Offline).";
603603
/* Footer text that explain what amount of space you will free up if 'Clear Offline data', 'Clear cache' or 'Clear Rubbish Bin' is tapped */
604-
"currentlyUsing"="利用している領域 %s";
604+
"currentlyUsing"="利用している領域 %@";
605605
/* In 'My account', when user want to delete/remove/cancel account will click button named 'Cancel your account' */
606606
"cancelYourAccount"="アカウントをキャンセルする";
607607
/* Message that is shown when the user click on 'Cancel your account' to confirm that he's aware that his data will be deleted. */

iMEGA/Languages/zh-Hans.lproj/Localizable.strings

+1-1
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@
993993
/* A button title which removes a participant from a chat. */
994994
"removeParticipant"="删除成员";
995995
/* Chat conversation header with user %@. Please leave %@ as it is. */
996-
"conversationWith"="与%s的对话";
996+
"conversationWith"="与%@的对话";
997997
/* Full text: MEGA protects your chat with end-to-end (user controlled) encryption providing essential safety assurances: Confidentiality - Only the author and intended recipients are able to decipher and read the content. Authenticity - There is an assurance that the message received was authored by the stated sender, and its content has not been tampered with during transport or on the server. */
998998
"chatIntroductionMessage"="为提供安全保障MEGA使用端对端(用户控制的)加密保护你的聊天";
999999
/* Chat advantages information. Full text: Mega protects your chat with end-to-end (user controlled) encryption providing essential safety assurances: [S]Confidentiality.[/S] Only the author and intended recipients are able to decipher and read the content. [S]Authenticity.[/S] The system ensures that the data received is from the sender displayed, and its content has not been manipulated during transit. */

iMEGA/Settings/About/AboutTableViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ - (void)viewDidLoad {
3636
self.versionCell.gestureRecognizers = @[tapGestureRecognizer];
3737

3838
[self.sdkVersionLabel setText:[NSString stringWithFormat:@"MEGA SDK %@", AMLocalizedString(@"version", nil)]];
39-
self.sdkVersionSHALabel.text = @"e8eeea7";
39+
self.sdkVersionSHALabel.text = @"3a2bc39";
4040

4141
[self.acknowledgementsLabel setText:AMLocalizedString(@"acknowledgements", nil)];
4242
}

iMEGA/Settings/SettingsTableViewController.m

+1
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp
303303

304304
self.selectedLanguage = [Helper languageID:row];
305305
[[LocalizationSystem sharedLocalSystem] setLanguage:self.selectedLanguage];
306+
[[MEGASdkManager sharedMEGASdk] setLanguageCode:self.selectedLanguage];
306307

307308
[self updateUI];
308309
[self.tableView reloadData];

iMEGA/Utils/Helper.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ + (NSArray *)languagesSupportedIDs {
7373
}
7474

7575
+ (BOOL)isLanguageSupported:(NSString *)languageID {
76-
return [self.languagesSupportedIDs containsObject:languageID];
76+
BOOL isLanguageSupported = [self.languagesSupportedIDs containsObject:languageID];
77+
if (isLanguageSupported) {
78+
[[MEGASdkManager sharedMEGASdk] setLanguageCode:languageID];
79+
}
80+
return isLanguageSupported;
7781
}
7882

7983
+ (NSString *)languageID:(NSUInteger)index {

iMEGA/Vendor/SDK

Submodule SDK updated 62 files

0 commit comments

Comments
 (0)