Showing
5 changed files
with
266 additions
and
12 deletions
... | @@ -284,10 +284,8 @@ WL_VERSION_INTERFACE() | ... | @@ -284,10 +284,8 @@ WL_VERSION_INTERFACE() |
284 | */ | 284 | */ |
285 | - (BOOL)getInboxWithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; | 285 | - (BOOL)getInboxWithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; |
286 | 286 | ||
287 | - | ||
288 | - (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; | 287 | - (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; |
289 | 288 | ||
290 | - | ||
291 | - (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params))success failureBlock:(void(^)(NSError *error))failure; | 289 | - (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params))success failureBlock:(void(^)(NSError *error))failure; |
292 | 290 | ||
293 | - (void)sendContactWithSuccessBlock:(NSString *)name andEmail:(NSString *)email andMsisdn:msisdn andMessage:message :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure; | 291 | - (void)sendContactWithSuccessBlock:(NSString *)name andEmail:(NSString *)email andMsisdn:msisdn andMessage:message :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure; |
... | @@ -363,6 +361,7 @@ WL_VERSION_INTERFACE() | ... | @@ -363,6 +361,7 @@ WL_VERSION_INTERFACE() |
363 | 361 | ||
364 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 362 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
365 | 363 | ||
364 | +- (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
366 | /*! | 365 | /*! |
367 | @abstract Get the full page add accordint to the display_type of a campaign. | 366 | @abstract Get the full page add accordint to the display_type of a campaign. |
368 | @attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered. | 367 | @attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered. | ... | ... |
... | @@ -430,6 +430,29 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -430,6 +430,29 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
430 | return [self isRegistrationValid]; | 430 | return [self isRegistrationValid]; |
431 | } | 431 | } |
432 | 432 | ||
433 | +- (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure | ||
434 | +{ | ||
435 | + if (self.allOffers.count > 0) { | ||
436 | + success(self.allOffers); | ||
437 | + } else { | ||
438 | + NSDictionary *postDictionary = @{@"offers": @{@"action": @"get_inbox"}}; | ||
439 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
440 | + | ||
441 | + [self sendContext:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
442 | + if (success) { | ||
443 | + success([contextResponse valueForKey:@"MAPP_OFFER"]); | ||
444 | + } | ||
445 | + } failureBlock:^(NSError *error) { | ||
446 | + if (failure) { | ||
447 | + failure(error); | ||
448 | + } | ||
449 | + }]; | ||
450 | + } | ||
451 | + | ||
452 | + | ||
453 | + return [self isRegistrationValid]; | ||
454 | +} | ||
455 | + | ||
433 | - (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure | 456 | - (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure |
434 | { | 457 | { |
435 | if (filter == nil) { | 458 | if (filter == nil) { |
... | @@ -556,6 +579,41 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -556,6 +579,41 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
556 | }]; | 579 | }]; |
557 | } | 580 | } |
558 | 581 | ||
582 | +- (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
583 | +{ | ||
584 | + NSDictionary *postDictionary = @{@"guid": guid, @"app_uuid": appUuid, @"ticket": ticket }; | ||
585 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
586 | + [self sendContextCosmote:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
587 | + if (success) { | ||
588 | + NSString* clientId = [NSString alloc]; | ||
589 | + clientId = [contextResponse objectForKey:@"client_id"]; | ||
590 | + NSString* clientSecret = [NSString alloc]; | ||
591 | + clientSecret = [contextResponse objectForKey:@"client_secret"]; | ||
592 | + NSString* refreshToken = [NSString alloc]; | ||
593 | + refreshToken = [contextResponse objectForKey:@"refresh_token"]; | ||
594 | + NSString* accessToken = [NSString alloc]; | ||
595 | + accessToken = [contextResponse objectForKey:@"access_oken"]; | ||
596 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
597 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
598 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
599 | + WL_FMDBLogError | ||
600 | + | ||
601 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, refreshToken, accessToken]; | ||
602 | + } else { | ||
603 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", clientId, clientSecret, refreshToken, accessToken]; | ||
604 | + } | ||
605 | + success(contextResponse); | ||
606 | + } | ||
607 | + } failureBlock:^(NSError *error) { | ||
608 | + if (failure) { | ||
609 | + failure(error); | ||
610 | + } | ||
611 | + NSLog(@"Error at fetching tags categories %@", error ); | ||
612 | + }]; | ||
613 | + | ||
614 | +} | ||
615 | + | ||
616 | + | ||
559 | - (void)loginWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 617 | - (void)loginWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
560 | { | 618 | { |
561 | NSString* webId = [NSString alloc]; | 619 | NSString* webId = [NSString alloc]; |
... | @@ -2199,6 +2257,34 @@ return appIsRegisteredWithWarply; | ... | @@ -2199,6 +2257,34 @@ return appIsRegisteredWithWarply; |
2199 | return appIsRegisteredWithWarply; | 2257 | return appIsRegisteredWithWarply; |
2200 | } | 2258 | } |
2201 | 2259 | ||
2260 | +- (BOOL)sendContextCosmote:(NSData*)context | ||
2261 | + successBlock:(void (^)(NSDictionary *contextResponse))successBlock | ||
2262 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
2263 | +{ | ||
2264 | + BOOL appIsRegisteredWithWarply = [self isRegistrationValid]; | ||
2265 | + | ||
2266 | + if (WL_FEATURE_IS_DISABLED_WITH_KEY(WL_WARPLY_ENABLED)) | ||
2267 | + return appIsRegisteredWithWarply; | ||
2268 | + | ||
2269 | + if (appIsRegisteredWithWarply == NO) { | ||
2270 | + [_pendingOperationsQueue setSuspended:YES]; | ||
2271 | + [self registration]; | ||
2272 | + } | ||
2273 | + NSString *path = nil; | ||
2274 | + | ||
2275 | + NSInvocation *invocation = [self contextRequestInvocationWithTypeCosmote:WLContextRequestTypePost | ||
2276 | + data:context | ||
2277 | + path:path | ||
2278 | + successBlock:[successBlock copy] | ||
2279 | + failureBlock:[failureBlock copy]]; | ||
2280 | + | ||
2281 | + | ||
2282 | + NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvocation:invocation]; | ||
2283 | + [_pendingOperationsQueue addOperation:operation]; | ||
2284 | + | ||
2285 | + return appIsRegisteredWithWarply; | ||
2286 | +} | ||
2287 | + | ||
2202 | #pragma - Events | 2288 | #pragma - Events |
2203 | /////////////////////////////////////////////////////////////////////////////// | 2289 | /////////////////////////////////////////////////////////////////////////////// |
2204 | - (void)addEvent:(WLEvent *)event priority:(BOOL)priority | 2290 | - (void)addEvent:(WLEvent *)event priority:(BOOL)priority |
... | @@ -3726,6 +3812,29 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -3726,6 +3812,29 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
3726 | return invocation; | 3812 | return invocation; |
3727 | } | 3813 | } |
3728 | 3814 | ||
3815 | +- (NSInvocation *)contextRequestInvocationWithTypeCosmote:(WLContextRequestType)type | ||
3816 | + data:(NSData *)context | ||
3817 | + path:(NSString *)path | ||
3818 | + successBlock:(void (^)(NSDictionary *contextResponse))successBlock | ||
3819 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
3820 | +{ | ||
3821 | + void (^ successBlockCopy)(void) = [successBlock copy]; | ||
3822 | + void (^ failureBlockCopy)(void) = [failureBlock copy]; | ||
3823 | + | ||
3824 | + NSMethodSignature *sgn = [self methodSignatureForSelector:@selector(runContextRequestWithTypeCosmote:data:path:successBlock:failureBlock:)]; | ||
3825 | + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sgn]; | ||
3826 | + [invocation setTarget:self]; | ||
3827 | + [invocation setSelector:@selector(runContextRequestWithTypeCosmote:data:path:successBlock:failureBlock:)]; | ||
3828 | + [invocation setArgument:&type atIndex:2]; | ||
3829 | + [invocation setArgument:&context atIndex:3]; | ||
3830 | + [invocation setArgument:&path atIndex:4]; | ||
3831 | + [invocation setArgument:&successBlockCopy atIndex:5]; | ||
3832 | + [invocation setArgument:&failureBlockCopy atIndex:6]; | ||
3833 | + [invocation retainArguments]; | ||
3834 | + return invocation; | ||
3835 | +} | ||
3836 | + | ||
3837 | + | ||
3729 | - (void)runVerifyTicketRequestWithType:(WLContextRequestType)requestType | 3838 | - (void)runVerifyTicketRequestWithType:(WLContextRequestType)requestType |
3730 | data:(NSData*)context | 3839 | data:(NSData*)context |
3731 | path:(NSString *)path | 3840 | path:(NSString *)path |
... | @@ -3958,6 +4067,133 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -3958,6 +4067,133 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
3958 | } | 4067 | } |
3959 | } | 4068 | } |
3960 | 4069 | ||
4070 | +- (void)runContextRequestWithTypeCosmote:(WLContextRequestType)requestType | ||
4071 | + data:(NSData*)context | ||
4072 | + path:(NSString *)path | ||
4073 | + successBlock:(void (^)(id contextResponse))successBlock | ||
4074 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
4075 | +{ | ||
4076 | + //Create REQUEST | ||
4077 | + NSMutableString *urlString = [NSMutableString stringWithFormat:@"partners/gapp/verify"]; | ||
4078 | + | ||
4079 | + WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); | ||
4080 | + | ||
4081 | + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:100]; | ||
4082 | + | ||
4083 | + NSDictionary *parameters; | ||
4084 | + | ||
4085 | + if (context != nil) { | ||
4086 | + parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL]; | ||
4087 | + } | ||
4088 | + | ||
4089 | + SuccessResponse successResponse = ^(NSURLSessionDataTask * _Nonnull task, id _Nullable JSON) { | ||
4090 | + if (JSON == nil) { | ||
4091 | + successBlock(@{@"status": @"0"}); | ||
4092 | + } | ||
4093 | + else { | ||
4094 | + | ||
4095 | +// NSData *responseData = [NSJSONSerialization dataWithJSONObject:JSON options:NSJSONWritingPrettyPrinted error:NULL]; | ||
4096 | +// NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; | ||
4097 | + // WLLOG(@"[WARP Trace] HTTP %@ Response:%@", request.HTTPMethod, responseString); | ||
4098 | + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod); | ||
4099 | + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId); | ||
4100 | + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey); | ||
4101 | + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString); | ||
4102 | + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding]; | ||
4103 | + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString); | ||
4104 | + WLLOG(@"*************************************************"); | ||
4105 | + NSDictionary *contextResponse=[JSON valueForKey:@"context"]; | ||
4106 | + | ||
4107 | + | ||
4108 | + | ||
4109 | + if ([JSON objectForKey:@"status"]) { | ||
4110 | + | ||
4111 | + int status = [[JSON valueForKey:@"status"] intValue]; | ||
4112 | + | ||
4113 | + if (status != WLResultCodesSuccess) | ||
4114 | + { | ||
4115 | + if ((status == WLResultCodesInvalidWebID) || (status == WLResultCodesDeviceRegistrationFailed)) | ||
4116 | + { | ||
4117 | + self.webId = nil; | ||
4118 | + self.apiKey = nil; | ||
4119 | + | ||
4120 | + [_pendingOperationsQueue setSuspended:YES]; | ||
4121 | + } | ||
4122 | + | ||
4123 | + NSString *errorDescrition = (status <= [WLResultCodesDescriptions count]) && status > 0 ? (WLResultCodesDescriptions[(status-1)]) : ([NSString stringWithFormat:@"Internal WARP Server error %d", status]); | ||
4124 | + | ||
4125 | + NSDictionary *eDict = @{NSLocalizedDescriptionKey: errorDescrition}; | ||
4126 | + NSError *error = [NSError errorWithDomain:WARP_ERROR_DOMAIN code:status userInfo:eDict]; | ||
4127 | + | ||
4128 | + if (failureBlock) | ||
4129 | + failureBlock(error); | ||
4130 | + | ||
4131 | + return; | ||
4132 | + } | ||
4133 | + | ||
4134 | + if (successBlock) | ||
4135 | + { | ||
4136 | + if ([path length]!=0) | ||
4137 | + { | ||
4138 | + successBlock([contextResponse valueForKey:path]); | ||
4139 | + return; | ||
4140 | + } | ||
4141 | + successBlock(contextResponse); | ||
4142 | + } | ||
4143 | + | ||
4144 | + | ||
4145 | + }else{ | ||
4146 | + NSError *error = [NSError errorWithDomain:WARP_ERROR_DOMAIN code:1026 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"Empty response", @"Warply")}]; | ||
4147 | + if (failureBlock) | ||
4148 | + failureBlock(error); | ||
4149 | + | ||
4150 | + } | ||
4151 | + | ||
4152 | + } | ||
4153 | + }; | ||
4154 | + | ||
4155 | + FailureResponse faliureResponse = ^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { | ||
4156 | + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod); | ||
4157 | + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId); | ||
4158 | + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey); | ||
4159 | + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString); | ||
4160 | + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding]; | ||
4161 | + | ||
4162 | + | ||
4163 | + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString); | ||
4164 | + WLLOG(@"[WARP Trace] Error: %@", [error description]); | ||
4165 | + WLLOG(@"*************************************************"); | ||
4166 | + if (failureBlock) | ||
4167 | + failureBlock(error); | ||
4168 | + }; | ||
4169 | + | ||
4170 | + _httpClient.responseSerializer = [AFJSONResponseSerializer serializer]; | ||
4171 | + _httpClient.requestSerializer = [AFJSONRequestSerializer serializer]; | ||
4172 | + | ||
4173 | + //Set HTTP Headers | ||
4174 | + time_t timestamp = (time_t) [[NSDate date] timeIntervalSince1970]; | ||
4175 | + [_httpClient.requestSerializer setValue:_webId forHTTPHeaderField:@"loyalty-web-id"]; | ||
4176 | + [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"%lu", timestamp] forHTTPHeaderField:@"loyalty-date"]; | ||
4177 | + [_httpClient.requestSerializer setValue:[[NSString stringWithFormat:@"%@%lu", _apiKey, timestamp] SHA256Sum] forHTTPHeaderField:@"loyalty-signature"]; | ||
4178 | + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; | ||
4179 | + [_httpClient.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; | ||
4180 | + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"User-Agent"]; | ||
4181 | + [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"ios:%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]] forHTTPHeaderField:@"loyalty-bundle-id"]; | ||
4182 | + [_httpClient.requestSerializer setValue:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forHTTPHeaderField:@"unique-device-id"]; | ||
4183 | + [_httpClient.requestSerializer setValue:@"apple" forHTTPHeaderField:@"vendor"]; | ||
4184 | + [_httpClient.requestSerializer setValue:@"platform" forHTTPHeaderField:@"ios"]; | ||
4185 | + [_httpClient.requestSerializer setValue:@"os_version" forHTTPHeaderField:[[UIDevice currentDevice] systemVersion]]; | ||
4186 | + [_httpClient.requestSerializer setValue:@"mobile" forHTTPHeaderField:@"channel"]; | ||
4187 | + if (requestType == WLContextRequestTypePost) { | ||
4188 | +// NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL]; | ||
4189 | + | ||
4190 | + [_httpClient POST:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse]; | ||
4191 | + } | ||
4192 | + else { | ||
4193 | + [_httpClient GET:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse]; | ||
4194 | + } | ||
4195 | +} | ||
4196 | + | ||
3961 | - (void)runContextRequestWithType2:(WLContextRequestType)requestType | 4197 | - (void)runContextRequestWithType2:(WLContextRequestType)requestType |
3962 | data:(NSData*)context | 4198 | data:(NSData*)context |
3963 | path:(NSString *)path | 4199 | path:(NSString *)path | ... | ... |
No preview for this file type
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | - (void) setToStage; | 16 | - (void) setToStage; |
17 | - (void) setLang:(NSString*) lang; | 17 | - (void) setLang:(NSString*) lang; |
18 | - (UIViewController *) openCoupons:(UIView*) parentView; | 18 | - (UIViewController *) openCoupons:(UIView*) parentView; |
19 | -- (UIViewController *) openGifts; | ||
20 | - (void) applicationDidEnterBackground:(UIApplication *)application; | 19 | - (void) applicationDidEnterBackground:(UIApplication *)application; |
21 | - (void) applicationWillEnterForeground:(UIApplication *)application; | 20 | - (void) applicationWillEnterForeground:(UIApplication *)application; |
22 | - (void) applicationDidBecomeActive:(UIApplication *)application; | 21 | - (void) applicationDidBecomeActive:(UIApplication *)application; |
... | @@ -60,6 +59,7 @@ | ... | @@ -60,6 +59,7 @@ |
60 | - (NSDictionary*)getCouponSetsWithActive:(NSNumber*)active andVisible:(NSNumber*)visible andUuids:(NSArray*)uuids; | 59 | - (NSDictionary*)getCouponSetsWithActive:(NSNumber*)active andVisible:(NSNumber*)visible andUuids:(NSArray*)uuids; |
61 | - (NSDictionary*)redeemCouponWithCoupon:(NSString*)coupon; | 60 | - (NSDictionary*)redeemCouponWithCoupon:(NSString*)coupon; |
62 | - (NSDictionary*)validateCouponWithCoupon:(NSString*)coupon; | 61 | - (NSDictionary*)validateCouponWithCoupon:(NSString*)coupon; |
62 | +- (NSDictionary*)loginCosmoteWithGuid:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket; | ||
63 | 63 | ||
64 | @end | 64 | @end |
65 | #endif /* MyApi_h */ | 65 | #endif /* MyApi_h */ | ... | ... |
... | @@ -47,19 +47,11 @@ NSString *LANG; | ... | @@ -47,19 +47,11 @@ NSString *LANG; |
47 | } | 47 | } |
48 | 48 | ||
49 | - (UIViewController *) openCoupons:(UIView*) parentView{ | 49 | - (UIViewController *) openCoupons:(UIView*) parentView{ |
50 | + | ||
50 | UIViewController *couponsViewController = [CouponsViewInterface couponsViewController:parentView]; | 51 | UIViewController *couponsViewController = [CouponsViewInterface couponsViewController:parentView]; |
51 | return couponsViewController; | 52 | return couponsViewController; |
52 | } | 53 | } |
53 | 54 | ||
54 | -- (UIViewController *) openGifts{ | ||
55 | - | ||
56 | - UIViewController *giftsViewController = [GiftsViewInterface giftsViewController]; | ||
57 | -// controller = [[UINavigationController alloc]initWithRootViewController:profileViewController]; | ||
58 | - | ||
59 | -// [window makeKeyAndVisible]; | ||
60 | - return giftsViewController; | ||
61 | -} | ||
62 | - | ||
63 | //- (UIViewController *) openCoupons { | 55 | //- (UIViewController *) openCoupons { |
64 | //// NSString* const frameworkBundleID = @"framework.warp.ly.WarplySDKFrameworkIOS"; | 56 | //// NSString* const frameworkBundleID = @"framework.warp.ly.WarplySDKFrameworkIOS"; |
65 | //// NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID]; | 57 | //// NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID]; |
... | @@ -1132,4 +1124,31 @@ NSString *LANG; | ... | @@ -1132,4 +1124,31 @@ NSString *LANG; |
1132 | } | 1124 | } |
1133 | return resp; | 1125 | return resp; |
1134 | } | 1126 | } |
1127 | + | ||
1128 | +- (NSDictionary*)loginCosmoteWithGuid:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket { | ||
1129 | + __block NSDictionary *resp = [NSDictionary alloc]; | ||
1130 | + __block BOOL isRunLoopNested = NO; | ||
1131 | + __block BOOL isOperationCompleted = NO; | ||
1132 | + [[Warply sharedService] loginCosmoteWithSuccessBlock:guid andAppUuid:appUuid andTicket:ticket :^(NSDictionary *response) { | ||
1133 | + resp = response; | ||
1134 | + isOperationCompleted = YES; | ||
1135 | + if (isRunLoopNested) { | ||
1136 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1137 | + } | ||
1138 | + } failureBlock:^(NSError *error) { | ||
1139 | + NSLog(@"%@", error); | ||
1140 | + resp = nil; | ||
1141 | + isOperationCompleted = YES; | ||
1142 | + if (isRunLoopNested) { | ||
1143 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1144 | + } | ||
1145 | + }]; | ||
1146 | + if ( ! isOperationCompleted) { | ||
1147 | + isRunLoopNested = YES; | ||
1148 | + NSLog(@"Waiting..."); | ||
1149 | + CFRunLoopRun(); // Magic! | ||
1150 | + isRunLoopNested = NO; | ||
1151 | + } | ||
1152 | + return resp; | ||
1153 | +} | ||
1135 | @end | 1154 | @end | ... | ... |
-
Please register or login to post a comment