Skip to content

Instantly share code, notes, and snippets.

View aschenkel's full-sized avatar

Axel Schenkelman aschenkel

View GitHub Profile
@blankg
blankg / WebViewBridge.js
Last active August 30, 2024 15:06
For RN >= 0.57 please look at https://github.com/blankg/rn-webview-bridge-sample-new/blob/master/resources/index.html. Provides a sample implementation for sending and receiving messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
/**
* Created by Guy Blank on 3/9/17.
*
* This is a sample provides an API to send & receive messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
* A sample project that uses the bridge is available here https://github.com/blankg/rn-webview-bridge-sample
*
* webViewBridge.send('functionToInvoke', {mydata: 'test'}, function(){console.log('success')},function(){console.log('error')});
*
* The API is designed to be similar to the Cordova exec API so migration to it should be almost seamless.
* The API also provides solution to a React-Native WebView bug in iOS which causes sending consecutive postMessage calls to override each other.
@andybangs
andybangs / GSEventEmitter.h
Last active February 4, 2019 03:03
Example RCTEventEmitter Subclass
#import "RCTEventEmitter.h"
#import "RCTBridge.h"
@interface GSEventEmitter : RCTEventEmitter <RCTBridgeModule>
+ (BOOL)application:(UIApplication *)application didSightBeacon:(NSString *)beaconID;
+ (BOOL)application:(UIApplication *)application didDepartBeacon:(NSString *)beaconID;
@end
@jglozano
jglozano / webview_fullscreen.cs
Created February 26, 2012 17:27
Correct way of making a UIWebView that takes full screen and handles the notification/resizing correctly
private UIWebView CreateWebView(NSUrlRequest urlRequest) {
var webView = new UIWebView(this.View.Bounds);
webView.AutosizesSubviews = true;
webView.AutoresizingMask = (UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth);
webView.LoadRequest(urlRequest);
webView.LoadError += (sender, e) => {
var view = sender as UIWebView;
view.LoadHtmlString("<html><body><h1>Oops!</h1></body></html>",null);
};