Skip to content
Browse files

Updated readme

  • Loading branch information...
1 parent 8492bc2 commit a5b123ce0856e02a3214507ff9b9934b37b390ca @possan committed
Showing with 13 additions and 18 deletions.
  1. +0 −4 IOSMQ.h
  2. +6 −13 IOSMQ.m
  3. +7 −1 README.md
View
4 IOSMQ.h
@@ -1,14 +1,11 @@
//
// IOSMQ.h
-// Flyessence
//
// Created by Per-Olov Jernberg on 2012-02-22.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
-
@interface IOSMQMessage : NSObject
+ (IOSMQMessage *)message;
@@ -28,7 +25,6 @@
@end
-
@interface IOSMQ : NSObject<UIWebViewDelegate> {
NSTimer *timer;
}
View
19 IOSMQ.m
@@ -1,9 +1,7 @@
//
// IOSMQ.m
-// Flyessence
//
// Created by Per-Olov Jernberg on 2012-02-22.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "IOSMQ.h"
@@ -67,14 +65,10 @@ + (id) queueWithWebView:(UIWebView *)webview {
return [mq autorelease];
}
-+ (NSString *) generateID {
- return @"";
-}
-
- (void) send:(IOSMQMessage *)message {
// TODO: Use SBJsonWriter instead
NSString *js = [NSString stringWithFormat:@"IOSMQ._backendPush({id:'%@',message:'%@'})",message.id,message.message];
- NSLog(@"pushing json: %@",js);
+ // NSLog(@"pushing json: %@",js);
[self.webview stringByEvaluatingJavaScriptFromString:js];
}
@@ -102,8 +96,7 @@ - (void) _poll {
}
- (void) start {
- NSLog(@"IOSMQ: start" );
- // hook events
+ // NSLog(@"IOSMQ: start" );
[self.webview setDelegate:self];
self->timer = [NSTimer scheduledTimerWithTimeInterval:self.pollInterval target:self selector:@selector(_poll) userInfo:nil repeats:YES];
}
@@ -116,14 +109,14 @@ - (void) dealloc {
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
- NSLog(@"IOSMQ: did fail; %@", error);
+ // NSLog(@"IOSMQ: did fail; %@", error);
if( nextDelegate != nil )
[nextDelegate webView:webView didFailLoadWithError:error];
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
- NSLog(@"IOSMQ: did start load");
+ // NSLog(@"IOSMQ: did start load");
if( nextDelegate != nil )
[nextDelegate webViewDidStartLoad:webView];
@@ -131,7 +124,7 @@ - (void)webViewDidStartLoad:(UIWebView *)webView
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
- NSLog(@"IOSMQ: did finish loading");
+ // NSLog(@"IOSMQ: did finish loading");
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"IOSMQ" ofType:@"js"];
if( filepath != nil ){
@@ -148,7 +141,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString* urlString = [[request URL] absoluteString];
- NSLog(@"IOSMQ: request: %@", urlString);
+ // NSLog(@"IOSMQ: request: %@", urlString);
if( nextDelegate != nil )
return [nextDelegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
View
8 README.md
@@ -35,6 +35,12 @@ Send messages to the html app
[mq send:[IOSMQMessage messageWithMessage:@"message from app"]];
````
+If you have another UIWebViewDelegate you want to use you can chain it after ourone.
+
+```Objective-C
+mq.nextDelegate = mydelegate;
+```
+
In JavaScript land:
-------------------
@@ -52,7 +58,7 @@ IOSMQ.listen(function(message,id){
Query for data in the native app:
```JavaScript
-IOSMQ.get( 'purchase-status/'+id, function( answer ) {
+IOSMQ.get( 'purchase-status/123', function( answer ) {
alert(answer);
} );
```

0 comments on commit a5b123c

Please sign in to comment.
Something went wrong with that request. Please try again.