Эх сурвалжийг харах

Add subscribingNextcloudServerFailure Delegate

Marino Faggiana 8 жил өмнө
parent
commit
930a2a3819

+ 1 - 1
iOSClient/AppDelegate.h

@@ -43,7 +43,7 @@
 #import "CCOfflineContainer.h"
 #import "CCOfflineContainer.h"
 #import "CCSettings.h"
 #import "CCSettings.h"
 
 
-@interface AppDelegate : UIResponder <UIApplicationDelegate, BKPasscodeLockScreenManagerDelegate, BKPasscodeViewControllerDelegate, LMMediaPlayerViewDelegate, TWMessageBarStyleSheet>
+@interface AppDelegate : UIResponder <UIApplicationDelegate, BKPasscodeLockScreenManagerDelegate, BKPasscodeViewControllerDelegate, LMMediaPlayerViewDelegate, TWMessageBarStyleSheet, CCNetworkingDelegate>
 
 
 // Timer 5 sec.
 // Timer 5 sec.
 @property (nonatomic, strong) NSTimer *timerVerifyProcess;
 @property (nonatomic, strong) NSTimer *timerVerifyProcess;

+ 15 - 10
iOSClient/AppDelegate.m

@@ -429,6 +429,11 @@
 #pragma mark ===== Push Notification =====
 #pragma mark ===== Push Notification =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 
 
