diff --git a/MASFoundation/Classes/_private_/services/model/MASModelService.m b/MASFoundation/Classes/_private_/services/model/MASModelService.m index 26f50a98..0aa71154 100644 --- a/MASFoundation/Classes/_private_/services/model/MASModelService.m +++ b/MASFoundation/Classes/_private_/services/model/MASModelService.m @@ -684,6 +684,11 @@ - (void)deregisterCurrentDeviceWithCompletion:(MASCompletionErrorBlock)completio // MASIMutableOrderedDictionary *mutableHeaderInfo = [MASIMutableOrderedDictionary new]; + // + // Post the Mobile SDK will attempt to deregister device + // + [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceWillDeregisterNotification object:self]; + __block MASModelService *blockSelf = self; // @@ -694,6 +699,23 @@ - (void)deregisterCurrentDeviceWithCompletion:(MASCompletionErrorBlock)completio andHeaders:mutableHeaderInfo completion:^(NSDictionary *responseInfo, NSError *error) { + // + // Detect if error, if so stop here + // + if(error) + { + // + // Post the did fail to deregister in cloud notification + // + [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidFailToDeregisterNotification object:self]; + + // + // Notify + // + if(completion) completion(NO, [NSError errorFromApiResponseInfo:responseInfo andError:error]); + + return; + } // // Clear currentUser object upon log-out @@ -727,24 +749,6 @@ - (void)deregisterCurrentDeviceWithCompletion:(MASCompletionErrorBlock)completio // [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidDeregisterOnDeviceNotification object:self]; - // - // Detect if error, if so stop here - // - if(error) - { - // - // Post the did fail to deregister in cloud notification - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidFailToDeregisterNotification object:self]; - - // - // Notify - // - if(completion) completion(NO, [NSError errorFromApiResponseInfo:responseInfo andError:error]); - - return; - } - // // Post the did deregister in cloud notification //