Showing
3 changed files
with
28 additions
and
0 deletions
No preview for this file type
... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
21 | - (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; | 21 | - (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; |
22 | - (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; | 22 | - (void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; |
23 | - (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo; | 23 | - (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo; |
24 | +- (NSMutableArray *)getInbox; | ||
24 | - (NSMutableArray *)getProducts:(NSString *) filter; | 25 | - (NSMutableArray *)getProducts:(NSString *) filter; |
25 | - (NSMutableArray*)sendContact:(NSString*)name email:(NSString*)email msisdn:(NSString*)msisdn message:(NSString*)message; | 26 | - (NSMutableArray*)sendContact:(NSString*)name email:(NSString*)email msisdn:(NSString*)msisdn message:(NSString*)message; |
26 | - (NSMutableArray *)getContentWithCategory:(NSString *)category tags:(NSArray *)tags; | 27 | - (NSMutableArray *)getContentWithCategory:(NSString *)category tags:(NSArray *)tags; | ... | ... |
... | @@ -92,6 +92,33 @@ NSString *LANG; | ... | @@ -92,6 +92,33 @@ NSString *LANG; |
92 | [[Warply sharedService].pushManager resetBadge]; | 92 | [[Warply sharedService].pushManager resetBadge]; |
93 | } | 93 | } |
94 | 94 | ||
95 | +- (NSMutableArray *)getInbox { | ||
96 | + __block NSArray *in = [NSMutableArray alloc]; | ||
97 | + __block BOOL isRunLoopNested = NO; | ||
98 | + __block BOOL isOperationCompleted = NO; | ||
99 | + [[Warply sharedService] getInboxWithSuccessBlock :^(NSArray *inbox) { | ||
100 | + in = inbox; | ||
101 | + isOperationCompleted = YES; | ||
102 | + if (isRunLoopNested) { | ||
103 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
104 | + } | ||
105 | + } failureBlock:^(NSError *error) { | ||
106 | + NSLog(@"%@", error); | ||
107 | + in = nil; | ||
108 | + isOperationCompleted = YES; | ||
109 | + if (isRunLoopNested) { | ||
110 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
111 | + } | ||
112 | + }]; | ||
113 | + if ( ! isOperationCompleted) { | ||
114 | + isRunLoopNested = YES; | ||
115 | + NSLog(@"Waiting..."); | ||
116 | + CFRunLoopRun(); // Magic! | ||
117 | + isRunLoopNested = NO; | ||
118 | + } | ||
119 | + return in; | ||
120 | +} | ||
121 | + | ||
95 | - (NSMutableArray *)getProducts:(NSString *) filter { | 122 | - (NSMutableArray *)getProducts:(NSString *) filter { |
96 | __block NSMutableArray *prods = [NSMutableArray alloc]; | 123 | __block NSMutableArray *prods = [NSMutableArray alloc]; |
97 | __block BOOL isRunLoopNested = NO; | 124 | __block BOOL isRunLoopNested = NO; | ... | ... |
-
Please register or login to post a comment