+- (void)subscribingNextcloudServerFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
+{
+    NSLog(@"[LOG] Error Subscribing Nextcloud Server %@", message);
+}
+
 - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
 - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
 {
 {
     [application registerForRemoteNotifications];
     [application registerForRemoteNotifications];
@@ -457,7 +462,7 @@
     
     
     if ([devicePublicKey length] > 0 && [pushTokenHash length] > 0) {
     if ([devicePublicKey length] > 0 && [pushTokenHash length] > 0) {
         
         
-        NSLog(@"Firebase InstanceID push token: %@", pushToken);
+        NSLog(@"[LOG] Firebase InstanceID push token: %@", pushToken);
         
         
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
     
     
@@ -471,7 +476,7 @@
 
 
 - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
 - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
 {
 {
-    NSLog(@"Error register remote notification %@", error);
+    NSLog(@"[LOG] Error register remote notification %@", error);
 }
 }
 
 
 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
@@ -480,11 +485,11 @@
     
     
     if (state == UIApplicationStateInactive || state == UIApplicationStateBackground) {
     if (state == UIApplicationStateInactive || state == UIApplicationStateBackground) {
         
         
-        NSLog(@"Receive Notification on Inactive or Background state");
+        NSLog(@"[LOG] Receive Notification on Inactive or Background state");
         
         
     } else {
     } else {
         
         
-        NSLog(@"Receive Notification on Active state");
+        NSLog(@"[LOG] Receive Notification on Active state");
     }
     }
     
     
     // If you are receiving a notification message while your app is in the background,
     // If you are receiving a notification message while your app is in the background,
@@ -497,7 +502,7 @@
     //}
     //}
     
     
     // Print full message.
     // Print full message.
-    NSLog(@"%@", userInfo);
+    NSLog(@"[LOG] %@", userInfo);
 
 
 }
 }
 
 
@@ -511,7 +516,7 @@
     //}
     //}
     
     
     // Print full message.
     // Print full message.
-    NSLog(@"%@", userInfo);
+    NSLog(@"[LOG] %@", userInfo);
 
 
     
     
     if (state == UIApplicationStateBackground || (state == UIApplicationStateInactive)) {
     if (state == UIApplicationStateBackground || (state == UIApplicationStateInactive)) {
@@ -537,7 +542,7 @@
     // should be done.
     // should be done.
     
     
     NSString *refreshedToken = [[FIRInstanceID instanceID] token];
     NSString *refreshedToken = [[FIRInstanceID instanceID] token];
-    NSLog(@"InstanceID token: %@", refreshedToken);
+    NSLog(@"[LOG] InstanceID token: %@", refreshedToken);
     
     
     // Connect to FCM since connection may have failed when attempted before having a token.
     // Connect to FCM since connection may have failed when attempted before having a token.
     [self connectToFcm];
     [self connectToFcm];
@@ -557,9 +562,9 @@
     
     
     [[FIRMessaging messaging] connectWithCompletion:^(NSError * _Nullable error) {
     [[FIRMessaging messaging] connectWithCompletion:^(NSError * _Nullable error) {
         if (error != nil) {
         if (error != nil) {
-            NSLog(@"Unable to connect to FCM. %@", error);
+            NSLog(@"[LOG] Unable to connect to FCM. %@", error);
         } else {
         } else {
-            NSLog(@"Connected to FCM.");
+            NSLog(@"[LOG] Connected to FCM.");
         }
         }
     }];
     }];
 }
 }
@@ -568,7 +573,7 @@
 // Receive data message on iOS 10 devices while app is in the foreground.
 // Receive data message on iOS 10 devices while app is in the foreground.
 - (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
 - (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
     // Print full message
     // Print full message
-    NSLog(@"%@", remoteMessage.appData);
+    NSLog(@"[LOG] %@", remoteMessage.appData);
 }
 }
 #endif
 #endif
 
 

+ 3 - 2
iOSClient/Networking/OCNetworking.h

@@ -112,17 +112,18 @@
 - (void)getUserProfileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 - (void)getUserProfileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 
 
 // Search
 // Search
-
 - (void)searchSuccess:(CCMetadataNet *)metadataNet metadatas:(NSArray *)metadatas;
 - (void)searchSuccess:(CCMetadataNet *)metadataNet metadatas:(NSArray *)metadatas;
 - (void)searchFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 - (void)searchFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 
 
 // Favorite
 // Favorite
-
 - (void)settingFavoriteSuccess:(CCMetadataNet *)metadataNet;
 - (void)settingFavoriteSuccess:(CCMetadataNet *)metadataNet;
 - (void)settingFavoriteFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 - (void)settingFavoriteFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 - (void)listingFavoritesSuccess:(CCMetadataNet *)metadataNet metadatas:(NSArray *)metadatas;
 - (void)listingFavoritesSuccess:(CCMetadataNet *)metadataNet metadatas:(NSArray *)metadatas;
 - (void)listingFavoritesFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 - (void)listingFavoritesFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 
 
+// Subscribing Nextcloud Server
+- (void)subscribingNextcloudServerFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
+
 @end
 @end
 
 
 @interface OCURLSessionManager : AFURLSessionManager
 @interface OCURLSessionManager : AFURLSessionManager

+ 18 - 0
iOSClient/Networking/OCNetworking.m

@@ -1436,6 +1436,15 @@
             if (errorCode == 0)
             if (errorCode == 0)
                 errorCode = error.code;
                 errorCode = error.code;
             
             
+            // Error
+            if ([self.delegate respondsToSelector:@selector(subscribingNextcloudServerFailure:message:errorCode:)]) {
+                
+                if (errorCode == 503)
+                    [self.delegate subscribingNextcloudServerFailure:_metadataNet message:NSLocalizedStringFromTable(@"_server_error_retry_", @"Error", nil) errorCode:errorCode];
+                else
+                    [self.delegate subscribingNextcloudServerFailure:_metadataNet message:[error.userInfo valueForKey:@"NSLocalizedDescription"] errorCode:errorCode];
+            }
+            
             // Request trusted certificated
             // Request trusted certificated
             if ([error code] == NSURLErrorServerCertificateUntrusted)
             if ([error code] == NSURLErrorServerCertificateUntrusted)
                 [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:(UIViewController *)self.delegate delegate:self];
                 [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:(UIViewController *)self.delegate delegate:self];
@@ -1452,6 +1461,15 @@
         if (errorCode == 0)
         if (errorCode == 0)
             errorCode = error.code;
             errorCode = error.code;
     
     
+        // Error
+        if ([self.delegate respondsToSelector:@selector(subscribingNextcloudServerFailure:message:errorCode:)]) {
+            
+            if (errorCode == 503)
+                [self.delegate subscribingNextcloudServerFailure:_metadataNet message:NSLocalizedStringFromTable(@"_server_error_retry_", @"Error", nil) errorCode:errorCode];
+            else
+                [self.delegate subscribingNextcloudServerFailure:_metadataNet message:[error.userInfo valueForKey:@"NSLocalizedDescription"] errorCode:errorCode];
+        }
+
         // Request trusted certificated
         // Request trusted certificated
         if ([error code] == NSURLErrorServerCertificateUntrusted)
         if ([error code] == NSURLErrorServerCertificateUntrusted)
             [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:(UIViewController *)self.delegate delegate:self];
             [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:(UIViewController *)self.delegate delegate:self];