Last active
January 5, 2018 00:00
-
-
Save zaguiini/bafc7dfe6eaa1ae83591394c544de774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
handleNavigationStateChange({ url }) { | |
... | |
if(Platform.OS === 'ios') { | |
this.refs[webviewRef].evaluateJavaScript('var isNative = "ios"') | |
} else { | |
this.refs[webviewRef].injectJavaScript('var isNative = "android"') | |
} | |
... | |
} | |
postMessage(message) { | |
message = JSON.stringify(message) | |
console.log('posting message', message) | |
const finalMessage = 'window.onMessage(' + message + ')' | |
if(Platform.OS === 'ios') { | |
this.refs[webviewRef].evaluateJavaScript(finalMessage) | |
} else { | |
this.refs[webviewRef].injectJavaScript(finalMessage) | |
} | |
console.log('message posted') | |
} | |
facebookLoginMethod() { | |
LoginManager | |
.logInWithReadPermissions(['public_profile']) | |
.then(response => { | |
// send the response back to the webview | |
this.postMessage(JSON.stringify({ ...response, type: 'facebookLogin' })) | |
}) | |
.catch(console.error) | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment