@@ -100,37 +100,33 @@ - (BFTask *)getCurrentObjectAsync {
100
100
return nil ;
101
101
}] continueWithBlock: ^id (BFTask *task) {
102
102
@strongify (self);
103
- if (task.faulted ) {
104
- return task;
105
- }
106
103
107
- PFInstallation *installation = task.result ;
108
- // TODO: (nlutsenko) Make it not terrible aka actually use task chaining here.
109
- NSString *installationId = [[self .installationIdentifierStore getInstallationIdentifierAsync ] waitForResult: nil ];
110
- installationId = installationId.lowercaseString ;
111
- if (!installation || ![installationId isEqualToString: installation.installationId]) {
112
- // If there's no installation object, or the object's installation
113
- // ID doesn't match this device's installation ID, create a new
114
- // installation. Try to keep track of the previously stored device
115
- // token: if there was an installation already stored just re-use
116
- // its device token, otherwise try loading from the keychain (where
117
- // old SDKs stored the token). Discard the old installation.
118
- NSString *oldDeviceToken = nil ;
119
- if (installation) {
120
- oldDeviceToken = installation.deviceToken ;
121
- } else {
122
- oldDeviceToken = [[PFPush pushInternalUtilClass ] getDeviceTokenFromKeychain ];
123
- }
104
+ __block PFInstallation *installation = task.result ;
105
+ return [[self .installationIdentifierStore getInstallationIdentifierAsync ] continueWithBlock: ^id _Nullable (BFTask<NSString *> * _Nonnull task) {
106
+ NSString *installationId = task.result .lowercaseString ;
107
+ if (!installation || ![installationId isEqualToString: installation.installationId]) {
108
+ // If there's no installation object, or the object's installation
109
+ // ID doesn't match this device's installation ID, create a new
110
+ // installation. Try to keep track of the previously stored device
111
+ // token: if there was an installation already stored just re-use
112
+ // its device token, otherwise try loading from the keychain (where
113
+ // old SDKs stored the token). Discard the old installation.
114
+ NSString *oldDeviceToken = nil ;
115
+ if (installation) {
116
+ oldDeviceToken = installation.deviceToken ;
117
+ } else {
118
+ oldDeviceToken = [[PFPush pushInternalUtilClass ] getDeviceTokenFromKeychain ];
119
+ }
124
120
125
- installation = [PFInstallation object ];
126
- installation.deviceType = kPFDeviceType ;
127
- installation.installationId = installationId;
128
- if (oldDeviceToken) {
129
- installation.deviceToken = oldDeviceToken;
121
+ installation = [PFInstallation object ];
122
+ installation.deviceType = kPFDeviceType ;
123
+ installation.installationId = installationId;
124
+ if (oldDeviceToken) {
125
+ installation.deviceToken = oldDeviceToken;
126
+ }
130
127
}
131
- }
132
-
133
- return installation;
128
+ return installation;
129
+ }];
134
130
}] continueWithBlock: ^id (BFTask *task) {
135
131
dispatch_barrier_sync (_dataQueue, ^{
136
132
_currentInstallation = task.result ;
0 commit comments