@@ -63,11 +63,6 @@ - (void)present:(nonnull IMGLYMediaEditViewControllerBlock)createMediaEditViewCo
6363 }
6464
6565 dispatch_async (dispatch_get_main_queue (), ^{
66- if (self.licenseError != nil ) {
67- reject (RN_IMGLY.kErrorUnableToUnlock , [NSString RN_IMGLY_string: @" Unable to unlock with license." withError: self .licenseError], self.licenseError );
68- return ;
69- }
70-
7166 PESDKAssetCatalog *assetCatalog = PESDKAssetCatalog.defaultItems ;
7267 PESDKConfiguration *configuration = [[PESDKConfiguration alloc ] initWithBuilder: ^(PESDKConfigurationBuilder * _Nonnull builder) {
7368 builder.assetCatalog = assetCatalog;
@@ -169,34 +164,24 @@ - (void)dismiss:(nullable PESDKMediaEditViewController *)mediaEditViewController
169164 });
170165}
171166
172- - (void )handleLicenseError : (nullable NSError *)error
167+ - (void )handleLicenseError : (nullable NSError *)error resolve : (nonnull RCTPromiseResolveBlock) resolve reject : (nonnull RCTPromiseRejectBlock) reject
173168{
174- self.licenseError = nil ;
175169 if (error != nil ) {
176- if ([error.domain isEqualToString: @" ImglyKit.IMGLY.Error" ]) {
177- switch (error.code ) {
178- case 3 :
179- RCTLogWarn (@" %@ : %@ " , NSStringFromClass (self.class ), error.localizedDescription );
180- break ;
181- default :
182- self.licenseError = error;
183- RCTLogError (@" %@ : %@ " , NSStringFromClass (self.class ), error.localizedDescription );
184- break ;
185- }
186- } else {
187- self.licenseError = error;
188- RCTLogError (@" Error while unlocking with license: %@ " , error);
189- }
170+ reject (RN_IMGLY.kErrorUnableToUnlock , [NSString RN_IMGLY_string: @" Unable to unlock with license." withError: error], error);
171+ return ;
172+ } else {
173+ resolve (nil );
174+ return ;
190175 }
191176}
192177
193- - (void )unlockWithLicenseURL : (nonnull NSURL *)url {}
178+ - (void )unlockWithLicenseURL : (nonnull NSURL *)url resolve : (nonnull RCTPromiseResolveBlock) resolve reject : (nonnull RCTPromiseRejectBlock) reject {}
194179
195- - (void )unlockWithLicenseString : (nonnull NSString *)string {}
180+ - (void )unlockWithLicenseString : (nonnull NSString *)string resolve : (nonnull RCTPromiseResolveBlock) resolve reject : (nonnull RCTPromiseRejectBlock) reject {}
196181
197- - (void )unlockWithLicenseObject : (nonnull NSDictionary *)dictionary {}
182+ - (void )unlockWithLicenseObject : (nonnull NSDictionary *)dictionary resolve : (nonnull RCTPromiseResolveBlock) resolve reject : (nonnull RCTPromiseRejectBlock) reject {}
198183
199- - (void )unlockWithLicense : (nonnull id )json
184+ - (void )unlockWithLicense : (nonnull id )json resolve : (nonnull RCTPromiseResolveBlock) resolve reject : (nonnull RCTPromiseRejectBlock) reject
200185{
201186 NSString *string = nil ;
202187 NSURL *url = nil ;
@@ -222,14 +207,14 @@ - (void)unlockWithLicense:(nonnull id)json
222207 }
223208
224209 if (url != nil ) {
225- [self unlockWithLicenseURL: url];
210+ [self unlockWithLicenseURL: url resolve: resolve reject: reject ];
226211 }
227212 else if (string != nil ) {
228- [self unlockWithLicenseString: string];
213+ [self unlockWithLicenseString: string resolve: resolve reject: reject ];
229214 }
230215 else if ([json isKindOfClass: [NSDictionary class ]]) {
231216 NSDictionary *dictionary = json;
232- [self unlockWithLicenseObject: dictionary];
217+ [self unlockWithLicenseObject: dictionary resolve: resolve reject: reject ];
233218 }
234219 else if (json) {
235220 RCTLogConvertError (json, @" a valid license format" );
0 commit comments