We use PhoneGap to use native capability of a mobile device. How does is work internally? How are we able to access PhoneGap’s implementation classes from a JavaScript method? Can someone please explain this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I did some spelunking on how Cordova iOS passes messages to the WebView. This is how to pass a message from iOS to JavaScript.
The
UIWebViewClass has a method calledstringByEvaluatingJavaScriptFromString.If you look in some files in the iOS Cordova Project, they are passing the JavaScript as a string that is to be executed to that function, e.g. CDVPlugin.m.
I do not know if iOS writes a new DOM node (something like
<script>alert('from iOS');</script>) or it executes the JavaScript through a special hook in Safari. I believe the later, in that, the documentation referenced above says:I don’t know how they could actually impose those limitations without some special access to that UIWebView’s internal state, so I doubt they are just inserting a new DOM node.