mirror of
https://github.com/status-im/react-native-webview-bridge.git
synced 2026-08-31 05:11:12 +00:00
29 lines
1.0 KiB
Objective-C
29 lines
1.0 KiB
Objective-C
#import <Foundation/Foundation.h>
|
|
#import "WVURLConnection.h"
|
|
|
|
@implementation WVURLConnection
|
|
|
|
// This method is used to receive the data which we get using post method.
|
|
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data
|
|
{
|
|
NSString *response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
NSString *trimmedResponse = [response stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
|
NSString *format = @"httpCallback('%@', '%@');";
|
|
|
|
NSString *command = [NSString stringWithFormat: format, self.callbackId, trimmedResponse];
|
|
[self.webView evaluateJavaScript:command completionHandler:nil];
|
|
}
|
|
|
|
// This method receives the error report in case of connection is not made to server.
|
|
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
|
|
{
|
|
}
|
|
|
|
// This method is used to process the data after connection has made successfully.
|
|
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
|
|
{
|
|
}
|
|
|
|
@end
|