inapp: if account expired, go to inapp view

This commit is contained in:
Gautier Pelloux-Prayer 2015-04-27 16:16:28 +02:00
parent 3e275a95b1
commit eff5cfdd5d
2 changed files with 25 additions and 19 deletions

View file

@ -27,6 +27,9 @@
#import "Utils.h"
#import "LinphoneManager.h"
#import "PhoneMainView.h"
#import "InAppProductsViewController.h"
NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotification";
@ -254,22 +257,25 @@ NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotificati
// [waitView setHidden:true];
if ([response isFault]) {
LOGE(@"Communication issue (%@)", [response faultString]);
// NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [response faultString]];
// UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue",nil)
// message:errorString
// delegate:nil
// cancelButtonTitle:NSLocalizedString(@"Continue",nil)
// otherButtonTitles:nil,nil];
// [errorView show];
// [errorView release];
NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [response faultString]];
UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue",nil)
message:errorString
delegate:nil
cancelButtonTitle:NSLocalizedString(@"Continue",nil)
otherButtonTitles:nil,nil];
[errorView show];
[errorView release];
} else if([response object] != nil) {
//Don't handle if not object: HTTP/Communication Error
if([[request method] isEqualToString:@"get_expiration_date"]) {
if([response object] == [NSNumber numberWithInt:1]) {
if(false && [response object] == [NSNumber numberWithInt:1]) {
LOGE(@"Todo: parse the response");
// [_productsIDPurchased addObject:@"test.auto_renew_7days"];
[self postNotificationforStatus:IAPReceiptSucceeded];
return;
} else {
LOGI(@"Account has expired");
[[PhoneMainView instance] changeCurrentView:[InAppProductsViewController compositeViewDescription]];
}
}
}
@ -279,15 +285,15 @@ NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotificati
- (void)XMLRPCRequest:(XMLRPCRequest *)request didFailWithError:(NSError *)error {
LOGE(@"Communication issue (%@)", [error localizedDescription]);
// NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [error localizedDescription]];
// UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue", nil)
// message:errorString
// delegate:nil
// cancelButtonTitle:NSLocalizedString(@"Continue", nil)
// otherButtonTitles:nil,nil];
// [errorView show];
// [errorView release];
// [waitView setHidden:true];
NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [error localizedDescription]];
UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue", nil)
message:errorString
delegate:nil
cancelButtonTitle:NSLocalizedString(@"Continue", nil)
otherButtonTitles:nil,nil];
[errorView show];
[errorView release];
[waitView setHidden:true];
latestReceiptMD5 = nil;
[self postNotificationforStatus:IAPReceiptFailed];
}

View file

@ -240,7 +240,7 @@
- (NSString *)md5 {
const char *ptr = [self UTF8String];
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(ptr, strlen(ptr), md5Buffer);
CC_MD5(ptr, (unsigned int)strlen(ptr), md5Buffer);
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x",md5Buffer[i]];